## R Markdown
BEFORE <- A6Q2$Before
AFTER <- A6Q2$After
DIFFERENCES <- AFTER - BEFORE
mean(BEFORE, na.rm = TRUE)
median(BEFORE, na.rm = TRUE)
sd(BEFORE, na.rm = TRUE)
mean(AFTER, na.rm = TRUE)
median(AFTER, na.rm = TRUE)
sd(AFTER, na.rm = TRUE)
hist(DIFFERENCES,
main = "Histogram of Difference Scores",
xlab = "Value" ,
ylab = "Frequency" ,
col = "light green" ,
border = "dark blue" ,
breaks = 20
)
#Histogram of Different Scores
#The scores look abnormally distributed.
#The data is negatively skewed.
# The data does not have proper bell curve.
boxplot(DIFFERENCES, main = "Distribution of Score Differences (after - before)", ylab = "Difference in Scores", col = "light green", border = "dark green")
#Boxplot
# There are dots outside the boxplot.
#The dot is not close to the whiskers.
#The dot is very far away from the whiskers.
#Based on these findings, the boxplot is not normal.
shapiro.test(DIFFERENCES)
#Shapiro-Wilk
#Difference Scores
#The data is normally distributed, (p= .332).
wilcox.test(BEFORE, AFTER, paired = TRUE, na.action = na.omit)
#A dependent T test was conducted to determine if there was a difference in body weight before a low calorie diet versus after the low calorie diet.
#Before scores ( M=76.13 , SD =7.78 ,) were significantly different from after scores (m= 57.17 , SD = 14.39), p = .02
cohens_d(BEFORE, AFTER, paired = TRUE)
df_long <- data.frame(
id = rep(1:length(BEFORE), 2),
time = rep(c("before", "after"), each = length(BEFORE)),
score = c(BEFORE, AFTER)
)
wilcox_effsize(df_long, score ~ time, paired = TRUE)
#A Dependent T-Test was conducted to determine if there was a difference in body weight before keto diet versus after keto diet.
#Before scores (M = 76.13, SD = 7.78) were significantly different from after scores (M = 57.17, SD = 14.39), t(19) = 14.25, p = .331.
#The effect size was small, Cohen's d = .75.
#A Wilcoxon Signed-Rank Test was conducted to determine if there was a difference in body weight before keto diet versus after keto diet.
#Before scores (Mdn = 75.95) were significantly different from after scores (Mdn = 58.36), V = 210, p = [< .001 / = .332 / > .05].
#The effect size was small.