Step 1: Open the installed packages
library(readxl)
library(ggpubr)
## Loading required package: ggplot2
library(effectsize)
Step 2: Import Data Set
Dataset6.3 <- read_excel("D:/SLU/APPLIED ANALYTICS/ASSIGNMENT 6/Dataset6.3.xlsx")
Step 3: Seperate the Data by Condition
Before <- Dataset6.3$Stress_Pre
After <- Dataset6.3$Stress_Post
Differences <- After - Before
Step 4: Calculating Descriptive Statistics for Each Group
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
Step 5: Create a Histogram of the Difference Scores
hist(Differences,
main = "Histogram of Difference in Stress Levels",
xlab = "Stress",
ylab = "Frequency",
col = "lightblue",
border = "black",
breaks = 20)
The histogram appears positively skewed. In the kurtosis Histogram appears tall and thin (abnormal)
Step 6: Creating a Boxplot of the Difference Scores
boxplot(Differences,
main = "Distribution of Stress Level Differences (After - Before)",
ylab = "Difference in Stress Level",
col = "blue",
border = "darkblue")
There are no outliers in the boxplot. We may need to use Dependent T-Test
Step 7: Shapiro-Wilk Test of Normality
shapiro.test(Differences)
##
## Shapiro-Wilk normality test
##
## data: Differences
## W = 0.95612, p-value = 0.1745
p > .05 (0.1745 greater than .05), the data is NORMAL. We may proceed with Dependent t-test
Step 8: Conducting 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<0.05, this means results are significant, effect size is calculated in the next step.
Step 9: Calculating 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 is 0.66 which is medium
Step 10: Reporting of Results
There was a significant difference in the dependent variable between 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).
library(rmarkdown)