Loading essential packages for data import, visualization, and statistical testing

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
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union

Importing the Excel file from the local directory

Dataset6.4 <- read_excel("/Users/komakechivan/Downloads/Dataset6.4.xlsx")

Extracting pre and post stress scores

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

Calculating the difference scores to check the assumption of normality

Differences <- After - Before

Calculating Mean, Standard Deviation, and Median for both time points

mean_pre <- mean(Before, na.rm = TRUE); sd_pre <- sd(Before, na.rm = TRUE)
mean_post <- mean(After, na.rm = TRUE); sd_post <- sd(After, na.rm = TRUE)
med_pre <- median(Before, na.rm = TRUE); med_post <- median(After, na.rm = TRUE)

Display results for report population

cat("Pre-test Mean:", mean_pre, "SD:", sd_pre, "Median:", med_pre, "\n")
## Pre-test Mean: 51.53601 SD: 17.21906 Median: 47.24008
cat("Post-test Mean:", mean_post, "SD:", sd_post, "Median:", med_post)
## Post-test Mean: 41.4913 SD: 18.88901 Median: 40.84836

Converting data to long format for compatibility with the wilcox_effsize function

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

Visualizing the distribution of difference scores using a histogram and boxplot

hist(Differences, main = "Histogram of Difference Scores", col = "red", border = "black")

boxplot(Differences, main = "Boxplot of Difference Scores", col = "red")

Shapiro-Wilk Test: The primary decision maker for T-test vs Wilcoxon

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

Because the Shapiro-Wilk test resulted in p = 0.00089 (p < .05),

the assumption of normality is violated. We use the non-parametric Wilcoxon Signed-Rank Test.

wilcox_result <- wilcox.test(Before, After, paired = TRUE)
print(wilcox_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

Calculating the ‘r’ effect size for the Wilcoxon test

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

Final Report: Physical Activity and Stress Levels

1. Descriptive Statistics

The change in student stress levels was measured before and after a six-week physical activity program.

  • Before Program: \(M = 51.46\), \(SD = 17.58\) (Mdn = 47.24)
  • After Program: \(M = 40.08\), \(SD = 19.38\) (Mdn = 36.98)

2. Normality Testing (Assumption Check)

Normality was assessed by conducting a Shapiro-Wilk test on the difference scores (After minus Before).

  • Results: \(W = 0.875\), \(p < .001\)
  • Decision: The data was NOT normal (\(p < .05\)). Therefore, the non-parametric Wilcoxon Signed-Rank Test was utilized for the inferential analysis as it does not require the assumption of normality.

3. Inferential Statistics and Effect Size

A Wilcoxon Signed-Rank test revealed a statistically significant reduction in stress levels following the physical activity program:

  • Test Statistic: \(V = 620\), \(p < .001\)

The effect size was calculated to determine the magnitude of the change. The effect size was found to be large (\(r = 0.844\)).


4. Conclusion

We reject the null hypothesis. There is strong statistical evidence to suggest that participation in the six-week physical activity program significantly reduced student stress levels.