2023-11-19

1

Sleep Data

Limitations of the data - Viewing the min and max of the age column shows that our youngest participant is 9 years old, but for our purpose of inspecting the relationship between alcohol and sleep this will not be relevant.

summary(mydata)
##        ID             Age           Gender            Bedtime         
##  Min.   :  1.0   Min.   : 9.00   Length:452         Length:452        
##  1st Qu.:113.8   1st Qu.:29.00   Class :character   Class :character  
##  Median :226.5   Median :40.00   Mode  :character   Mode  :character  
##  Mean   :226.5   Mean   :40.29                                        
##  3rd Qu.:339.2   3rd Qu.:52.00                                        
##  Max.   :452.0   Max.   :69.00                                        
##                                                                       
##  Wakeup.time        Sleep.duration   Sleep.efficiency REM.sleep.percentage
##  Length:452         Min.   : 5.000   Min.   :0.5000   Min.   :15.00       
##  Class :character   1st Qu.: 7.000   1st Qu.:0.6975   1st Qu.:20.00       
##  Mode  :character   Median : 7.500   Median :0.8200   Median :22.00       
##                     Mean   : 7.466   Mean   :0.7889   Mean   :22.62       
##                     3rd Qu.: 8.000   3rd Qu.:0.9000   3rd Qu.:25.00       
##                     Max.   :10.000   Max.   :0.9900   Max.   :30.00       
##                                                                           
##  Deep.sleep.percentage Light.sleep.percentage   Awakenings   
##  Min.   :18.00         Min.   : 7.00          Min.   :0.000  
##  1st Qu.:48.25         1st Qu.:15.00          1st Qu.:1.000  
##  Median :58.00         Median :18.00          Median :1.000  
##  Mean   :52.82         Mean   :24.56          Mean   :1.641  
##  3rd Qu.:63.00         3rd Qu.:32.50          3rd Qu.:3.000  
##  Max.   :75.00         Max.   :63.00          Max.   :4.000  
##                                               NA's   :20     
##  Caffeine.consumption Alcohol.consumption Smoking.status     Exercise.frequency
##  Min.   :  0.00       Min.   :0.000       Length:452         Min.   :0.000     
##  1st Qu.:  0.00       1st Qu.:0.000       Class :character   1st Qu.:0.000     
##  Median : 25.00       Median :0.000       Mode  :character   Median :2.000     
##  Mean   : 23.65       Mean   :1.174                          Mean   :1.791     
##  3rd Qu.: 50.00       3rd Qu.:2.000                          3rd Qu.:3.000     
##  Max.   :200.00       Max.   :5.000                          Max.   :5.000     
##  NA's   :25           NA's   :14                             NA's   :6

Typical Night of Sleep

Sleep occurs in five stages: wake, N1, N2, N3, and REM. Stages N1 to N3 are considered non-rapid eye movement (NREM) sleep, with each stage a progressively deeper sleep. Approximately 75% of sleep is spent in the NREM stages, with the majority spent in the N2 stage. A typical night’s sleep consists of 4 to 5 sleep cycles, with the progression of sleep stages in the following order: N1, N2, N3, N2, REM. A complete sleep cycle takes roughly 90 to 110 minutes. The first REM period is short, and, as the night progresses, longer periods of REM and decreased time in deep sleep (NREM) occur.

Filtering

I will filter between alcohol consumers and non-alcohol consumers for future testing purposes.

AlcoholConsumer <- filter(mydata, Alcohol.consumption != 0)


NonAlcConsumer <- filter(mydata, Alcohol.consumption == 0)

Alcohol and Sleep Efficiency

Sleep Efficiency - ratio of total sleep time (TST) to time in bed (TIB) (multiplied by 100 to yield a percentage).

boxplot(mydata$Sleep.efficiency~mydata$Alcohol.consumption,data=mydata, main="Alcohol effect on Sleep Efficiency",
   ylab="Sleep Efficiency Score", xlab="Alcohol Consumption (oz)")

The box plot suggest there’s a decrease in sleep efficiency when alcohol is consumed. Let’s conduct a test:

t.test(AlcoholConsumer$Sleep.efficiency, NonAlcConsumer$Sleep.efficiency)
## 
##  Welch Two Sample t-test
## 
## data:  AlcoholConsumer$Sleep.efficiency and NonAlcConsumer$Sleep.efficiency
## t = -7.8476, df = 346.38, p-value = 5.333e-14
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.12337083 -0.07392337
## sample estimates:
## mean of x mean of y 
## 0.7333854 0.8320325

Because our p-value is 5.333e-14, we can say there is a significant difference between the sleep quality in those who consume alcohol and those who do not. The degrees of freedom is high, but we have a large sample size of 452. But why is the sleep efficiency being lowered? Which cycle of sleep is being affected? Lets look..

Alcohol and REM

boxplot(mydata$REM.sleep.percentage~mydata$Alcohol.consumption,data=mydata, main="Alcohol effect on REM Sleep",
   ylab="REM Sleep Percentage", xlab="Alcohol Consumption (oz)")

The percentage of REM sleep mostly stays between 20% - 25% with no significant difference between alcohol consumers and non-alcohol consumers.

t.test(AlcoholConsumer$REM.sleep.percentage, NonAlcConsumer$REM.sleep.percentage)
## 
##  Welch Two Sample t-test
## 
## data:  AlcoholConsumer$REM.sleep.percentage and NonAlcConsumer$REM.sleep.percentage
## t = -0.88035, df = 407.5, p-value = 0.3792
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.9552715  0.3643162
## sample estimates:
## mean of x mean of y 
##  22.46875  22.76423

Since our p-value is 0.3792 we cannot conclude that there is a significant difference in REM sleep between those who consume alcohol and those who do not. Let’s keep looking..

Alcohol and Sleep Duration

boxplot(mydata$Sleep.duration~mydata$Alcohol.consumption,data=mydata, main="Alcohol and Sleep Duration",
   ylab="Sleep Duration", xlab="Alcohol Consumption (oz)")

The box plot doesn’t show any significant differences in sleep duration between those who consume alcohol and those that do not, mostly staying between 7-8 hours a night.

t.test(AlcoholConsumer$Sleep.duration, NonAlcConsumer$Sleep.duration)
## 
##  Welch Two Sample t-test
## 
## data:  AlcoholConsumer$Sleep.duration and NonAlcConsumer$Sleep.duration
## t = 0.20531, df = 409.97, p-value = 0.8374
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.1475951  0.1820209
## sample estimates:
## mean of x mean of y 
##  7.476562  7.459350

Our test supports our assumptions from the box plot. The p-value is 0.8374 and shows no significance.

Alcohol and Deep Sleep

boxplot(mydata$Deep.sleep.percentage~mydata$Alcohol.consumption,data=mydata, main="Alcohol and Deep Sleep",
   ylab="Deep Sleep Percentage", xlab="Alcohol Consumption (oz)")

From looking at the box plot, there seems to be a huge differnce in deep sleep between those who drink and those who do not.

t.test(AlcoholConsumer$Deep.sleep.percentage, NonAlcConsumer$Deep.sleep.percentage)
## 
##  Welch Two Sample t-test
## 
## data:  AlcoholConsumer$Deep.sleep.percentage and NonAlcConsumer$Deep.sleep.percentage
## t = -7.1458, df = 316.05, p-value = 6.214e-12
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -13.571494  -7.711534
## sample estimates:
## mean of x mean of y 
##  46.78125  57.42276

Our test supports our findings from the box plot - the p-value is 6.214e-12, which shows a significance.

Alcohol and Light Sleep

boxplot(mydata$Light.sleep.percentage~mydata$Alcohol.consumption,data=mydata, main="Alcohol and Light Sleep",
   ylab="Light Sleep Percentage", xlab="Alcohol Consumption (oz)")

It looks like the percentage of light sleep in those who consume alcohol increases.

t.test(AlcoholConsumer$Deep.sleep.percentage, NonAlcConsumer$Deep.sleep.percentage)
## 
##  Welch Two Sample t-test
## 
## data:  AlcoholConsumer$Deep.sleep.percentage and NonAlcConsumer$Deep.sleep.percentage
## t = -7.1458, df = 316.05, p-value = 6.214e-12
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -13.571494  -7.711534
## sample estimates:
## mean of x mean of y 
##  46.78125  57.42276

Our test supports that claim - there is significance.

Light vs Deep sleep

Comparing light vs deep sleep next to each other completes the picture.

Awakenings

boxplot(mydata$Awakenings~mydata$Alcohol.consumption,data=mydata, main="Alcohol and Nightly Awakening",
   ylab="Awakenings", xlab="Alcohol Consumption (oz)")

t.test(AlcoholConsumer$Awakenings, NonAlcConsumer$Deep.sleep.percentage)
## 
##  Welch Two Sample t-test
## 
## data:  AlcoholConsumer$Awakenings and NonAlcConsumer$Deep.sleep.percentage
## t = -72.969, df = 253.96, p-value < 2.2e-16
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -57.01087 -54.01443
## sample estimates:
## mean of x mean of y 
##  1.910112 57.422764

Our test shows that there is statistical significance.

Conclusion

In conclusion, alcohol has significant effects on sleep efficiency. This is because the effects it has on the light and deep sleep cycles. However, with our data set we were unable to determine that there was a significant effect alcohol had on REM sleep.