Step 1: Open the Installed Packages
library(readxl)
library(ggpubr)
## Loading required package: ggplot2
library(effectsize)
Step 2: Import Dataset
Dataset6.3 <- read_excel("C:/Users/yenug/OneDrive/Documents/Assignment 6/Dataset6.3.xlsx")
Step 3: Seperate the Data by Condition
Before <- Dataset6.3$Stress_Pre
After <- Dataset6.3$Stress_Post
Differences <- After - Before
Step 4: Calculate Descriptive Statistics for Each Group
mean(Before, na.rm = TRUE)
## [1] 65.86954
median(Before, na.rm = TRUE)
## [1] 67.33135
sd(Before, na.rm = TRUE)
## [1] 9.496524
mean(After, na.rm = TRUE)
## [1] 57.90782
median(After, na.rm = TRUE)
## [1] 59.14539
sd(After, na.rm = TRUE)
## [1] 10.1712
Step 5: Create a Histogram of the Difference Scores
hist(Differences,
main = "Histogram of Difference in Stress Levels",
xlab = "Value",
ylab = "Frequency",
col = "lightblue",
border = "black",
breaks = 20)
The histogram appears positively skewed and looks tall and thin (Abnormal).
Step 6: Create a Boxplot of the Difference Scores
boxplot(Differences,
main = "Distribution of Stress Level Differences (After - Before)",
ylab = "Difference in Stress Level",
col = "lightblue",
border = "darkblue")
There are no outliers in the boxplot so the data is normal and we will continue with Dependent T-Test.
Step 7: Shapiro-Wilk Test of Normality
shapiro.test(Differences)
##
## Shapiro-Wilk normality test
##
## data: Differences
## W = 0.95612, p-value = 0.1745
The p-value was above .05, the data is NORMAL which means we should proceed with the Dependent T-Test.
Step 8: Conduct Inferential Test
t.test(Before, After, paired = TRUE)
##
## Paired t-test
##
## data: Before and After
## t = 3.9286, df = 34, p-value = 0.0003972
## alternative hypothesis: true mean difference is not equal to 0
## 95 percent confidence interval:
## 3.843113 12.080317
## sample estimates:
## mean difference
## 7.961715
p < .05, (less than .05), this means the results were SIGNIFICANT. Effect Size is calculated in the next step.
Step 9: Calculate the Effect Size
cohens_d(Before, After, paired = TRUE)
## For paired samples, 'repeated_measures_d()' provides more options.
## Cohen's d | 95% CI
## ------------------------
## 0.66 | [0.29, 1.03]
Cohen’s D effect size is 0.66 which means the the difference between the group averages is Medium.
Step 10: Results
There was a significant difference in Stress levels between Stress_Pre (65.86, SD = 9.49) and Stress_Post (M = 57.90, SD = 10.17), t(34) = 3.92, p < .001. The effect size was Medium (Cohen’s d = 0.66).
library(rmarkdown)