Installing the Packages install.packages(“readxl”) install.packages(“ggpubr”) install.packages(“effectsize”) install.packages(“rstatix”)
Loading the Packages:
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
Loading Dataset:
Dataset6.3 <- read_excel("C:/Users/datta/Downloads/Dataset6.3.xlsx")
Seperate the Data by Condition:
Before <- Dataset6.3$Stress_Pre
After <- Dataset6.3$Stress_Post
Differences <- After - Before
Calculating Descriptive Statistics for Each Group:
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
Creating a Histogram of the Difference Scores:
hist(Differences,
main = "Histogram of Difference Scores",
xlab = "Value",
ylab = "Frequency",
col = "red",
border = "black",
breaks = 20)
Creating a Boxplot of the Difference Scores:
boxplot(Differences,
main = "Distribution of Score Differences (After - Before)",
ylab = "Difference in Scores",
col = "red",
border = "black")
Shapiro-Wilk Test of Normality:
shapiro.test(Differences)
##
## Shapiro-Wilk normality test
##
## data: Differences
## W = 0.95612, p-value = 0.1745
The p-value is 0.1745 (>.05). The data is normal, we need to continue with Dependent T-Test to conduct Inferentinal Test.
Conduct Inferential Test: 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
Since the results are significant (p-value <.05), we have to calculate the effect size.
Calculating the Effect Size: Cohen’s D for Dependent T-Test
t_result <- t.test(Before, After, paired = TRUE)
effectsize::cohens_d(t_result)
## For paired samples, 'repeated_measures_d()' provides more options.
## Cohen's d | 95% CI
## ------------------------
## 0.66 | [0.29, 1.03]
The effect size is 0.66, which is medium in magnitude.
Reporting Results: There was a significant difference in stress levels between Before joining mindfulness training program (M = 65.869, SD = 9.496) and After joining mindfulness training program (M = 57.907, SD = 10.171), t(34) = 3.9286, p < .001. The effect size was medium (Cohen’s d = 0.66).