Open the Required Packages

library(readxl)
library(ggpubr)
## Loading required package: ggplot2
library(rstatix)
## 
## Attaching package: 'rstatix'
## The following object is masked from 'package:stats':
## 
##     filter
library(effectsize)
## 
## Attaching package: 'effectsize'
## The following objects are masked from 'package:rstatix':
## 
##     cohens_d, eta_squared

Import & Name Dataset

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

Seperate the Data by Condition

Before <- Dataset6.3$Stress_Pre
After <- Dataset6.3$Stress_Post

Differences <- After - Before

Calculate Descriptive Statistics for Each Group

  1. Stress_Pre
mean(Before, na.rm = TRUE)
## [1] 65.86954
median(Before, na.rm = TRUE)
## [1] 67.33135
sd(Before, na.rm = TRUE)
## [1] 9.496524

The variable Stress_Pre had a mean of 65.87, median of 67.33 and a standard deviation of 9.50

  1. Stress_Post
mean(After, na.rm = TRUE)
## [1] 57.90782
median(After, na.rm = TRUE)
## [1] 59.14539
sd(After, na.rm = TRUE)
## [1] 10.1712

The variable Stress_Post had a mean of 57.91, median of 59.15 and a standard deviation of 10.17

Create a Histogram of the Difference Scores

hist(Differences,
     main = "Histogram of Difference Scores",
     xlab = "Value",
     ylab = "Frequency",
     col = "blue",
     border = "black",
     breaks = 20)

The data looks positively skewed (most data is in the left). The data also appears to have a proper bell curve.

Create a Boxplot of the Difference Scores

boxplot(Differences,
        main = "Distribution of Score Differences (After - Before)",
        ylab = "Difference in Scores",
        col = "blue",
        border = "darkblue")

There was no outlier out of the boxplot.

Conduct Shapiro–Wilk tests for to check the normality

shapiro.test(Differences)
## 
##  Shapiro-Wilk normality test
## 
## data:  Differences
## W = 0.95612, p-value = 0.1745

The p-value = 0.1745 (greater than .05), which means the data was normal we should proceed with the Dependent t-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

p-value = 0.0003972 (less than .05), this means the results were SIGNIFICANT

Calculate the Effect Size

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]

The effect size was medium (Cohen’s d = 0.66).

Report the Results

There was a significant difference in stress in student in group Stress_Pre (M = 65.87, SD = 9.50) and group Stress_Post (M = 57.91, SD = 10.17), t(34) = 3.93, p < .001. The effect size was medium (Cohen’s d = 0.66).