library(readxl)
library(rstatix)
##
## Attaching package: 'rstatix'
## The following object is masked from 'package:stats':
##
## filter
library(ggpubr)
## Loading required package: ggplot2
library(effectsize)
##
## Attaching package: 'effectsize'
## The following objects are masked from 'package:rstatix':
##
## cohens_d, eta_squared, omega_squared
A6Q3 <- read_excel("C:/Users/DeSheila Hatcher/OneDrive/AA 5221/Assignment 6/A6Q3.xlsx")
Cardio <- A6Q3$Weight[A6Q3$Exercise == "cardio"]
NoCardio <- A6Q3$Weight[A6Q3$Exercise == "nocardio"]
mean(Cardio, na.rm = TRUE)
## [1] 74.73336
median(Cardio, na.rm = TRUE)
## [1] 73.2562
sd(Cardio, na.rm = TRUE)
## [1] 7.573859
mean(NoCardio, na.rm = TRUE)
## [1] 70.8171
median(NoCardio, na.rm = TRUE)
## [1] 69.50471
sd(NoCardio, na.rm = TRUE)
## [1] 7.350987
hist(NoCardio,
breaks = 15,
col = "skyblue",
border = "white")
hist(Cardio,
breaks = 15,
col = "firebrick",
border = "white")
ggboxplot(A6Q3, x = "Exercise", y = "Weight",
color = "Exercise",
palette = "jco",
add = "jitter")
# I added the missing histograms and boxplot.
# My original analysis did not include these graphs.
# I added them to examine the distributions and
# check for potential outliers, as shown in the answer key.
shapiro.test(Cardio)
##
## Shapiro-Wilk normality test
##
## data: Cardio
## W = 0.96745, p-value = 0.5812
shapiro.test(NoCardio)
##
## Shapiro-Wilk normality test
##
## data: NoCardio
## W = 0.97686, p-value = 0.8166
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
# I corrected my independent t-test by adding var.equal = TRUE.
# My original code used the default Welch t-test instead of
# the equal-variances t-test shown in the answer key.
cohens_d_result <- effectsize::cohens_d(Weight ~ Exercise, data = A6Q3, pooled_sd = TRUE)
print(cohens_d_result)
## Cohen's d | 95% CI
## -------------------------
## 0.52 | [-0.04, 1.09]
##
## - Estimated using pooled SD.
# I corrected my effect-size calculation by using the
# effectsize package instead of rstatix.
# My previous code produced an unused argument error.
# I specified pooled_sd = TRUE to match the answer key..
# I updated my written interpretation to reflect the
# corrected independent t-test and effect-size results.
# I changed the degrees of freedom from 47.96 to 48,
# updated Cohen's d from .53 to .52, and added the
# standard deviations for both groups.
An independent-samples t-test was conducted to determine whether weight differed between participants who completed cardio exercise and those who did not. Participants in the cardio group (M = 74.73, SD = 7.57) had a higher mean weight than participants in the no-cardio group (M = 70.82, SD = 7.35). However, the difference was not statistically significant, t(48) = 1.86, p > .05. The effect size was medium, Cohen’s d = 0.52.