library(readxl)
library(ggpubr)
## Warning: package 'ggpubr' was built under R version 4.6.1
## Loading required package: ggplot2
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.6.1
##
## 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)
## Warning: package 'effectsize' was built under R version 4.6.1
library(effsize)
## Warning: package 'effsize' was built under R version 4.6.1
library(rstatix)
## Warning: package 'rstatix' was built under R version 4.6.1
##
## Attaching package: 'rstatix'
## The following objects are masked from 'package:effectsize':
##
## cohens_d, eta_squared
## The following object is masked from 'package:stats':
##
## filter
library(dplyr)
A6Q3 <- read_excel("C:/Users/Tharu/Downloads/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 == "nocardio"],
main = "Histogram of Weight - No Cardio",
xlab = "Value",
ylab = "Frequency",
col = "lightblue",
border = "black",
breaks = 10)
hist(A6Q3$Weight[A6Q3$Exercise == "cardio"],
main = "Histogram of Weight - Cardio",
xlab = "Value",
ylab = "Frequency",
col = "lightgreen",
border = "black",
breaks = 10)
#Group 1: No Cardio #The first variable looks approximately normally
distributed. #The data appears reasonably symmetrical. #The data shows a
bell-shaped pattern. #Group 2: Cardio #The second variable looks
approximately normally distributed. #The data appears reasonably
symmetrical. #The data shows a bell-shaped pattern.
ggboxplot(A6Q3, x = "Exercise", y = "Weight",
color = "Exercise",
palette = "jco",
add = "jitter")
#Boxplot 1: nocardio #There is one or two points slightly outside the
boxplot. #The points are close to the whiskers. #The data looks fairly
symmetrical. #Based on these findings, the boxplot is approximately
normal.
#Boxplot 2: cardio #There are a few points near the whiskers. #The points are not far away from the whiskers. #The distribution looks fairly balanced. #There is no strong skewness in the data. #Based on these findings, the boxplot is approximately normal.
shapiro.test(A6Q3$Weight[A6Q3$Exercise == "nocardio"])
##
## Shapiro-Wilk normality test
##
## data: A6Q3$Weight[A6Q3$Exercise == "nocardio"]
## W = 0.97686, p-value = 0.8166
shapiro.test(A6Q3$Weight[A6Q3$Exercise == "cardio"])
##
## Shapiro-Wilk normality test
##
## data: A6Q3$Weight[A6Q3$Exercise == "cardio"]
## W = 0.96745, p-value = 0.5812
#Group 1: nocardio #The first group is abnormally distributed, (p = 0.8166).
#Group 2: cardio #The second group is normally distributed, (p = 0.5812).
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
cohens_d_result <- cohens_d(Weight ~ Exercise, data = A6Q3)
cohens_d_result
## # A tibble: 1 × 7
## .y. group1 group2 effsize n1 n2 magnitude
## * <chr> <chr> <chr> <dbl> <int> <int> <ord>
## 1 Weight cardio nocardio 0.525 25 25 moderate
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
#An Independent Samples t-test was conducted to determine if there was a difference in Weight between nocardio and cardio groups. #Nocardio (M = 70.8, SD = 7.35) and cardio (M = 74.7, SD = 7.57) were not significantly different, t(48) = 1.86, p = .070. #The effect size was moderate, Cohen’s d = 0.525.
#A Mann-Whitney U test was conducted to determine if there was a difference in Weight between nocardio and cardio groups. Nocardio scores (Mdn = 69.5) were not significantly different from #cardio scores (Mdn = 73.3), U = 74.00, p = .095. #The effect size was small, Cliff’s Delta = .277.