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(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ forcats 1.0.1 ✔ stringr 1.6.0
## ✔ lubridate 1.9.5 ✔ tibble 3.3.1
## ✔ purrr 1.2.1 ✔ tidyr 1.3.2
## ✔ readr 2.2.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
D3 <- read_excel("A6Q3.xlsx")
#Descriptive Statistics
D3 <- pivot_longer(D3,cols = c(nocardio, cardio), names_to = "label", values_to = "weight")
D3 %>%
group_by(label) %>%
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
## label Mean Median SD N
## <chr> <dbl> <dbl> <dbl> <int>
## 1 cardio 70.8 69.5 7.35 25
## 2 nocardio 74.7 73.3 7.57 25
hist(D3$weight[D3$label == "nocardio"],
main = "Histogram of No Cardio Weights",
xlab = "Value",
ylab = "Frequency",
col = "lightblue",
border = "pink",
breaks = 10)
hist(D3$weight[D3$label == "cardio"],
main = "Histogram of cardio weights",
xlab = "Value",
ylab = "Frequency",
col = "lightgreen",
border = "pink",
breaks = 10)
The first variable looks normally distributed. The data is positively sqewed. The data has a proper bell curve.
The second variable looks normally distributed. The data is negatively skewed. The data has a proper bell curve.
ggboxplot(D3, x = "label", y = "weight",
color = "label",
palette = "jco",
add = "jitter")
There are dots outside the boxplot. The dots are not close to the whiskers. The dots are not far away from the whiskers. Based on these findings, the boxplot is normal.
There are dots outside the boxplot. The dots are not close to the whiskers. The dots are not far away from the whiskers. Based on these findings, the boxplot is normal.
shapiro.test(D3$weight[D3$label == "nocardio"])
##
## Shapiro-Wilk normality test
##
## data: D3$weight[D3$label == "nocardio"]
## W = 0.96745, p-value = 0.5812
shapiro.test(D3$weight[D3$label == "cardio"])
##
## Shapiro-Wilk normality test
##
## data: D3$weight[D3$label == "cardio"]
## W = 0.97686, p-value = 0.8166
The first group is normally distributed, (p > 0.05).
##Group 2: cardio The second group is normally distributed, (p > 0.05).
t.test(weight ~ label, data = D3, var.equal = TRUE)
##
## Two Sample t-test
##
## data: weight by label
## 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:
## -8.1605622 0.3280454
## sample estimates:
## mean in group cardio mean in group nocardio
## 70.81710 74.73336
#An Independent T-Test was conducted to determine if there was a difference in weight in kg between nocardio and cardio groups. #nocardio scores (M = 74.7, SD = 7.57) were [not significantly] different from Group2 scores (M = 70.8, SD = 7.35), t(48) = -1.855, p > 0.05 .