#**1.The Power of Sleep: A Statistical Study on How Sleep Affects the Health and Productivity of Working Adults
#2.Problem Statement: There is a great amount of working adults who do not get enough sleep and suffer from health problems.
library(ggplot2)
library(readxl)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## âś” dplyr 1.1.4 âś” readr 2.1.5
## âś” forcats 1.0.0 âś” stringr 1.5.1
## âś” lubridate 1.9.3 âś” tibble 3.2.1
## âś” purrr 1.0.2 âś” tidyr 1.3.1
## ── 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
#3.Objective
sleep_data <- read_excel("/Users/leo/Desktop/Group 7/Sleep_Deprivation_Data.xlsx")
summary(sleep_data)
## Person ID Gender Age Occupation
## Min. : 1.00 Length:374 Min. :27.00 Length:374
## 1st Qu.: 94.25 Class :character 1st Qu.:35.25 Class :character
## Median :187.50 Mode :character Median :43.00 Mode :character
## Mean :187.50 Mean :42.18
## 3rd Qu.:280.75 3rd Qu.:50.00
## Max. :374.00 Max. :59.00
## Sleep Duration Quality of Sleep Physical Activity Level Stress Level
## Min. :5.800 Min. :4.000 Min. :30.00 Min. :3.000
## 1st Qu.:6.400 1st Qu.:6.000 1st Qu.:45.00 1st Qu.:4.000
## Median :7.200 Median :7.000 Median :60.00 Median :5.000
## Mean :7.132 Mean :7.313 Mean :59.17 Mean :5.385
## 3rd Qu.:7.800 3rd Qu.:8.000 3rd Qu.:75.00 3rd Qu.:7.000
## Max. :8.500 Max. :9.000 Max. :90.00 Max. :8.000
## BMI Category Blood Pressure Heart Rate Daily Steps
## Length:374 Length:374 Min. :65.00 Min. : 3000
## Class :character Class :character 1st Qu.:68.00 1st Qu.: 5600
## Mode :character Mode :character Median :70.00 Median : 7000
## Mean :70.17 Mean : 6817
## 3rd Qu.:72.00 3rd Qu.: 8000
## Max. :86.00 Max. :10000
## Sleep Disorder
## Length:374
## Class :character
## Mode :character
##
##
##
#Stress Level
n1 <- 374
new_data <- data.frame(sleep_data$`Sleep Duration`, sleep_data$`Stress Level`)
summary(new_data)
## sleep_data..Sleep.Duration. sleep_data..Stress.Level.
## Min. :5.800 Min. :3.000
## 1st Qu.:6.400 1st Qu.:4.000
## Median :7.200 Median :5.000
## Mean :7.132 Mean :5.385
## 3rd Qu.:7.800 3rd Qu.:7.000
## Max. :8.500 Max. :8.000
#4.Hypothesis Testing #Ho: there is no correlation between sleep and health #Ha: there is a correlation between sleep and health #Ho: μ1 - μ2 = 0 Ha: μ1 - μ2 ≠0 #Parameters: Stress Level Mean - 5.385, Stress Level Median - 5, Sleep Duration Mean - 7.132, Sleep Duration Median - 7.2
t_test <- t.test(new_data$sleep_data..Sleep.Duration., new_data$sleep_data..Stress.Level.)
t_test
##
## Welch Two Sample t-test
##
## data: new_data$sleep_data..Sleep.Duration. and new_data$sleep_data..Stress.Level.
## t = 17.373, df = 517.15, p-value < 2.2e-16
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 1.549502 1.944615
## sample estimates:
## mean of x mean of y
## 7.132086 5.385027
p_value <- t_test$p.value
alpha <- .05
if (p_value < alpha) {
# Reject the null hypothesis
print("Reject the null hypothesis: There is a significant difference between the means of Variable1 and Variable2.")
} else {
# Fail to reject the null hypothesis
print("Fail to reject the null hypothesis: There is no significant difference between the means of Variable1 and Variable2.")
}
## [1] "Reject the null hypothesis: There is a significant difference between the means of Variable1 and Variable2."
#5. Interpretation: The less sleep a person gets their stress level is at a high whereas if they get more sleep, their stress level is low.
#Visual Data: Linear Regression
plot(new_data$sleep_data..Sleep.Duration., new_data$sleep_data..Stress.Level., main = "Scatter diagram", xlab = "Sleep Duration",
ylab = "Stress Level", pch=19)
#6. Conclusion & Recommendations #We conclude that there will be a significant impact between sleep duration and stress level. (p-value < 0.05) #Based on the results the High sleep duration causes low stress levels and Low sleep duration causes high stress levels. #Management can use our model to know employees’ health #Management should enforce monthly counseling on their employees sleeping duration for productivity.