#Loading Dataset

Dataset6.3 <- read_excel("C:/Users/Student/Documents/Assignment6_AA/Dataset6.3.xlsx")
Before <- Dataset6.3$Stress_Pre
After  <- Dataset6.3$Stress_Post
Differences <- After - Before

Descriptive Statistics

mean(Before); sd(Before); median(Before)
## [1] 65.86954
## [1] 9.496524
## [1] 67.33135
mean(After); sd(After); median(After)
## [1] 57.90782
## [1] 10.1712
## [1] 59.14539

Histogram of Difference Scores

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

#Boxplot

boxplot(Differences,
        main = "Distribution of Score Differences (Post - Pre)",
        ylab = "Difference in Scores",
        col = "lightblue",
        border = "darkblue")

# Normality of Differences

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

# Paired 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

Effect Size

Dataset6.3 %>%
  cohens_d(Stress_Post ~ Stress_Pre, paired = TRUE)
## # A tibble: 595 × 7
##    .y.         group1           group2           effsize    n1    n2 magnitude
##  * <chr>       <chr>            <chr>              <dbl> <int> <int> <ord>    
##  1 Stress_Post 41.6906882541988 49.6958783027338      NA     1     1 <NA>     
##  2 Stress_Post 41.6906882541988 53.4656051466686      NA     1     1 <NA>     
##  3 Stress_Post 41.6906882541988 53.7967257510268      NA     1     1 <NA>     
##  4 Stress_Post 41.6906882541988 54.2776119794539      NA     1     1 <NA>     
##  5 Stress_Post 41.6906882541988 56.9532831578635      NA     1     1 <NA>     
##  6 Stress_Post 41.6906882541988 57.4198472087007      NA     1     1 <NA>     
##  7 Stress_Post 41.6906882541988 57.8796143506825      NA     1     1 <NA>     
##  8 Stress_Post 41.6906882541988 59.4808533383599      NA     1     1 <NA>     
##  9 Stress_Post 41.6906882541988 60.2531530410475      NA     1     1 <NA>     
## 10 Stress_Post 41.6906882541988 62.2201508620985      NA     1     1 <NA>     
## # ℹ 585 more rows

#Reporting the result

  cat("The results indicated that there was a statistically significant difference 
      between stress levels before and after the intervention,
      t(34) = 3.93, p < .001, 95% CI [3.84, 12.08]. The mean difference was 7.96.")
## The results indicated that there was a statistically significant difference 
##       between stress levels before and after the intervention,
##       t(34) = 3.93, p < .001, 95% CI [3.84, 12.08]. The mean difference was 7.96.