library(readxl)
library(ggpubr)
## Loading required package: ggplot2
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(rstatix)
## 
## Attaching package: 'rstatix'
## The following objects are masked from 'package:effectsize':
## 
##     cohens_d, eta_squared, omega_squared
## The following object is masked from 'package:stats':
## 
##     filter
A6Q4 <- read_excel("//apporto.com/dfs/SLU/Users/brentgallagher_slu/Desktop/A6Q4.xlsx")
A6Q4 %>%
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
# A tribble 2x5
# Lift: Mean 120, Median 116, SD 53.3, N 25
# No Lift: Mean 33, Median 41, SD 57, N 25

hist(A6Q4$Weight[A6Q4$Exercise == "lift"],
     breaks = 15,
     col = "skyblue",
     border = "white")

hist(A6Q4$Weight[A6Q4$Exercise == "nolift"],
     breaks = 15,
     col = "firebrick",
     border = "white")

# Data for group one appears abnormally distributed.
# Data for group two appears abormally distributed.

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

# The group one boxplot does have outliers.
# The group two boxplot does have outliers.

shapiro.test(A6Q4$Weight[A6Q4$Exercise == "lift"])
## 
##  Shapiro-Wilk normality test
## 
## data:  A6Q4$Weight[A6Q4$Exercise == "lift"]
## W = 0.78786, p-value = 0.0001436
shapiro.test(A6Q4$Weight[A6Q4$Exercise == "nolift"])
## 
##  Shapiro-Wilk normality test
## 
## data:  A6Q4$Weight[A6Q4$Exercise == "nolift"]
## W = 0.70002, p-value = 7.294e-06
# Lift W = 0.79, p-value = 0.00014036
# No Lift W = 0.70, p-value = 7.29e-06
# The first group is abnormally distributed, p < .05.
# The second group is abnormally distributed, p < .05.

wilcox.test(Weight ~ Exercise,
data = A6Q4)
## 
##  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
# Wilcoxon Rank Sum Exact Test
# W = 603, p-value = 7.123e-11
# Alternative hypothesis: true location shift is not equal to 0.

mw_effect <- cliff.delta(Weight
~ Exercise, data = A6Q4)                     
print(mw_effect)
## 
## Cliff's Delta
## 
## delta estimate: 0.9296 (large)
## 95 percent confidence interval:
##     lower     upper 
## 0.7993841 0.9764036
# Cliff's Delta: delta estimate: 0.93 (large), 95% confidence interval: lower: 0.80, upper: 0.98
# A Mann-Whitney U Test was conducted to determine if there was a difference in Outcome Variable between group one and group two.
# Group one scores median was 116 were significantly different from group two median 41.
# W = 603, p-value = 7.123e-11.
# The effect size was large, Cliff's Delta was .93.