CORRECTION - Insert question:

Research Question Is there a mean difference in body weight (kg) before versus after all participants tried the low calorie diet?

CORRECTION - Insert step:

Open packages.

library(readxl)
library(ggpubr)
library(ggplot2)
library(rstatix)
library(effsize)

CORRECTION - Insert step:

Import dataset.

library(readxl)
A6Q1 <- read_excel("C:/Users/rmich/Desktop/A6Q1.xlsx")

CORRECTION - Insert step:

Create before and after scores.

Before <- A6Q1$Before
After <- A6Q1$After
Differences <- A6Q1$After - A6Q1$Before

CORRECTION - Insert step:

Descriptive statistic:

mean(Before, na.rm = TRUE)
## [1] 76.13299
median(Before, na.rm = TRUE)
## [1] 75.95988
sd(Before, na.rm = TRUE)
## [1] 7.781323
mean(After, na.rm = TRUE)
## [1] 71.58994
median(After, na.rm = TRUE)
## [1] 70.88045
sd(After, na.rm = TRUE)
## [1] 6.639509

CORRECTION - Insert step:

Check normality via histogram

hist(Differences,
     main = "Histogram of Weight Difference - Before and After Low Calorie Diet",
     xlab = "Weight Difference",
     ylab = "Count",
     col = "blue",
     border = "black",
     breaks = 20)

#Histogram of Difference Weight Differences #The difference scores looks abnormally distributed. #The data is negatively skewed. #The data does not have a proper bell curve.

boxplot(Differences,
        main = "Distribution of Weight Difference - Before and After Low Calorie Diet",
        ylab = "Weight Difference",
        col = "blue",
        border = "darkblue")

#There are dots outside the boxplot. CORRECTION: Clarify to correct there is one. #The dot is not close to the whiskers. CORRECTION: It is indeed closer to a whisker. Student needs to review what whisker area is. #Based on these findings, the boxplot is abnormal.CORRECTION: There is one outlier, the boxplot is relatively normal.

shapiro.test(Differences)
## 
##  Shapiro-Wilk normality test
## 
## data:  Differences
## W = 0.94757, p-value = 0.3318

Interpret Shapiro Wiki: #The data is normally distributed, (p = .332).

Dependent T Test:

t.test(Before, After, paired = TRUE, na.action = na.omit)
## 
##  Paired t-test
## 
## data:  Before and After
## t = 1.902, df = 19, p-value = 0.07245
## alternative hypothesis: true mean difference is not equal to 0
## 95 percent confidence interval:
##  -0.4563808  9.5424763
## sample estimates:
## mean difference 
##        4.543048
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 tibble: 1 × 7
##   .y.   group1 group2 effsize    n1    n2 magnitude
## * <chr> <chr>  <chr>    <dbl> <int> <int> <ord>    
## 1 score After  Before   0.359    20    20 moderate

CORRECTION NEEDED: Rounded mean to 76.12 to 76.13 and modify from p = .072. to p > .05. #A Dependent T-Test was conducted to determine if there was a difference in Weight before and after a low calorie diet #Weight before (M = 76.13, SD = 7.78) were not significantly different from weight after (M = 71.59, SD = 6.64), t(19) = 1.90, p > .05

CORRECTION NEEDED - Remove Cohen’s D test and data. CORRECTION - Remove wilcox rank test info and data.