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
Dataset6.4 <- read_excel("D:/SLU/AdvAppliedAnalytics/Dataset6.4.xlsx")
Before1 <- Dataset6.4$Stress_Pre
After1 <- Dataset6.4$Stress_Post
Differences1 <- After1 - Before1
mean(Before1, na.rm = TRUE)
## [1] 51.53601
median(Before1, na.rm = TRUE)
## [1] 47.24008
sd(Before1, na.rm = TRUE)
## [1] 17.21906
The variable Stress_Pre had a mean of 51.54, median of 47.24 and a standard deviation of 17.22
mean(After1, na.rm = TRUE)
## [1] 41.4913
median(After1, na.rm = TRUE)
## [1] 40.84836
sd(After1, na.rm = TRUE)
## [1] 18.88901
The variable Stress_Post had a mean of 41.49, median of 40.84 and a standard deviation of 18.90
hist(Differences1,
main = "Histogram of Difference Scores",
xlab = "Value",
ylab = "Frequency",
col = "blue",
border = "black",
breaks = 20)
The data looks negatively skewed (most data is in the right) - not normal. The data also appears to not have a proper bell curve - not normal.
boxplot(Differences1,
main = "Distribution of Score Differences1 (After1 - Before1)",
ylab = "Difference in Scores",
col = "blue",
border = "darkblue")
There was two outlier in the boxplot. And it is far away from the whisker.
shapiro.test(Differences1)
##
## Shapiro-Wilk normality test
##
## data: Differences1
## W = 0.87495, p-value = 0.0008963
The p-value = 0.0008963(less than .05), which means the data was NOT normal we should proceed with the Wilcoxon Sign Rank Test.
wilcox.test(Before1, After1, paired = TRUE)
##
## Wilcoxon signed rank exact test
##
## data: Before1 and After1
## V = 620, p-value = 2.503e-09
## alternative hypothesis: true location shift is not equal to 0
p-value = 2.503e-09 (less than .05), this means the results were SIGNIFICANT
df_long <- data.frame(
id = rep(1:length(Before1), 2),
time = rep(c("Before1", "After1"), each = length(Before1)),
score = c(Before1, After1)
)
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 After1 Before1 0.844 35 35 large
The effect size was very large (.84)
There was a significant difference in stress between students in Stress_Pre (Mdn = 47.24) and Stress_Post (Mdn = 40.85), V = 620, p = .0001. The effect size was very large (r₍rb₎ = .84)