Open the Required 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

Import & Name Dataset

Dataset6.4 <- read_excel("D:/SLU/AdvAppliedAnalytics/Dataset6.4.xlsx")

Seperate the Data by Condition

Before1 <- Dataset6.4$Stress_Pre
After1 <- Dataset6.4$Stress_Post

Differences1 <- After1 - Before1

Calculate Descriptive Statistics for Each Group

  1. Stress_Pre
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

  1. Stress_Post
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

Create a Histogram of the Difference Scores

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.

Create a Boxplot of the Difference Scores

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.

Conduct Shapiro–Wilk tests for to check the normality

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.

Conduct Inferential Test - 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

Calculate the Effect Size - Rank Biserial Correlation for Mann-Whitney U

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)

Report the Results

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)