library(readxl)
library(ggpubr)
library(dplyr)
library(effectsize)
library(effsize)
library(ggplot2)
library(rstatix)
A6Q4_2 %>%
group_by(Exercise) %>%
summarise(
Mean = mean(Weight),
SD = sd(Weight),
N = n()
)
## # A tibble: 2 × 4
## Exercise Mean SD N
## <chr> <dbl> <dbl> <int>
## 1 lift 120. 53.3 25
## 2 nolift 33.0 56.7 25
hist(
A6Q4_2$Weight[A6Q4_2$Exercise == "lift"],
main = "Histogram of Weight: Lifters",
xlab = "Weight",
ylab = "Frequency",
col = "lightblue",
border = "black",
breaks = 10
)
hist(
A6Q4_2$Weight[A6Q4_2$Exercise == "nolift"],
main = "Histogram of Weight: Non-Lifters",
xlab = "Weight",
ylab = "Frequency",
col = "lightgreen",
border = "black",
breaks = 10
)
#Group 1: Lifters #The first variable looks abnormally distributed. #The data is negatively skewed]. #The data does not have a proper bell curve.
#Group 2: Non-Lifters #The second variable looks abnormally distributed. #The data is positively skewed. #The data does not have a proper bell curve.
#NOTE for Professor - This flagged me to review the data. There are some weights that are negative. Not possible. Errors in the data.
ggboxplot(A6Q4_2, x = "Exercise", y = "Weight",
color = "Exercise",
palette = "jco",
add = "jitter")
#Boxplot 1: Lifters #There are dots outside the boxplot. #The dots are not close to the whiskers. #The dots are very far away from the whiskers. #The outliers are not balanced. #Based on these findings, the boxplot is not normal.
#Boxplot 2: Non Lifters ##There are dots outside the boxplot. #The dots are not close to the whiskers. #The dots are very far away from the whiskers. #The outliers are not balanced. #Based on these findings, the boxplot is not normal.
shapiro.test(A6Q4_2$Weight[A6Q4_2$Exercise == "lift"])
##
## Shapiro-Wilk normality test
##
## data: A6Q4_2$Weight[A6Q4_2$Exercise == "lift"]
## W = 0.78786, p-value = 0.0001436
shapiro.test(A6Q4_2$Weight[A6Q4_2$Exercise == "nolift"])
##
## Shapiro-Wilk normality test
##
## data: A6Q4_2$Weight[A6Q4_2$Exercise == "nolift"]
## W = 0.70002, p-value = 7.294e-06
#Group 1: Lifters #The first group is abnormally distributed, (p < .001).
#Group 2: Non-Lifters #The second group is abnormally distributed, (p < .001).
t.test(Weight ~ Exercise, data = A6Q4_2, 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
wilcox.test(Weight ~ Exercise, data = A6Q4_2)
##
## Wilcoxon rank sum exact test
##
## data: Weight by Exercise
## W = 603, p-value = 7.132e-11
## alternative hypothesis: true location shift is not equal to 0
NOTE TO PROFESSOR: R required me to use Rstatix, needed to research what to do due to unused arguement error.
cohens_d_result <- rstatix::cohens_d(
Weight ~ Exercise,
data = A6Q4_2
)
print(cohens_d_result)
## # A tibble: 1 × 7
## .y. group1 group2 effsize n1 n2 magnitude
## * <chr> <chr> <chr> <dbl> <int> <int> <ord>
## 1 Weight lift nolift 1.58 25 25 large
mw_effect <- cliff.delta(Weight ~ Exercise, data = A6Q4_2)
print(mw_effect)
##
## Cliff's Delta
##
## delta estimate: 0.9296 (large)
## 95 percent confidence interval:
## lower upper
## 0.7993841 0.9764036
A6Q4_2 %>%
group_by(Exercise) %>%
summarise(
Median = median(Weight),
N = n()
)
## # A tibble: 2 × 3
## Exercise Median N
## <chr> <dbl> <int>
## 1 lift 116. 25
## 2 nolift 40.8 25
#An Independent T-Test was conducted to determine if there was a difference in Weight between Lifters and Non-Lifters. #Lifters weights (M = 120.0, SD = 53.3) were significantly different from Non-Lifters weights (M = 33.0, SD = 56.7), t(48) = 5.59, p < .001. #The effect size was large, Cohen’s d = 1.5.
#A Mann-Whitney U test was conducted to determine if there was a difference in Weight between Lifters and Non-Lifters. #Lifters weights (Mdn = 116.0) were significantly different from Non-Lifters weights (Mdn = 40.8) U = 603, p < .001. #The effect size was large, Cliff’s Delta = .930.