library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(effectsize)
library(effsize)
library(readxl)
library(ggpubr)
## Loading required package: ggplot2
A6Q4 <- read_excel("C:/Users/tmd97/Downloads/A6Q4.xlsx")
View(A6Q4)
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 == "nolift"],
breaks = 15,
col = "skyblue",
border = "white")

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

#Data for nolift appears abnormally distributed.
#Data for lift appears abnormally distributed.
#Added the histogram from the answer key. When I originally completed the assignment, I was unable to generate the histogram because R returned an error indicating that the values were too far apart.
ggboxplot(A6Q4, x = "Exercise", y = "Weight",
color = "Exercise",
palette = "jco",
add = "jitter")

# The nolift boxplot does have outliers.
# The lift boxplot does have outliers.
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
shapiro.test(A6Q4$Weight[A6Q4$Exercise == "lift"])
##
## Shapiro-Wilk normality test
##
## data: A6Q4$Weight[A6Q4$Exercise == "lift"]
## W = 0.78786, p-value = 0.0001436
#The first group is abnormally distributed, (p < .05).
#I changed the "first group" to nolift group. I hadn't changed the group name. I also changed p < .05 to p < .000.
#The second group is abnormally distributed, (p < .05).
#I changed the "second group" to lift group. I had forgotten to change the group name. I also changed p < .05 to p < .000.
wilcox.test(Weight ~ Exercise, data = A6Q4)
##
## 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
mw_effect <- cliff.delta(Weight ~ Exercise, data = A6Q4)
print(mw_effect)
##
## Cliff's Delta
##
## delta estimate: 0.9296 (large)
## 95 percent confidence interval:
## lower upper
## 0.7993841 0.9764036
#A Mann-Whitney U test was conducted to determine if there was a difference in Weight between nolift and lift.
#I am confused. The answer key states that an Independent T-Test was conducted. However, the actual code on the answer key is wilcox.test(), followed by Cliff's delta. That should make the test conducted the Mann-Whiney U test not the Independent T-Test. Could you please explain if I missunderstood something?
#nolift scores (Mdn = 40.8) were significantly different from lift scores (Mdn = 116), W = 603, p < .001.
#The effect size was large, Cliff's Delta = .930.