Assignment 6- Dataset 6.4

Step 1: Install the Required Packages

install.packages(“readxl”) install.packages(“ggpubr”) install.packages(“effectsize”) install.packages(“rstatix”)

Step 2: Open the Installed 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

Step 3: Import and Name Dataset

Dataset6.4 <- read_excel("C:/Users/srina/OneDrive/Documents/Madhu Master's/Applied Analytics/Assignment 6/Dataset6.4.xlsx")

Step 4: Seperate the Data by Condition

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

Differences <- After - Before

Step 5: Calculate Descriptive Statistics for Each Group

mean(Before, na.rm = TRUE)
## [1] 51.53601
median(Before, na.rm = TRUE)
## [1] 47.24008
sd(Before, na.rm = TRUE)
## [1] 17.21906
mean(After, na.rm = TRUE)
## [1] 41.4913
median(After, na.rm = TRUE)
## [1] 40.84836
sd(After, na.rm = TRUE)
## [1] 18.88901

Step 6: Create a Histogram of the Difference Scores

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

Histogram is Negatively skewed and It is difficult to state the exact kurtosis, but it appears abnormal.

Step 7: 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 two outliers in the boxplot. However, it is far away from the whisker.

Step 8: Shapiro-Wilk Test of Normality

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

The p-value was below .05, which means we should proceed with the Wilcoxon Sign Rank.

Step 9: Conduct Inferential Test

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

Here, p < .05, (less than .05), this means the results were SIGNIFICANT.

Report the Results

There was a significant difference in stress levels between Before(Stress_Pre) (Mdn = 47.24) and After(Stress_Post) (Mdn = 40.85), V = 620, p < .001.