library(readxl)
library(ggpubr)
## Loading required package: ggplot2
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
data <- read_excel("C:/Users/Admin/Downloads/Dataset6.4.xlsx")
head(data)
## # A tibble: 6 × 3
## Student_ID Stress_Pre Stress_Post
## <dbl> <dbl> <dbl>
## 1 1 53.5 45.5
## 2 2 37.4 33.9
## 3 3 35.8 9.49
## 4 4 89.0 82.8
## 5 5 30.5 26.8
## 6 6 42.5 26.9
str(data)
## 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] 53.5 37.4 35.8 89 30.5 ...
## $ Stress_Post: num [1:35] 45.48 33.92 9.49 82.77 26.82 ...
Before <- data$Stress_Pre
After <- data$Stress_Post
Differences <- After - Before
summary(Differences)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## -36.697 -14.400 -6.897 -10.045 -3.675 3.900
hist(Differences,
main = "Histogram of Difference Scores",
xlab = "Difference (Post - Pre)",
col = "lightblue",
border = "black",
breaks = 10)
#Interpretation
The histogram displays the distribution of the difference scores.If the histogram appears roughly symmetric and bell-shaped, the normality assumption is likely satisfied.If the histogram appears skewed or irregular, the normality assumption may be violated.
boxplot(Differences,
main = "Boxplot of Differences",
col = "lightgreen",
border = "black")
The boxplot helps identify potential outliers and the overall spread of the data.Data points beyond the whiskers indicate potential outliers.The presence of several outliers may suggest that the normality assumption is violated.
shapiro.test(Differences)
##
## Shapiro-Wilk normality test
##
## data: Differences
## W = 0.87495, p-value = 0.0008963
The Shapiro–Wilk test evaluates whether the difference scores are normally distributed.If p > .05 → Data are considered normal. If p < .05 → Data are not normal
If the Shapiro–Wilk test is not significant (p > .05), a paired-samples t-test is appropriate.If the Shapiro–Wilk test is significant (p < .05), a Wilcoxon signed-rank test is appropriate.
wilcox.test(Before, After, paired = TRUE)
##
## 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
There was a significant difference in the stress between Pre-Stress Group (Mdn = 47.24) and Post-Stress (Mdn = 40.84), V = 620, p = .000000002503 The effect size was very large (r₍rb₎ = .84).