library(readxl)
library(rcompanion)
A6Q4 <- read_excel("C:/Users/nehab/OneDrive/A5221/Assignment 6/A6Q4.xlsx")
# Check the weightlifting groups
table(A6Q4$Exercise)
##
## lift nolift
## 25 25
# Descriptive statistics for each group
aggregate(
Weight ~ Exercise,
data = A6Q4,
FUN = mean
)
## Exercise Weight
## 1 lift 120.08238
## 2 nolift 33.02525
aggregate(
Weight ~ Exercise,
data = A6Q4,
FUN = sd
)
## Exercise Weight
## 1 lift 53.31766
## 2 nolift 56.70695
aggregate(
Weight ~ Exercise,
data = A6Q4,
FUN = median
)
## Exercise Weight
## 1 lift 115.58898
## 2 nolift 40.83897
# Examine weight distributions for both groups
boxplot(
Weight ~ Exercise,
data = A6Q4,
main = "Body Weight by Weightlifting",
xlab = "Regular Weightlifting",
ylab = "Body Weight"
)
# Test normality separately for both groups
by(
A6Q4$Weight,
A6Q4$Exercise,
shapiro.test
)
## A6Q4$Exercise: lift
##
## Shapiro-Wilk normality test
##
## data: dd[x, ]
## W = 0.78786, p-value = 0.0001436
##
## ------------------------------------------------------------
## A6Q4$Exercise: nolift
##
## Shapiro-Wilk normality test
##
## data: dd[x, ]
## W = 0.70002, p-value = 7.294e-06
# Both groups are not normally distributed because both p-values are less than .05.
# The boxplot also shows possible outliers.
# Therefore, a Mann-Whitney U Test will be used.
# Conduct the Mann-Whitney U Test
wilcox.test(
Weight ~ Exercise,
data = A6Q4,
exact = FALSE
)
##
## Wilcoxon rank sum test with continuity correction
##
## data: Weight by Exercise
## W = 603, p-value = 1.836e-08
## alternative hypothesis: true location shift is not equal to 0
# Calculate the effect size
wilcoxonR(
A6Q4$Weight,
A6Q4$Exercise
)
## r
## 0.798
A Mann-Whitney U test was conducted to compare body weight between participants who regularly lift weights and participants who do not. Body weight was significantly higher for the weightlifting group (Mdn = 115.59) than for the no-weightlifting group (Mdn = 40.84), W = 603, p < .001. The effect size was large (r = .80). Therefore, the null hypothesis was rejected.