Loading Libraries
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
Research Question: Does a four-week mindfulness training program
reduce student stress levels?
Loading Dataset
DatasetRQ3 <- read_excel("DatasetRQ3.xlsx")
Checking Data and Dataset Structure
head(DatasetRQ3)
## # A tibble: 6 × 3
## Student_ID Stress_Pre Stress_Post
## <dbl> <dbl> <dbl>
## 1 1 82.0 59.1
## 2 2 57.9 35.7
## 3 3 62.2 74.4
## 4 4 63.8 56.4
## 5 5 63.8 58.3
## 6 6 67.7 42.6
str(DatasetRQ3)
## tibble [35 × 3] (S3: tbl_df/tbl/data.frame)
## $ Student_ID : num [1:35] 1 2 3 4 5 6 7 8 9 10 ...
## $ Stress_Pre : num [1:35] 82 57.9 62.2 63.8 63.8 ...
## $ Stress_Post: num [1:35] 59.1 35.7 74.4 56.4 58.3 ...
Seperate the Data by Condition
Stress_Pre <- DatasetRQ3$Stress_Pre
Stress_Post <- DatasetRQ3$Stress_Post
Differences <- Stress_Post - Stress_Pre
print(Differences)
## [1] -22.903638 -22.142247 12.137753 -7.396717 -5.477719 -25.048371
## [7] -13.486837 -6.827396 -7.950267 6.516529 -7.062918 -19.258741
## [13] 0.655531 -20.068451 -5.308485 -8.049830 -20.451612 -13.696728
## [19] -9.567336 -18.117255 -26.261721 -2.517369 -12.999376 21.424030
## [25] 2.706774 6.670166 16.860869 1.306624 -5.777144 9.455990
## [31] -16.661701 -15.088606 -14.976417 -12.220246 -17.077168
Calculate descriptive statistics for each group
cat("Pre-Test Mean: ", mean(Stress_Pre, na.rm = TRUE), "\n")
## Pre-Test Mean: 65.86954
cat("Pre-Test Median: ", median(Stress_Pre, na.rm = TRUE), "\n")
## Pre-Test Median: 67.33135
cat("Pre-Test SD: ", sd(Stress_Pre, na.rm = TRUE), "\n\n")
## Pre-Test SD: 9.496524
cat("Post-Test Mean: ", mean(Stress_Post, na.rm = TRUE), "\n")
## Post-Test Mean: 57.90782
cat("Post-Test Median: ", median(Stress_Post, na.rm = TRUE), "\n")
## Post-Test Median: 59.14539
cat("Post-Test SD: ", sd(Stress_Post, na.rm = TRUE), "\n")
## Post-Test SD: 10.1712
Check normality
Method 1: Histograms
hist(Differences,
main = "Histogram of Difference Scores (Post - Pre)",
xlab = "Change in Stress Levels",
ylab = "Frequency",
col = "purple",
border = "darkblue",
breaks = 15)

cat("Skewness: Positively skewed ,", "Kurtosis: Bell Curve")
## Skewness: Positively skewed , Kurtosis: Bell Curve
print("As the data is positively skewed also the shape is somehow resembling a bell curve")
## [1] "As the data is positively skewed also the shape is somehow resembling a bell curve"
print("Based on Reports we cannot use the Dependent T-test")
## [1] "Based on Reports we cannot use the Dependent T-test"
Method 2: Boxplots
boxplot(Differences,
main = "Distribution of Score Differences (Post Stress - Pre Stress)",
ylab = "Change in Stress Levels",
col = "lightblue",
border = "darkblue",
horizontal = FALSE)

print("The box plot appears to be normal and the data appears to be within whiskers")
## [1] "The box plot appears to be normal and the data appears to be within whiskers"
print("Based on Reports we can use the Dependent T-test")
## [1] "Based on Reports we can use the Dependent T-test"
Method 3: Shapiro-Wilk
shapiro.test(Differences)
##
## Shapiro-Wilk normality test
##
## data: Differences
## W = 0.95612, p-value = 0.1745
print("The value of p > 0.05, so the data is normal")
## [1] "The value of p > 0.05, so the data is normal"
print("Based on Reports we can use the Dependent T-test")
## [1] "Based on Reports we can use the Dependent T-test"
Interpretation: After conducting all three normality tests, it is
clear we must use a Dependent T-test.
Conduct Inferential Test (Dependent T-Test)
t.test(Stress_Pre, Stress_Post, paired = TRUE)
##
## Paired t-test
##
## data: Stress_Pre and Stress_Post
## 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
print("As the value of p < 0.05 (p = 0.0003972), this means the results were SIGNIFICANT.")
## [1] "As the value of p < 0.05 (p = 0.0003972), this means the results were SIGNIFICANT."
Calculate the Effect Size (Cohen’s D for Dependent T-Test)
cohens_d <- effectsize::cohens_d(Stress_Pre, Stress_Post, paired = TRUE)
## For paired samples, 'repeated_measures_d()' provides more options.
print(cohens_d)
## Cohen's d | 95% CI
## ------------------------
## 0.66 | [0.29, 1.03]
print("As the size of the effect is (0.60), this means the effect is 'Medium'.")
## [1] "As the size of the effect is (0.60), this means the effect is 'Medium'."
Report the Results
cat("There was a significant difference in stress between Pre-Stress Group (M = 65.86, SD = 9.49) and Post-Stress Group (M = 57.90, SD = 10.17), t(34) = 3.92, p < .0003972 The effect size was Medium (Cohen’s d = 66).")
## There was a significant difference in stress between Pre-Stress Group (M = 65.86, SD = 9.49) and Post-Stress Group (M = 57.90, SD = 10.17), t(34) = 3.92, p < .0003972 The effect size was Medium (Cohen’s d = 66).