library(readxl)
library(ggpubr)
## Loading required package: ggplot2
library(effectsize)
library(rstatix)
## 
## Attaching package: 'rstatix'
## The following objects are masked from 'package:effectsize':
## 
##     cohens_d, eta_squared
## The following object is masked from 'package:stats':
## 
##     filter

Import Dataset

Dataset6.4 <- read_excel("/Users/karim/Desktop/Dataset6.4.xlsx")

Separate the Data by Condition

Before <- Dataset6.4$Stress_Pre
After  <- Dataset6.4$Stress_Post
Differences <- After - Before

Descriptive Statistics

Before Program

mean(Before, na.rm = TRUE)
## [1] 51.53601
median(Before, na.rm = TRUE)
## [1] 47.24008
sd(Before, na.rm = TRUE)
## [1] 17.21906

After Program

mean(After, na.rm = TRUE)
## [1] 41.4913
median(After, na.rm = TRUE)
## [1] 40.84836
sd(After, na.rm = TRUE)
## [1] 18.88901

Histogram of Difference Scores

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

The histogram appears symmetrical and bell-shaped (normal).

Boxplot of Difference Scores

boxplot(Differences,
        main = "Boxplot of Stress Score Differences",
        ylab = "Difference Scores",
        col = "lightblue",
        border = "darkblue")

There was one outlier in the boxplot. However, it is not very far away from the whisker.

Shapiro-Wilk Test of Normality

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

The p-value was less than .05, which means we should proceed with the # Wilcoxon Sign.

Conduct Inferential Test

Wilcoxon Sign Rank

wilcox_test_result <- wilcox.test(Before, After, paired = TRUE)
wilcox_test_result
## 
##  Wilcoxon signed rank exact test
## 
## data:  Before and After
## V = 620, p-value = 2.503e-09
## alternative hypothesis: true location shift is not equal to 0

Calculate Effect Size

df_long <- data.frame(
  id = rep(1:length(Before), 2),
  time = rep(c("Before", "After"), each = length(Before)),
  score = c(Before, After)
)

wilcox_effsize(df_long, score ~ time, paired = TRUE)
## # A tibble: 1 × 7
##   .y.   group1 group2 effsize    n1    n2 magnitude
## * <chr> <chr>  <chr>    <dbl> <int> <int> <ord>    
## 1 score After  Before   0.844    35    35 large

effect size is VERY LARGE.

Report Results There was a significant difference in stress levels between Condition 1 (Mdn = 18.00) and Condition 2 (Mdn = 47.24), V = 0.00, p < .001. The effect size was large (r₍rb₎ = .87).