2024-09-16

Analysis of Sleep Quality Data

This data set represents attributes that affect the an individual’s sleep quality. We will look at different variables that have been measured in subjects to determine which of these factors have the largest affect on how well people sleep and some that may present signs of poor rest.

Data Source:

https://www.kaggle.com/datasets/hanaksoy/health-and-sleep-statistics

Sleep Quality Based off Daily Steps

Scatter Plot: \(\text{Sleep Quality} = \beta_0 + \beta_1 \cdot \text{Daily Steps} + \varepsilon; \hspace{1.5cm} \varepsilon \sim \mathcal{N}(0; \sigma^2)\)
           Fitted: \(\text{Sleep Quality} = \hat{\beta_0} + \hat{\beta_1} \cdot \text{Daily Steps} \hspace{2.3cm} \hat{\beta_0} = b_0 - \text{estimate of } \beta_0;\)   \(\hat{\beta_1} = b_1 - \text{estimate of } \beta_1\)

Sleep Quality Based off Daily Steps

lm(Sleep.Quality ~ Daily.Steps, sleep)
## 
## Call:
## lm(formula = Sleep.Quality ~ Daily.Steps, data = sleep)
## 
## Coefficients:
## (Intercept)  Daily.Steps  
##   2.3701283    0.0006779



Regression Coefficient of sleep quality based off daily steps is .00068.

Sleep Quality Based off Calories Burned

Scatter Plot: \(\text{Sleep Quality} = \beta_0 + \beta_1 \cdot \text{Clories Burned} + \varepsilon; \hspace{1.5cm} \varepsilon \sim \mathcal{N}(0; \sigma^2)\)
           Fitted: \(\text{Sleep Quality} = \hat{\beta_0} + \hat{\beta_1} \cdot \text{Calories Burned} \hspace{2.1cm} \hat{\beta_0} = b_0 - \text{estimate of } \beta_0;\)   \(\hat{\beta_1} = b_1 - \text{estimate of } \beta_1\)

Sleep Quality Based off Calories Burned

lm(Sleep.Quality ~ Calories.Burned, sleep)
## 
## Call:
## lm(formula = Sleep.Quality ~ Calories.Burned, data = sleep)
## 
## Coefficients:
##     (Intercept)  Calories.Burned  
##        -7.54909          0.00601



Regression Coefficient of sleep quality based off daily steps is .0061.

Sleep Quality Based off Age

knitr::opts_chunk$set(echo = TRUE)
plot_ly(sleep, x=x2, y=y2, type="scatter", mode="markers", name="Data") %>%
add_lines(x=x2, y = fitted(mod), name="Fitted Line") %>%
layout(xaxis = xax2, yaxis = yax2, title="Sleep Quality by Age")

Sleep Quality Based off Age

lm(Sleep.Quality ~ Age, sleep)
## 
## Call:
## lm(formula = Sleep.Quality ~ Age, data = sleep)
## 
## Coefficients:
## (Intercept)          Age  
##     13.2688      -0.1741



Regression Coefficient of sleep quality based off age is -0.1741.

Average Sleep Quality by Medication

plot_ly(sleep, x=x, y=y, type="bar") %>%
layout(xaxis= xax, yaxis=yax, title="Average Sleep Quality by Medication Use")

Comment

Those that do not take Medication for sleep had a average quality of sleep far superior to that of individuals that do. People that are able to avoid medication for sleep have an average sleep quality of 7.5 whereas those that take medication regularly average only a 5.0 sleep quality rating.

Analysis

Description of Findings:

As seen in the plots of the previous pages consistent exercise, such as walking, is directly correlated to better sleep quality. It also is a great way to burn more calories, which also directly impacts how well one sleeps.

Also, as displayed on the final plot, taking sleep medication doesn’t completely solved any issues with obtaining beneficial rest. Individuals that have trouble getting a good night’s rest, even with help of medication, still need to be active in their daily lives in order to sleep well at night.