library(readxl)
library(ggpubr)
## Loading required package: ggplot2
library(effectsize)
Dataset6.3 <- read_excel("C:/Users/joyce/Downloads/Dataset6.3.xlsx")
Before <- Dataset6.3$Stress_Pre
After <- Dataset6.3$Stress_Post

Differences <- After - Before

This creates the before variables that store the pre-stress and after variable that stores the post-stress scores. Creates a difference score

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

This calculates the descriptive statistics mean 65.86954, median of 67.33135, SD 9.496524 of the before after mean 57.90782, median 59.14539 and SD 10.1712

hist(Differences,
     main = "Histogram of Difference Scores",
     xlab = "Difference(Post - Pre) ",
     ylab = "Frequency",
     col = "blue",
     border = "black",
     breaks = 20)

The histogram appears positively skewed and not symmetrical and it does not have a proper bell-shaped curve. The histogram appears tall and not so thin.

boxplot(Differences,
        main = "Distribution of Score Differences (After - Before)",
        ylab = "Difference in Scores",
        col = "blue",
        border = "darkblue")

There was no outlier in the boxplot.There where no dots outside of the whiskers.

shapiro.test(Differences)
## 
##  Shapiro-Wilk normality test
## 
## data:  Differences
## W = 0.95612, p-value = 0.1745

The p-value was above .05, which means we should proceed with the Dependent t-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
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]

This measures how big the difference is between the groups

The effect size is medium d= 0.66 indicating a difference between before and after scores.

There was a significant difference in the dependent variable between Before (M = 65.87, SD = 9.50) and After (M = 57.91, SD = 10.17), t(29) = 3.84, p = .001. The effect size was medium (Cohen’s d = 0.66).