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(effsize)
library(readxl)
library(ggpubr)
## Loading required package: ggplot2
library(ggpubr)
A6Q3 <- read_excel("C:/Users/giuli/OneDrive - Saint Louis University/AA 5221/Assignment 6/A6Q3.xlsx")
A6Q3 %>%
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 cardio 74.7 73.3 7.57 25
## 2 nocardio 70.8 69.5 7.35 25
hist(A6Q3$Weight[A6Q3$Exercise == "cardio"],
breaks = 15,
col = "skyblue",
border = "white")

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

#Data for cardio appears normally distributed.
#Data for nocardio appears abnormally distributed.
ggboxplot(A6Q3, x = "Exercise", y = "Weight",
color = "Exercise",
palette = "jco",
add = "jitter")

# The cardio boxplot does not have outliers.
# The nocardio boxplot does not have outliers.
shapiro.test(A6Q3$Weight[A6Q3$Exercise == "cardio"])
##
## Shapiro-Wilk normality test
##
## data: A6Q3$Weight[A6Q3$Exercise == "cardio"]
## W = 0.96745, p-value = 0.5812
shapiro.test(A6Q3$Weight[A6Q3$Exercise == "nocardio"])
##
## Shapiro-Wilk normality test
##
## data: A6Q3$Weight[A6Q3$Exercise == "nocardio"]
## W = 0.97686, p-value = 0.8166
#The cardio group is normally distributed, (p > .05).
#The nocardio group is normally distributed, (p > .05).
t.test(Weight ~ Exercise, data = A6Q3, var.equal = TRUE)
##
## Two Sample t-test
##
## data: Weight by Exercise
## t = 1.8552, df = 48, p-value = 0.06971
## alternative hypothesis: true difference in means between group cardio and group nocardio is not equal to 0
## 95 percent confidence interval:
## -0.3280454 8.1605622
## sample estimates:
## mean in group cardio mean in group nocardio
## 74.73336 70.81710
wilcox.test(Weight ~ Exercise, data = A6Q3)
##
## Wilcoxon rank sum exact test
##
## data: Weight by Exercise
## W = 399, p-value = 0.09541
## alternative hypothesis: true location shift is not equal to 0
mw_effect <- cliff.delta(Weight ~ Exercise, data = A6Q3); print(mw_effect)
##
## Cliff's Delta
##
## delta estimate: 0.2768 (small)
## 95 percent confidence interval:
## lower upper
## -0.05295739 0.55212525
#A Mann-Whitney U test was conducted to determine if there was a difference in Weight between cardio and nocardio.
#cardio scores (Mdn = 73.3) were significantly different from nocardio scores (Mdn = 69.5), W = 0.967, p = 0.581.
#The effect size was small / medium Cliff's Delta = 0.277.