Step 1: Install the Required Packages
install.packages(“readxl”) install.packages(“ggpubr”) install.packages(“dplyr”) install.packages(“effectsize”) install.packages(“effsize”)
Step 2: Open the Installed Packages
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)
Step 3: Import and Name Dataset
Dataset6.2 <- read_excel("C:/Users/pavan/Desktop/Assignments/Assignment 6/Dataset6.2.xlsx")
Dataset 6.2 was imported successfully.
Step 4: Calculate Descriptive Statistics for Each Group
Dataset6.2 %>%
group_by(Work_Status) %>%
summarise(
Mean = mean(Study_Hours, na.rm = TRUE),
Median = median(Study_Hours, na.rm = TRUE),
SD = sd(Study_Hours, na.rm = TRUE),
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
Step 5: Create Histograms for Each Group
hist(Dataset6.2$Study_Hours[Dataset6.2$Work_Status == "Works"],
main = "Histogram of undergraduates who works",
xlab = "Value",
ylab = "Frequency",
col = "lightblue",
border = "black",
breaks = 10)
hist(Dataset6.2$Study_Hours[Dataset6.2$Work_Status == "Does_Not_Work"],
main = "Histogram of undergraduates who Does not work",
xlab = "Value",
ylab = "Frequency",
col = "lightgreen",
border = "black",
breaks = 10)
Step 6: Create Boxplots for Each Group
ggboxplot(Dataset6.2, x = "Work_Status", y = "Study_Hours",
color = "Work_Status",
palette = "jco",
add = "jitter")
Step 7: Shapiro-Wilk Test of Normality
shapiro.test(Dataset6.2$Study_Hours[Dataset6.2$Work_Status == "Works"])
##
## Shapiro-Wilk normality test
##
## data: Dataset6.2$Study_Hours[Dataset6.2$Work_Status == "Works"]
## W = 0.94582, p-value = 0.1305
shapiro.test(Dataset6.2$Study_Hours[Dataset6.2$Work_Status == "Does_Not_Work"])
##
## Shapiro-Wilk normality test
##
## data: Dataset6.2$Study_Hours[Dataset6.2$Work_Status == "Does_Not_Work"]
## W = 0.83909, p-value = 0.0003695
The p-value for the Does_Not_Work group is less than 0.05, indicating that the data is not normally distributed. The p-value for the Works group is greater than 0.05, indicating that the data is normally distributed. Since one or both groups are not normal, we should switch to the Mann-Whitney U test.
Step 8: Conduct Inferential Test Mann-Whitney U test
wilcox.test(Study_Hours ~ Work_Status, data = Dataset6.2)
##
## 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
the p value is 0.079 which is greater than 0.05, this means the results were NOT significant.
Step 9: Calculate the Effect Size
cliff.delta(Study_Hours ~ Work_Status, data = Dataset6.2)
##
## Cliff's Delta
##
## delta estimate: 0.2644444 (small)
## 95 percent confidence interval:
## lower upper
## -0.03422594 0.51975307
Step 10: Report the Results
The group who works (Mdn = 5.64) were not significantly different from group who does not work (Mdn = 8.54) in Study Hours, p = .079. The effect size was small (r₍rb₎ = 0.264).