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(effsize)
Mindfulness Program Import dataset
Dataset6.3 <- read_excel("/Users/karim/Desktop/Dataset6.3.xlsx")
Separate the Data by Condition
Before <- Dataset6.3$Stress_Pre
After <- Dataset6.3$Stress_Post
Create difference scores
Differences <- After - Before
Descriptive Statistics
Pre-Program Stress
mean(Before, na.rm = TRUE)
## [1] 65.86954
median(Before, na.rm = TRUE)
## [1] 67.33135
sd(Before, na.rm = TRUE)
## [1] 9.496524
Post-Program Stress
mean(After, na.rm = TRUE)
## [1] 57.90782
median(After, na.rm = TRUE)
## [1] 59.14539
sd(After, na.rm = TRUE)
## [1] 10.1712
Interpretation: Report means and SDs if data is normal. Report medians if data is not normal.
Step 6: Histogram of Difference Scores
hist(Differences,
main = "Histogram of Stress Difference Scores (Post - Pre)",
xlab = "Difference in Stress Scores",
ylab = "Frequency",
col = "blue",
border = "black",
breaks = 20)
Interpretation: Examine symmetry (skewness) Examine shape (kurtosis) If symmetrical and bell-shaped → likely normal
Step 7: Boxplot of Difference Scores
boxplot(Differences,
main = "Distribution of Stress Score Differences",
ylab = "Difference in Stress Scores",
col = "lightblue",
border = "darkblue")
Interpretation: Check for dots (outliers) If no extreme outliers →
likely normal If extreme outliers → not normal
Step 8: Shapiro-Wilk Test of Normality
shapiro.test(Differences)
##
## Shapiro-Wilk normality test
##
## data: Differences
## W = 0.95612, p-value = 0.1745
Interpretation:
p < .05 → Data NOT normal → Use Wilcoxon Sign Rank
Wilcoxon Sign
wilcox.test(Before, After, paired = TRUE)
##
## Wilcoxon signed rank exact test
##
## data: Before and After
## V = 518, p-value = 0.0005508
## alternative hypothesis: true location shift is not equal to 0
Step 10: 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.562 35 35 large
There was a significant difference in stress levels between Pre-Program (M = 42.35, SD = 8.47) and Post-Program (M = 34.39, SD = 9.12), t(29) = 3.64, p = .001. The effect size was medium (Cohen’s d = 0.66)