Loading 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)
Calculate descriptive statistics for each group
DatasetRQ2 %>%
group_by(Work_Status) %>%
summarise(
Mean = mean(Study_Hours),
Median = median(Study_Hours),
SD = sd(Study_Hours),
N = n()
)
## # A tibble: 2 × 5
## Work_Status Mean Median SD N
## <chr> <dbl> <dbl> <dbl> <int>
## 1 Does_Not_Work 9.62 8.54 7.45 30
## 2 Works 6.41 5.64 4.41 30
Check normality
Method 1: Histograms
hist(DatasetRQ2$Study_Hours[DatasetRQ2$Work_Status == "Does_Not_Work"],
main = "Histogram of Study Hours - Non-Working Students",
xlab = "Study Hours per Week",
ylab = "Frequency",
col = "lightgreen",
border = "darkgreen",
breaks = 10)

cat("Skewness: Positively Skewed ,", "Kurtosis: It is difficult to state the exact kurtosis, but it appears abnormal")
## Skewness: Positively Skewed , Kurtosis: It is difficult to state the exact kurtosis, but it appears abnormal
hist(DatasetRQ2$Study_Hours[DatasetRQ2$Work_Status == "Works"],
main = "Histogram of Study Hours - Working Students",
xlab = "Study Hours per Week",
ylab = "Frequency",
col = "lightblue",
border = "blue",
breaks = 10)

cat("Skewness: Positively Skewed ,", "Kurtosis: It is difficult to state the exact kurtosis, but it appears abnormal")
## Skewness: Positively Skewed , Kurtosis: It is difficult to state the exact kurtosis, but it appears abnormal
print("For Working group: the data appears Positively Skewed, and the kurtosis appears abnormal")
## [1] "For Working group: the data appears Positively Skewed, and the kurtosis appears abnormal"
print("For Non-Working group: the data appears Positively Skewed, and the kurtosis appears abnormal")
## [1] "For Non-Working group: the data appears Positively Skewed, and the kurtosis appears abnormal"
print("Based on Reports we can use the Mann-Whitney U test")
## [1] "Based on Reports we can use the Mann-Whitney U test"
Method 2: Boxplots
ggboxplot(DatasetRQ2, x = "Work_Status", y = "Study_Hours",
color = "Work_Status",
palette = c("blue", "green"),
add = "jitter",
title = "Study Hours by Work Status",
xlab = "Work Status",
ylab = "Study Hours per Week")

print("For Working group: the data appears somewhat normal with only one outlier")
## [1] "For Working group: the data appears somewhat normal with only one outlier"
print("For Non-Working group: the data appears abnormal with multiple outliers and unevely distributed")
## [1] "For Non-Working group: the data appears abnormal with multiple outliers and unevely distributed"
print("Based on Reports we can use the Mann-Whitney U test.")
## [1] "Based on Reports we can use the Mann-Whitney U test."
Method 3: Shapiro-Wilk
shapiro.test(DatasetRQ2$Study_Hours[DatasetRQ2$Work_Status == "Works"])
##
## Shapiro-Wilk normality test
##
## data: DatasetRQ2$Study_Hours[DatasetRQ2$Work_Status == "Works"]
## W = 0.94582, p-value = 0.1305
shapiro.test(DatasetRQ2$Study_Hours[DatasetRQ2$Work_Status == "Does_Not_Work"])
##
## Shapiro-Wilk normality test
##
## data: DatasetRQ2$Study_Hours[DatasetRQ2$Work_Status == "Does_Not_Work"]
## W = 0.83909, p-value = 0.0003695
print("For Working group: the value of p > 0.05, so the data is normal")
## [1] "For Working group: the value of p > 0.05, so the data is normal"
print("For Non-Working group: the value of p < 0.05 (0.0003695), so the data is not normal")
## [1] "For Non-Working group: the value of p < 0.05 (0.0003695), so the data is not normal"
print("Based on Reports we can use the Mann-Whitney U test")
## [1] "Based on Reports we can use the Mann-Whitney U test"
Interpretation: After conducting all three normality tests, it is
clear we must use a Mann-Whitney U test.
Conduct Inferential Test (Mann-Whitney U Test)
wilcox.test(Study_Hours ~ Work_Status, data = DatasetRQ2)
##
## Wilcoxon rank sum exact test
##
## data: Study_Hours by Work_Status
## W = 569, p-value = 0.07973
## alternative hypothesis: true location shift is not equal to 0
print("As the value of p > 0.05 (p = 0.07973), this means the results were NOT significant. So we'll skip effect size.")
## [1] "As the value of p > 0.05 (p = 0.07973), this means the results were NOT significant. So we'll skip effect size."
Report the Results
cat("Working Students Group ((Mdn = 5.64) was not significantly different from Non-Working Students Group (Mdn = 8.54), U = 569, p = .07973. The data was not Statically Significant")
## Working Students Group ((Mdn = 5.64) was not significantly different from Non-Working Students Group (Mdn = 8.54), U = 569, p = .07973. The data was not Statically Significant