Question 3: Is there a difference in mean body weight (kg) between participants who do cardio versus participants who do not do cardio?

#Import dataset
Q3 <- read_excel("C:/Users/Julia/OneDrive/Desktop/Assignment 6/Question 3/A6Q3-2.xlsx")

#Descriptive Statistics
Q3 %>%
  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 cardio    74.7   73.3  7.57    25
## 2 nocardio  70.8   69.5  7.35    25
#Create histograms

#No Cardio Histogram
hist(Q3$Weight[Q3$Exercise == "nocardio"],
     main = "Histogram of No Cardio Weight",
     xlab = "Weight (kg)",
     ylab = "Frequency",
     col = "lightblue",
     border = "black",
     breaks = 10)

# Interpretation
#Group 1: No Cardio
# The data is normally distributed. 
# The data is symmetrical. 
# The data has a proper bell curve.

# Interpretation
#Group 2: Cardio Histogram
hist(Q3$Weight[Q3$Exercise == "cardio"],
     main = "Histogram of Cardio Weight",
     xlab = "Weight (kg)",
     ylab = "Frequency",
     col = "lightgreen",
     border = "black",
     breaks = 10)

#Interpretation
#Group 2: Cardio
#The data is normally distributed. 
#The data is symmetrical. 
#The data has a proper bell curve.


#Create Boxplot for Outliers
ggboxplot(Q3, x = "Exercise", y = "Weight",
          color = "Exercise",
          palette = "jco",
          add = "jitter")

#Interpretation
#The nocardio boxplot has dots outside the boxplot. 
#The dots are close to the whiskers.
#The boxplot is normal.
#The cardio boxplot has dots outside the boxplot. 
#The dots are close to the whiskers. 
#The boxplot is normal.
#Shapiro-Wilk Tests
shapiro.test(Q3$Weight[Q3$Exercise == "nocardio"])
## 
##  Shapiro-Wilk normality test
## 
## data:  Q3$Weight[Q3$Exercise == "nocardio"]
## W = 0.97686, p-value = 0.8166
shapiro.test(Q3$Weight[Q3$Exercise == "cardio"])
## 
##  Shapiro-Wilk normality test
## 
## data:  Q3$Weight[Q3$Exercise == "cardio"]
## W = 0.96745, p-value = 0.5812

Shapiro-Wilk Interpretation: Group 1: No Cardio The first group is normally distributed, (p = .817).

Group 2: Cardio The second group is normally distributed, (p = .581).

#Independent T-Test
  t.test(Weight ~ Exercise, data = Q3, var.equal = TRUE)
## 
##  Two Sample t-test
## 
## data:  Weight by Exercise
## t = 1.8552, df = 48, p-value = 0.06971
## alternative hypothesis: true difference in means between group cardio and group nocardio is not equal to 0
## 95 percent confidence interval:
##  -0.3280454  8.1605622
## sample estimates:
##   mean in group cardio mean in group nocardio 
##               74.73336               70.81710

Independent T-Test Interpretation: An Independent T-Test was conducted to determine if there was a difference in weight (kg) between participants that did cardio versus those that did not do cardio. The weight of the group that did cardio (M = 74.70, SD = 7.57) was not significantly different from the group that did not do cardio (M = 70.80, SD = 7.35), t(48) = 1.86, p > .05.