Introduction

Sleep is very important for humans health and daily functioning.

Nowadays phones are being used before bedtime and I think it is important to check the correlation between phones and bedtime.

I decided to work on this dataset containing 8500 records and 18 variables about bed time, phone usage, habits and the next day fatigue.

Research Question:

Is there an impact on sleep duration if using phone before bed time?

Understanding Data

Total observations = 8500

Total variables = 18

Some of the variables:

bedtime_phone_minutes: Total minutes of phone use before bed

total_sleep_hours : Total hours of sleep

sleep_latency_min : Minutes taken to fall asleep

caffeine_post_5pm_mg : Evening coffee consumption

next_day_fatigue_score: Next day fatigue score

Main variables focusing on will be bedtime phone use minutes and total sleep hours.

Mean

\[ \bar{x} = \frac{1}{n}\sum_{i=1}^{n}x_i \]

             Measure   Value
1     Num of records 8500.00
2         Num of var   18.00
3    Avg phone usage   59.25
4 Avg sleep duration    6.27

What does this mean?

Avg bedtime phone usage is apx around 59.26 mins.

avg sleep duration is apx 6.27 hours.

Visualization 1: Phone usage vs Sleep duration

How to read the graph??

Each dot represents all the given observations and the line shows the linear trend.

Visualization 2: Average sleep duration by phone usage

How to read the graph?? x-axis : groups of people based on how long they use their phones before bed

y-axis : shows the avg num of hours of sleep for each group

Interaction plotly visualization

Simple linear Regression

\[ Y_i = \beta_0 + \beta_1 X_i + \varepsilon_i \]

\(Y_i\) : Sleep duration in hours

\(X_i\): Bedtime phone use in minutes

\(\beta_0\) : Intercept

\(\beta_1\) : Slope

\(\varepsilon_i\) : Random error

Call:
lm(formula = total_sleep_hours ~ bedtime_phone_minutes, data = bedtime)

Residuals:
    Min      1Q  Median      3Q     Max 
-3.9184 -0.8511  0.0917  0.8696  3.2360 

Coefficients:
                        Estimate Std. Error t value Pr(>|t|)    
(Intercept)            7.5525629  0.0246829  305.98   <2e-16 ***
bedtime_phone_minutes -0.0217106  0.0003535  -61.41   <2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 1.204 on 8498 degrees of freedom
Multiple R-squared:  0.3074,    Adjusted R-squared:  0.3073 
F-statistic:  3771 on 1 and 8498 DF,  p-value: < 2.2e-16

Actual R code slide

meanOfLatency = mean(bedtime$sleep_latency_min, na.rm = TRUE)
meanOffatigue = mean(bedtime$next_day_fatigue_score, na.rm = TRUE)

meanOffatigue
meanOfLatency

The mean of how long it takes to go from full wakefulness to first stage of sleep is 3.79471

The mean of the fatigue of is around 40.67147

Conclusion

The data set included over 8500 observations and 18 variables related to phone usage and sleep habits.

Avg bedtime phone usage was around 59.25 mins while avg sleep was around 6.27 hours

The scatterplot and the linear regression showed a negative relationship between bed time phone usage and sleep duration

More bedtime phone usage is associated with shorter sleep duration in this dataset I chose.