SleepStudy <- read.csv("https://www.lock5stat.com/datasets3e/SleepStudy.csv")

Question 1:

  1. Is there a significant difference in the average GPA between male and female college students?
t.test(GPA ~ Gender, data = SleepStudy)
## 
##  Welch Two Sample t-test
## 
## data:  GPA by Gender
## t = 3.9139, df = 200.9, p-value = 0.0001243
## alternative hypothesis: true difference in means between group 0 and group 1 is not equal to 0
## 95 percent confidence interval:
##  0.09982254 0.30252780
## sample estimates:
## mean in group 0 mean in group 1 
##        3.324901        3.123725

Question 2:

  1. Is there a significant difference in the average number of early classes between the first two class years and other class years?
first_two <- SleepStudy$EarlyClass[SleepStudy$ClassYear <= 2]
upper_years <- SleepStudy$EarlyClass[SleepStudy$ClassYear > 2]

t.test(first_two, upper_years, na.rm = TRUE)
## 
##  Welch Two Sample t-test
## 
## data:  first_two and upper_years
## t = 2.3233, df = 224.26, p-value = 0.02106
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  0.02121868 0.25831438
## sample estimates:
## mean of x mean of y 
## 0.7253521 0.5855856

Question 3:

  1. Do students who identify as “larks” have significantly better cognitive skills (cognition z-score) than “owls”?
larks <- SleepStudy$CognitionZscore[SleepStudy$LarkOwl == "Lark"]
owls <- SleepStudy$CognitionZscore[SleepStudy$LarkOwl == "Owl"]

t.test(larks, owls, na.rm = TRUE)
## 
##  Welch Two Sample t-test
## 
## data:  larks and owls
## t = 0.80571, df = 75.331, p-value = 0.4229
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.1893561  0.4465786
## sample estimates:
##   mean of x   mean of y 
##  0.09024390 -0.03836735

Question 4:

  1. Is there a significant difference in the average number of classes missed in a semester between students who had at least one early class (EarlyClass=1) and those who didn’t (EarlyClass=0)?
early <- SleepStudy$ClassesMissed[SleepStudy$EarlyClass == 1]
no_early <- SleepStudy$ClassesMissed[SleepStudy$EarlyClass == 0]

t.test(early, no_early, na.rm = TRUE)
## 
##  Welch Two Sample t-test
## 
## data:  early and no_early
## t = -1.4755, df = 152.78, p-value = 0.1421
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -1.5412830  0.2233558
## sample estimates:
## mean of x mean of y 
##  1.988095  2.647059

Question 5:

  1. Is there a significant difference in the average happiness level between students with at least moderate depression and normal depression status?
mod_sev <- SleepStudy$Happiness[SleepStudy$DepressionStatus %in% c("moderate", "severe")]
normal <- SleepStudy$Happiness[SleepStudy$DepressionStatus == "normal"]

t.test(mod_sev, normal, na.rm = TRUE)
## 
##  Welch Two Sample t-test
## 
## data:  mod_sev and normal
## t = -5.6339, df = 55.594, p-value = 6.057e-07
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -7.379724 -3.507836
## sample estimates:
## mean of x mean of y 
##  21.61364  27.05742

Question 6:

  1. Is there a significant difference in average sleep quality scores between students who reported having at least one all-nighter (AllNighter=1) and those who didn’t (AllNighter=0)?
alln <- SleepStudy$PoorSleepQuality[SleepStudy$AllNighter == 1]
none <- SleepStudy$PoorSleepQuality[SleepStudy$AllNighter == 0]

t.test(alln, none, na.rm = TRUE)
## 
##  Welch Two Sample t-test
## 
## data:  alln and none
## t = 1.7068, df = 44.708, p-value = 0.09479
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.1608449  1.9456958
## sample estimates:
## mean of x mean of y 
##  7.029412  6.136986

Question 7:

  1. Do students who abstain from alcohol use have significantly better stress scores than those who report heavy alcohol use?
abstain <- SleepStudy$StressScore[SleepStudy$AlcoholUse == "Abstain"]
heavy <- SleepStudy$StressScore[SleepStudy$AlcoholUse == "Heavy"]

t.test(abstain, heavy, na.rm = TRUE)
## 
##  Welch Two Sample t-test
## 
## data:  abstain and heavy
## t = -0.62604, df = 28.733, p-value = 0.5362
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -6.261170  3.327346
## sample estimates:
## mean of x mean of y 
##  8.970588 10.437500

Question 8:

  1. Is there a significant difference in the average number of drinks per week between students of different genders?
male_drinks <- SleepStudy$Drinks[SleepStudy$Gender == 1]
female_drinks <- SleepStudy$Drinks[SleepStudy$Gender == 0]

t.test(male_drinks, female_drinks, na.rm = TRUE)
## 
##  Welch Two Sample t-test
## 
## data:  male_drinks and female_drinks
## t = 6.1601, df = 142.75, p-value = 7.002e-09
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  2.241601 4.360009
## sample estimates:
## mean of x mean of y 
##  7.539216  4.238411

Question 9:

  1. Is there a significant difference in the average weekday bedtime between students with high and low stress (Stress=High vs. Stress=Normal)?
high_stress <- SleepStudy$WeekdayBed[SleepStudy$Stress == "high"]
normal_stress <- SleepStudy$WeekdayBed[SleepStudy$Stress == "normal"]

t.test(high_stress, normal_stress, na.rm = TRUE)
## 
##  Welch Two Sample t-test
## 
## data:  high_stress and normal_stress
## t = -1.0746, df = 87.048, p-value = 0.2855
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.4856597  0.1447968
## sample estimates:
## mean of x mean of y 
##  24.71500  24.88543

Question 10:

  1. Is there a significant difference in the average hours of sleep on weekends between first two-year students and other students?
lower_sleep <- SleepStudy$WeekendSleep[SleepStudy$ClassYear <= 2]
upper_sleep <- SleepStudy$WeekendSleep[SleepStudy$ClassYear > 2]

t.test(lower_sleep, upper_sleep, na.rm = TRUE)
## 
##  Welch Two Sample t-test
## 
## data:  lower_sleep and upper_sleep
## t = -0.047888, df = 237.36, p-value = 0.9618
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.3497614  0.3331607
## sample estimates:
## mean of x mean of y 
##  8.213592  8.221892