library(dplyr)
##
## Caricamento pacchetto: 'dplyr'
## I seguenti oggetti sono mascherati da 'package:stats':
##
## filter, lag
## I seguenti oggetti sono mascherati da 'package:base':
##
## intersect, setdiff, setequal, union
library(effectsize)
library(effsize)
library(readxl)
library(ggpubr)
## Caricamento del pacchetto richiesto: ggplot2
A6Q4 <- read_excel("C:\\Users\\sonis\\OneDrive\\Desktop\\SLU\\AA 5221\\Assignment6\\A6Q4.xlsx")
A6Q4 %>%
group_by(Exercise) %>%
summarise(
Mean = mean(Weight, na.rm = TRUE),
Median = median(Weight, na.rm = TRUE),
SD = sd(Weight, na.rm = TRUE),
N = n()
)
## # A tibble: 2 × 5
## Exercise Mean Median SD N
## <chr> <dbl> <dbl> <dbl> <int>
## 1 lift 120. 116. 53.3 25
## 2 nolift 33.0 40.8 56.7 25
hist(A6Q4$Weight[A6Q4$Exercise == "lift"],
breaks = 15,
col = "skyblue",
border = "white")

hist(A6Q4$Weight[A6Q4$Exercise == "nolift"],
breaks = 15,
col = "firebrick",
border = "white")

#Data for lift group appears abnormally distributed.
#Data for nolift group appears abnormally distributed.
ggboxplot(A6Q4, x = "Exercise", y = "Weight",
color = "Exercise",
palette = "jco",
add = "jitter")

# The lift group boxplot does have outliers.
# The nolift group boxplot does have outliers.
shapiro.test(A6Q4$Weight[A6Q4$Exercise == "lift"])
##
## Shapiro-Wilk normality test
##
## data: A6Q4$Weight[A6Q4$Exercise == "lift"]
## W = 0.78786, p-value = 0.0001436
shapiro.test(A6Q4$Weight[A6Q4$Exercise == "nolift"])
##
## Shapiro-Wilk normality test
##
## data: A6Q4$Weight[A6Q4$Exercise == "nolift"]
## W = 0.70002, p-value = 7.294e-06
#The lift group is abnormally distributed, (p < .01).
#The nolift group is abnormally distributed, (p < .01).
t.test(Weight ~ Exercise, data = A6Q4, var.equal = TRUE)
##
## Two Sample t-test
##
## data: Weight by Exercise
## t = 5.5923, df = 48, p-value = 1.045e-06
## alternative hypothesis: true difference in means between group lift and group nolift is not equal to 0
## 95 percent confidence interval:
## 55.75715 118.35710
## sample estimates:
## mean in group lift mean in group nolift
## 120.08238 33.02525
cohens_d_result <- cohens_d(Weight ~ Exercise, data = A6Q4)
print(cohens_d_result)
## Cohen's d | 95% CI
## ------------------------
## 1.58 | [0.94, 2.21]
##
## - Estimated using pooled SD.
# An Independent T-Test was conducted to determine if there was a difference in Weight between people who lift weights and don't lift weights
# The lift group scores (M = 120.08, SD = 53.3) were significantly different from nolift group scores (M = 33.02, SD = 56.7), (t(df 48) = 5.60, p < .01).
# The effect size was very large, Cohen's d = 1.58.