#install.packages("readxl")
#install.packages("ggpubr")
#install.packages("effectsize")
#install.packages("rstatix")
#Load Librabries
library(readxl)
library(ggpubr)
## Loading required package: ggplot2
library(effectsize)
Dataset6.3 <- read_excel("/Users/ha113ab/Desktop/datasets/Research Assignment 6/Dataset6.3.xlsx")
Before <- Dataset6.3$Stress_Pre
After <- Dataset6.3$Stress_Post
Differences <- After - Before
#Descriptive Statistics
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
# Differences Hisatogram Visualization
hist(Differences,
main = "Histogram of Difference Scores (Post - Pre)",
xlab = "Value",
ylab = "Frequency",
col = "blue",
border = "black",
breaks = 20)

#histogram is symmetrical and the kurosis is als0 bell shaped seems to be normally distributed and
#Method 2 Boxplot
boxplot(Dataset6.3$Stress_Post - Dataset6.3$Stress_Pre,
main = "Distribution of Difference Scores (Post - Pre)",
ylab = "Difference in Scores",
col = "green",
border = "black")

# Normal Distribution there are no outliers
# since the data is normal
# we'll use Dependet T-test
shapiro.test(Differences)
##
## Shapiro-Wilk normality test
##
## data: Differences
## W = 0.95612, p-value = 0.1745
#p-value = 0.1745 Greater than 0.5 proceed with dependent t-test
#Inferential 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
#p-value = 0.001
#Since the P value is less than 0.5 we will proceed with calculating the Effect Size with cohens D
cohens_d(Before, After, paired = TRUE)
## For paired samples, 'repeated_measures_d()' provides more options.
## Cohen's d | 95% CI
## ------------------------
## 0.66 | [0.29, 1.03]
#0.66 it was a medium effect size.
"There is a significant change in stress levels between students who participated in the mindfulness
training program before and after. Stress_Pre (M = 65.86, SD = 9.49) and Stress_Post (M =57.91, SD = 10.17),
t(34) = 3.9286, p < .001 The effect size was medium (Cohen’s d = 0.66).)."
## [1] "There is a significant change in stress levels between students who participated in the mindfulness \ntraining program before and after. Stress_Pre (M = 65.86, SD = 9.49) and Stress_Post (M =57.91, SD = 10.17), \nt(34) = 3.9286, p < .001 The effect size was medium (Cohen’s d = 0.66).)."