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
LiftWeight <- read_excel("C:/Users/tawan/OneDrive - Saint Louis University/AA 5221/Assignment 6/A6Q4.xlsx")
View(LiftWeight)

LiftWeight %>%
  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 lift     120.   116.   53.3    25
## 2 nolift    33.0   40.8  56.7    25
hist(LiftWeight$Weight[LiftWeight$Exercise == "lift"],
     breaks = 15,
     main = "Histogram of Weight who lift Paticipants",
     xlab = "Lifters",
     col = "skyblue",
     border = "white")

hist(LiftWeight$Weight[LiftWeight$Exercise == "nolift"],
     breaks = 15,
     main = "Histogram of Weight Non Lifting Participants",
     xlab = "Non Lifters",
     col = "firebrick",
     border = "white")

#Data for nocardio appears abnormally distributed.
#Data for cardio appears abnormally distributed.

ggboxplot(LiftWeight, x = "Exercise", y = "Weight",
          color = "Exercise",
          palette = "jco",
          add = "jitter")

# The nolift boxplot have  outliers.
# The lift boxplot have  outliers

shapiro.test(LiftWeight$Weight[LiftWeight$Exercise == "lift"])
## 
##  Shapiro-Wilk normality test
## 
## data:  LiftWeight$Weight[LiftWeight$Exercise == "lift"]
## W = 0.78786, p-value = 0.0001436
shapiro.test(LiftWeight$Weight[LiftWeight$Exercise == "nolift"])
## 
##  Shapiro-Wilk normality test
## 
## data:  LiftWeight$Weight[LiftWeight$Exercise == "nolift"]
## W = 0.70002, p-value = 7.294e-06
#The nolift is abnormally  distributed, (p < .001).
#The lift is abnormally  distributed, (p < .001).

wilcox.test(Weight ~ Exercise, data = LiftWeight)
## 
##  Wilcoxon rank sum exact test
## 
## data:  Weight by Exercise
## W = 603, p-value = 7.132e-11
## alternative hypothesis: true location shift is not equal to 0
mw_effect <- cliff.delta(Weight ~ Exercise, data = LiftWeight)
print(mw_effect)
## 
## Cliff's Delta
## 
## delta estimate: 0.9296 (large)
## 95 percent confidence interval:
##     lower     upper 
## 0.7993841 0.9764036
#A Mann-Whitney U test was conducted to determine if there was a difference in Weight between Lifters and Non Lifters.
#Lifters (Mdn = 116.00) were significantly different from Non Lifters (Mdn = 40.8), W = 603, p < 0.001.
#The effect size was large, Cliff's Delta = .93.