##Opening libraries

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)

##Import data

A6Q4_2 <- read_excel("A6Q4-2.xlsx")

##Descriptive statistics

A6Q4_2 %>%
  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

##Histograms for Groups (lift and nolift)

hist(A6Q4_2$Weight[A6Q4_2$Exercise == "lift"],
     main = "Histogram of Lift",
     xlab = "Value",
     ylab = "Frequency",
     col = "brown",
     border = "black",
     breaks = 10)

hist(A6Q4_2$Weight[A6Q4_2$Exercise == "nolift"],
     main = "Histogram of No Lift",
     xlab = "Value",
     ylab = "Frequency",
     col = "darkgray",
     border = "black",
     breaks = 10)

##Report on Histograms #Group 1: lift The first variable looks abnormally distributed. Data is not positively skewed. Data does not have proper bell curve.

#Group 2: nolift The first variable looks abnormally distributed. Data is not negatively skewed. Data does not have proper bell curve.

##Boxplots

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

##Report Boxplots #Group 1:no lift There are dots outside the boxplot. The dots are not close to the whiskers. The outliers are not balanced.Based on the findings data is abnormal.

#Group 2:lift There are dots outside the boxplot. The dots are not close to the whiskers. The outliers are not balanced.Based on the findings data is abnormal.

##Shapiro-Wilk Test of Groups “lift” and “no lift”

shapiro.test(A6Q4_2$Weight[A6Q4_2$Exercise == "lift"])
## 
##  Shapiro-Wilk normality test
## 
## data:  A6Q4_2$Weight[A6Q4_2$Exercise == "lift"]
## W = 0.78786, p-value = 0.0001436
shapiro.test(A6Q4_2$Weight[A6Q4_2$Exercise == "nolift"])
## 
##  Shapiro-Wilk normality test
## 
## data:  A6Q4_2$Weight[A6Q4_2$Exercise == "nolift"]
## W = 0.70002, p-value = 7.294e-06

Report on Shapiro-Wilk Test

#Group1:lift The first group is abnormally distributed, (p= <001)

#Group2:nolift The second group is abnormally distributed, (p= <001)

##Mann-Whitney U Test

wilcox.test(Weight ~ Exercise, data = A6Q4_2)
## 
##  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

##Effect Size for Mann-Whitney U Calculation

mw_effect <- cliff.delta(Weight ~ Exercise, data = A6Q4_2)
print(mw_effect)
## 
## Cliff's Delta
## 
## delta estimate: 0.9296 (large)
## 95 percent confidence interval:
##     lower     upper 
## 0.7993841 0.9764036

##Mann Whitney U test report A Mann-Whitney U test was conducted to determine if there was a difference in Weight between lift and nolift groups. lift scores (Mdn = 116) were significantly different from nolift scores (Mdn = 40.8), U = 0.80, p = .002. The effect size was large, Cliff’s Delta = .93.