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
CardioWeight <- read_excel("C:/Users/tawan/OneDrive - Saint Louis University/AA 5221/Assignment 6/A6Q3.xlsx")
View(CardioWeight)
CardioWeight %>%
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(CardioWeight$Weight[CardioWeight$Exercise == "nocardio"],
breaks = 15,
main = "Histogram of Weight Non Cardio Paticipants",
xlab = "No Cardio",
col = "skyblue",
border = "white")

hist(CardioWeight$Weight[CardioWeight$Exercise == "cardio"],
breaks = 15,
main = "Histogram of Weight Cardio Exercising Participants",
xlab = "Cardio",
col = "firebrick",
border = "white")

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

# The noocardio boxplot does have outliers.
# The cardio boxplot does have outliers.
shapiro.test(CardioWeight$Weight[CardioWeight$Exercise == "nocardio"])
##
## Shapiro-Wilk normality test
##
## data: CardioWeight$Weight[CardioWeight$Exercise == "nocardio"]
## W = 0.97686, p-value = 0.8166
shapiro.test(CardioWeight$Weight[CardioWeight$Exercise == "cardio"])
##
## Shapiro-Wilk normality test
##
## data: CardioWeight$Weight[CardioWeight$Exercise == "cardio"]
## W = 0.96745, p-value = 0.5812
#The nocardio is normally distributed, (p > .05).
#The cardio is normally distributed, (p > .05).
t.test(Weight ~ Exercise, data = CardioWeight, 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
cohens_d_result <- cohens_d(Weight ~ Exercise, data = CardioWeight, pooled_sd = TRUE)
print(cohens_d_result)
## Cohen's d | 95% CI
## -------------------------
## 0.52 | [-0.04, 1.09]
##
## - Estimated using pooled SD.
#An Independent T-Test was conducted to determine if there was a difference in Weight between nocardio and cardio.
#nocardio scores (M = 70.8, SD = 7.35) were significantly different from cardio (M = 74.7, SD = 7.57), t(48) = 1.86, p > .05.
#The effect size was medium, Cohen's d = .52.