This report presents an analysis of sleep patterns among college students, utilizing the SleepStudy dataset obtained from Lock5Stat. The dataset includes 253 observations and 27 variables related to students’ sleep habits, academic performance, psychological health, and lifestyle choices.
The primary objective of this analysis is to explore various research questions about how sleep and lifestyle impact college students’ academic and emotional well-being. The research questions addressed are:
SleepStudy <- Read("https://www.lock5stat.com/datasets3e/SleepStudy.csv", quiet = TRUE)
head(SleepStudy)
## Gender ClassYear LarkOwl NumEarlyClass EarlyClass GPA ClassesMissed
## 1 0 4 Neither 0 0 3.60 0
## 2 0 4 Neither 2 1 3.24 0
## 3 0 4 Owl 0 0 2.97 12
## 4 0 1 Lark 5 1 3.76 0
## 5 0 4 Owl 0 0 3.20 4
## 6 1 4 Neither 0 0 3.50 0
## CognitionZscore PoorSleepQuality DepressionScore AnxietyScore StressScore
## 1 -0.26 4 4 3 8
## 2 1.39 6 1 0 3
## 3 0.38 18 18 18 9
## 4 1.39 9 1 4 6
## 5 1.22 9 7 25 14
## 6 -0.04 6 14 8 28
## DepressionStatus AnxietyStatus Stress DASScore Happiness AlcoholUse Drinks
## 1 normal normal normal 15 28 Moderate 10
## 2 normal normal normal 4 25 Moderate 6
## 3 moderate severe normal 45 17 Light 3
## 4 normal normal normal 11 32 Light 2
## 5 normal severe normal 46 15 Moderate 4
## 6 moderate moderate high 50 22 Abstain 0
## WeekdayBed WeekdayRise WeekdaySleep WeekendBed WeekendRise WeekendSleep
## 1 25.75 8.70 7.70 25.75 9.50 5.88
## 2 25.70 8.20 6.80 26.00 10.00 7.25
## 3 27.44 6.55 3.00 28.00 12.59 10.09
## 4 23.50 7.17 6.77 27.00 8.00 7.25
## 5 25.90 8.67 6.09 23.75 9.50 7.00
## 6 23.80 8.95 9.05 26.00 10.75 9.00
## AverageSleep AllNighter
## 1 7.18 0
## 2 6.93 0
## 3 5.02 0
## 4 6.90 0
## 5 6.35 0
## 6 9.04 0
ttest(GPA ~ Gender, data = SleepStudy)
##
## Compare GPA across Gender with levels 0 and 1
## Grouping Variable: Gender
## Response Variable: GPA
##
##
## ------ Describe ------
##
## GPA for Gender 0: n.miss = 0, n = 151, mean = 3.325, sd = 0.375
## GPA for Gender 1: n.miss = 0, n = 102, mean = 3.124, sd = 0.418
##
## Mean Difference of GPA: 0.201
##
## Weighted Average Standard Deviation: 0.393
##
##
## ------ Assumptions ------
##
## Note: These hypothesis tests can perform poorly, and the
## t-test is typically robust to violations of assumptions.
## Use as heuristic guides instead of interpreting literally.
##
## Null hypothesis, for each group, is a normal distribution of GPA.
## Group 0: Sample mean assumed normal because n > 30, so no test needed.
## Group 1: Sample mean assumed normal because n > 30, so no test needed.
##
## Null hypothesis is equal variances of GPA, homogeneous.
## Variance Ratio test: F = 0.174/0.141 = 1.240, df = 101;150, p-value = 0.232
## Levene's test, Brown-Forsythe: t = -1.879, df = 251, p-value = 0.061
##
##
## ------ Infer ------
##
## --- Assume equal population variances of GPA for each Gender
##
## t-cutoff for 95% range of variation: tcut = 1.969
## Standard Error of Mean Difference: SE = 0.050
##
## Hypothesis Test of 0 Mean Diff: t-value = 3.996, df = 251, p-value = 0.000
##
## Margin of Error for 95% Confidence Level: 0.099
## 95% Confidence Interval for Mean Difference: 0.102 to 0.300
##
##
## --- Do not assume equal population variances of GPA for each Gender
##
## t-cutoff: tcut = 1.972
## Standard Error of Mean Difference: SE = 0.051
##
## Hypothesis Test of 0 Mean Diff: t = 3.914, df = 200.902, p-value = 0.000
##
## Margin of Error for 95% Confidence Level: 0.101
## 95% Confidence Interval for Mean Difference: 0.100 to 0.303
##
##
## ------ Effect Size ------
##
## --- Assume equal population variances of GPA for each Gender
##
## Standardized Mean Difference of GPA, Cohen's d: 0.512
##
##
## ------ Practical Importance ------
##
## Minimum Mean Difference of practical importance: mmd
## Minimum Standardized Mean Difference of practical importance: msmd
## Neither value specified, so no analysis
##
##
## ------ Graphics Smoothing Parameter ------
##
## Density bandwidth for Gender 0: 0.154
## Density bandwidth for Gender 1: 0.189
SleepStudy$YearGroup <- ifelse(SleepStudy$ClassYear <= 2, "Lower", "Upper")
ttest(NumEarlyClass ~ YearGroup, data = SleepStudy)
##
## Compare NumEarlyClass across YearGroup with levels Lower and Upper
## Grouping Variable: YearGroup
## Response Variable: NumEarlyClass
##
##
## ------ Describe ------
##
## NumEarlyClass for YearGroup Lower: n.miss = 0, n = 142, mean = 2.070, sd = 1.657
## NumEarlyClass for YearGroup Upper: n.miss = 0, n = 111, mean = 1.306, sd = 1.249
##
## Mean Difference of NumEarlyClass: 0.764
##
## Weighted Average Standard Deviation: 1.492
##
##
## ------ Assumptions ------
##
## Note: These hypothesis tests can perform poorly, and the
## t-test is typically robust to violations of assumptions.
## Use as heuristic guides instead of interpreting literally.
##
## Null hypothesis, for each group, is a normal distribution of NumEarlyClass.
## Group Lower: Sample mean assumed normal because n > 30, so no test needed.
## Group Upper: Sample mean assumed normal because n > 30, so no test needed.
##
## Null hypothesis is equal variances of NumEarlyClass, homogeneous.
## Variance Ratio test: F = 2.747/1.560 = 1.761, df = 141;110, p-value = 0.002
## Levene's test, Brown-Forsythe: t = 2.424, df = 251, p-value = 0.016
##
##
## ------ Infer ------
##
## --- Assume equal population variances of NumEarlyClass for each YearGroup
##
## t-cutoff for 95% range of variation: tcut = 1.969
## Standard Error of Mean Difference: SE = 0.189
##
## Hypothesis Test of 0 Mean Diff: t-value = 4.042, df = 251, p-value = 0.000
##
## Margin of Error for 95% Confidence Level: 0.372
## 95% Confidence Interval for Mean Difference: 0.392 to 1.136
##
##
## --- Do not assume equal population variances of NumEarlyClass for each YearGroup
##
## t-cutoff: tcut = 1.969
## Standard Error of Mean Difference: SE = 0.183
##
## Hypothesis Test of 0 Mean Diff: t = 4.181, df = 250.690, p-value = 0.000
##
## Margin of Error for 95% Confidence Level: 0.360
## 95% Confidence Interval for Mean Difference: 0.404 to 1.124
##
##
## ------ Effect Size ------
##
## --- Assume equal population variances of NumEarlyClass for each YearGroup
##
## Standardized Mean Difference of NumEarlyClass, Cohen's d: 0.512
##
##
## ------ Practical Importance ------
##
## Minimum Mean Difference of practical importance: mmd
## Minimum Standardized Mean Difference of practical importance: msmd
## Neither value specified, so no analysis
##
##
## ------ Graphics Smoothing Parameter ------
##
## Density bandwidth for YearGroup Lower: 0.701
## Density bandwidth for YearGroup Upper: 0.555
LarkOwlSubset <- subset(SleepStudy, LarkOwl %in% c("Lark", "Owl"))
ttest(CognitionZscore ~ LarkOwl, data = LarkOwlSubset)
##
## Compare CognitionZscore across LarkOwl with levels Lark and Owl
## Grouping Variable: LarkOwl
## Response Variable: CognitionZscore
##
##
## ------ Describe ------
##
## CognitionZscore for LarkOwl Lark: n.miss = 0, n = 41, mean = 0.090, sd = 0.830
## CognitionZscore for LarkOwl Owl: n.miss = 0, n = 49, mean = -0.038, sd = 0.653
##
## Mean Difference of CognitionZscore: 0.129
##
## Weighted Average Standard Deviation: 0.738
##
##
## ------ Assumptions ------
##
## Note: These hypothesis tests can perform poorly, and the
## t-test is typically robust to violations of assumptions.
## Use as heuristic guides instead of interpreting literally.
##
## Null hypothesis, for each group, is a normal distribution of CognitionZscore.
## Group Lark: Sample mean assumed normal because n > 30, so no test needed.
## Group Owl: Sample mean assumed normal because n > 30, so no test needed.
##
## Null hypothesis is equal variances of CognitionZscore, homogeneous.
## Variance Ratio test: F = 0.688/0.426 = 1.615, df = 40;48, p-value = 0.112
## Levene's test, Brown-Forsythe: t = 1.336, df = 88, p-value = 0.185
##
##
## ------ Infer ------
##
## --- Assume equal population variances of CognitionZscore for each LarkOwl
##
## t-cutoff for 95% range of variation: tcut = 1.987
## Standard Error of Mean Difference: SE = 0.156
##
## Hypothesis Test of 0 Mean Diff: t-value = 0.823, df = 88, p-value = 0.413
##
## Margin of Error for 95% Confidence Level: 0.311
## 95% Confidence Interval for Mean Difference: -0.182 to 0.439
##
##
## --- Do not assume equal population variances of CognitionZscore for each LarkOwl
##
## t-cutoff: tcut = 1.992
## Standard Error of Mean Difference: SE = 0.160
##
## Hypothesis Test of 0 Mean Diff: t = 0.806, df = 75.331, p-value = 0.423
##
## Margin of Error for 95% Confidence Level: 0.318
## 95% Confidence Interval for Mean Difference: -0.189 to 0.447
##
##
## ------ Effect Size ------
##
## --- Assume equal population variances of CognitionZscore for each LarkOwl
##
## Standardized Mean Difference of CognitionZscore, Cohen's d: 0.174
##
##
## ------ Practical Importance ------
##
## Minimum Mean Difference of practical importance: mmd
## Minimum Standardized Mean Difference of practical importance: msmd
## Neither value specified, so no analysis
##
##
## ------ Graphics Smoothing Parameter ------
##
## Density bandwidth for LarkOwl Lark: 0.450
## Density bandwidth for LarkOwl Owl: 0.341
ttest(ClassesMissed ~ EarlyClass, data = SleepStudy)
##
## Compare ClassesMissed across EarlyClass with levels 0 and 1
## Grouping Variable: EarlyClass
## Response Variable: ClassesMissed
##
##
## ------ Describe ------
##
## ClassesMissed for EarlyClass 0: n.miss = 0, n = 85, mean = 2.647, sd = 3.477
## ClassesMissed for EarlyClass 1: n.miss = 0, n = 168, mean = 1.988, sd = 3.101
##
## Mean Difference of ClassesMissed: 0.659
##
## Weighted Average Standard Deviation: 3.232
##
##
## ------ Assumptions ------
##
## Note: These hypothesis tests can perform poorly, and the
## t-test is typically robust to violations of assumptions.
## Use as heuristic guides instead of interpreting literally.
##
## Null hypothesis, for each group, is a normal distribution of ClassesMissed.
## Group 0: Sample mean assumed normal because n > 30, so no test needed.
## Group 1: Sample mean assumed normal because n > 30, so no test needed.
##
## Null hypothesis is equal variances of ClassesMissed, homogeneous.
## Variance Ratio test: F = 12.088/9.617 = 1.257, df = 84;167, p-value = 0.214
## Levene's test, Brown-Forsythe: t = 1.373, df = 251, p-value = 0.171
##
##
## ------ Infer ------
##
## --- Assume equal population variances of ClassesMissed for each EarlyClass
##
## t-cutoff for 95% range of variation: tcut = 1.969
## Standard Error of Mean Difference: SE = 0.430
##
## Hypothesis Test of 0 Mean Diff: t-value = 1.532, df = 251, p-value = 0.127
##
## Margin of Error for 95% Confidence Level: 0.847
## 95% Confidence Interval for Mean Difference: -0.188 to 1.506
##
##
## --- Do not assume equal population variances of ClassesMissed for each EarlyClass
##
## t-cutoff: tcut = 1.976
## Standard Error of Mean Difference: SE = 0.447
##
## Hypothesis Test of 0 Mean Diff: t = 1.475, df = 152.779, p-value = 0.142
##
## Margin of Error for 95% Confidence Level: 0.882
## 95% Confidence Interval for Mean Difference: -0.223 to 1.541
##
##
## ------ Effect Size ------
##
## --- Assume equal population variances of ClassesMissed for each EarlyClass
##
## Standardized Mean Difference of ClassesMissed, Cohen's d: 0.204
##
##
## ------ Practical Importance ------
##
## Minimum Mean Difference of practical importance: mmd
## Minimum Standardized Mean Difference of practical importance: msmd
## Neither value specified, so no analysis
##
##
## ------ Graphics Smoothing Parameter ------
##
## Density bandwidth for EarlyClass 0: 1.629
## Density bandwidth for EarlyClass 1: 1.044
# Filter only for normal, moderate, and severe
DepSubset <- subset(SleepStudy, DepressionStatus %in% c("normal", "moderate", "severe"))
# Create two groups: "Mod-Sev" and "Normal"
DepSubset$DepGroup <- ifelse(DepSubset$DepressionStatus %in% c("moderate", "severe"), "Mod-Sev", "Normal")
# Confirm grouping worked
print(table(DepSubset$DepGroup))
##
## Mod-Sev Normal
## 44 209
# Run the t-test on Happiness
ttest(Happiness ~ DepGroup, data = DepSubset)
##
## Compare Happiness across DepGroup with levels Normal and Mod-Sev
## Grouping Variable: DepGroup
## Response Variable: Happiness
##
##
## ------ Describe ------
##
## Happiness for DepGroup Normal: n.miss = 0, n = 209, mean = 27.057, sd = 4.885
## Happiness for DepGroup Mod-Sev: n.miss = 0, n = 44, mean = 21.614, sd = 6.005
##
## Mean Difference of Happiness: 5.444
##
## Weighted Average Standard Deviation: 5.094
##
##
## ------ Assumptions ------
##
## Note: These hypothesis tests can perform poorly, and the
## t-test is typically robust to violations of assumptions.
## Use as heuristic guides instead of interpreting literally.
##
## Null hypothesis, for each group, is a normal distribution of Happiness.
## Group Normal: Sample mean assumed normal because n > 30, so no test needed.
## Group Mod-Sev: Sample mean assumed normal because n > 30, so no test needed.
##
## Null hypothesis is equal variances of Happiness, homogeneous.
## Variance Ratio test: F = 36.057/23.862 = 1.511, df = 43;208, p-value = 0.062
## Levene's test, Brown-Forsythe: t = -2.246, df = 251, p-value = 0.026
##
##
## ------ Infer ------
##
## --- Assume equal population variances of Happiness for each DepGroup
##
## t-cutoff for 95% range of variation: tcut = 1.969
## Standard Error of Mean Difference: SE = 0.845
##
## Hypothesis Test of 0 Mean Diff: t-value = 6.443, df = 251, p-value = 0.000
##
## Margin of Error for 95% Confidence Level: 1.664
## 95% Confidence Interval for Mean Difference: 3.780 to 7.108
##
##
## --- Do not assume equal population variances of Happiness for each DepGroup
##
## t-cutoff: tcut = 2.004
## Standard Error of Mean Difference: SE = 0.966
##
## Hypothesis Test of 0 Mean Diff: t = 5.634, df = 55.594, p-value = 0.000
##
## Margin of Error for 95% Confidence Level: 1.936
## 95% Confidence Interval for Mean Difference: 3.508 to 7.380
##
##
## ------ Effect Size ------
##
## --- Assume equal population variances of Happiness for each DepGroup
##
## Standardized Mean Difference of Happiness, Cohen's d: 1.069
##
##
## ------ Practical Importance ------
##
## Minimum Mean Difference of practical importance: mmd
## Minimum Standardized Mean Difference of practical importance: msmd
## Neither value specified, so no analysis
##
##
## ------ Graphics Smoothing Parameter ------
##
## Density bandwidth for DepGroup Normal: 1.202
## Density bandwidth for DepGroup Mod-Sev: 3.211
ttest(PoorSleepQuality ~ AllNighter, data = SleepStudy)
##
## Compare PoorSleepQuality across AllNighter with levels 1 and 0
## Grouping Variable: AllNighter
## Response Variable: PoorSleepQuality
##
##
## ------ Describe ------
##
## PoorSleepQuality for AllNighter 1: n.miss = 0, n = 34, mean = 7.029, sd = 2.823
## PoorSleepQuality for AllNighter 0: n.miss = 0, n = 219, mean = 6.137, sd = 2.922
##
## Mean Difference of PoorSleepQuality: 0.892
##
## Weighted Average Standard Deviation: 2.910
##
##
## ------ Assumptions ------
##
## Note: These hypothesis tests can perform poorly, and the
## t-test is typically robust to violations of assumptions.
## Use as heuristic guides instead of interpreting literally.
##
## Null hypothesis, for each group, is a normal distribution of PoorSleepQuality.
## Group 1: Sample mean assumed normal because n > 30, so no test needed.
## Group 0: Sample mean assumed normal because n > 30, so no test needed.
##
## Null hypothesis is equal variances of PoorSleepQuality, homogeneous.
## Variance Ratio test: F = 8.541/7.969 = 1.072, df = 218;33, p-value = 0.846
## Levene's test, Brown-Forsythe: t = 0.279, df = 251, p-value = 0.780
##
##
## ------ Infer ------
##
## --- Assume equal population variances of PoorSleepQuality for each AllNighter
##
## t-cutoff for 95% range of variation: tcut = 1.969
## Standard Error of Mean Difference: SE = 0.536
##
## Hypothesis Test of 0 Mean Diff: t-value = 1.664, df = 251, p-value = 0.097
##
## Margin of Error for 95% Confidence Level: 1.056
## 95% Confidence Interval for Mean Difference: -0.164 to 1.949
##
##
## --- Do not assume equal population variances of PoorSleepQuality for each AllNighter
##
## t-cutoff: tcut = 2.014
## Standard Error of Mean Difference: SE = 0.523
##
## Hypothesis Test of 0 Mean Diff: t = 1.707, df = 44.708, p-value = 0.095
##
## Margin of Error for 95% Confidence Level: 1.053
## 95% Confidence Interval for Mean Difference: -0.161 to 1.946
##
##
## ------ Effect Size ------
##
## --- Assume equal population variances of PoorSleepQuality for each AllNighter
##
## Standardized Mean Difference of PoorSleepQuality, Cohen's d: 0.307
##
##
## ------ Practical Importance ------
##
## Minimum Mean Difference of practical importance: mmd
## Minimum Standardized Mean Difference of practical importance: msmd
## Neither value specified, so no analysis
##
##
## ------ Graphics Smoothing Parameter ------
##
## Density bandwidth for AllNighter 1: 1.589
## Density bandwidth for AllNighter 0: 0.936
StressSubset <- subset(SleepStudy, AlcoholUse %in% c("Abstain", "Heavy"))
ttest(StressScore ~ AlcoholUse, data = StressSubset)
##
## Compare StressScore across AlcoholUse with levels Heavy and Abstain
## Grouping Variable: AlcoholUse
## Response Variable: StressScore
##
##
## ------ Describe ------
##
## StressScore for AlcoholUse Heavy: n.miss = 0, n = 16, mean = 10.438, sd = 7.797
## StressScore for AlcoholUse Abstain: n.miss = 0, n = 34, mean = 8.971, sd = 7.582
##
## Mean Difference of StressScore: 1.467
##
## Weighted Average Standard Deviation: 7.650
##
##
## ------ Assumptions ------
##
## Note: These hypothesis tests can perform poorly, and the
## t-test is typically robust to violations of assumptions.
## Use as heuristic guides instead of interpreting literally.
##
## Null hypothesis, for each group, is a normal distribution of StressScore.
## Group Heavy Shapiro-Wilk normality test: W = 0.961, p-value = 0.687
## Group Abstain: Sample mean assumed normal because n > 30, so no test needed.
##
## Null hypothesis is equal variances of StressScore, homogeneous.
## Variance Ratio test: F = 60.796/57.484 = 1.058, df = 15;33, p-value = 0.856
## Levene's test, Brown-Forsythe: t = 0.347, df = 48, p-value = 0.730
##
##
## ------ Infer ------
##
## --- Assume equal population variances of StressScore for each AlcoholUse
##
## t-cutoff for 95% range of variation: tcut = 2.011
## Standard Error of Mean Difference: SE = 2.319
##
## Hypothesis Test of 0 Mean Diff: t-value = 0.633, df = 48, p-value = 0.530
##
## Margin of Error for 95% Confidence Level: 4.663
## 95% Confidence Interval for Mean Difference: -3.196 to 6.130
##
##
## --- Do not assume equal population variances of StressScore for each AlcoholUse
##
## t-cutoff: tcut = 2.046
## Standard Error of Mean Difference: SE = 2.343
##
## Hypothesis Test of 0 Mean Diff: t = 0.626, df = 28.733, p-value = 0.536
##
## Margin of Error for 95% Confidence Level: 4.794
## 95% Confidence Interval for Mean Difference: -3.327 to 6.261
##
##
## ------ Effect Size ------
##
## --- Assume equal population variances of StressScore for each AlcoholUse
##
## Standardized Mean Difference of StressScore, Cohen's d: 0.192
##
##
## ------ Practical Importance ------
##
## Minimum Mean Difference of practical importance: mmd
## Minimum Standardized Mean Difference of practical importance: msmd
## Neither value specified, so no analysis
##
##
## ------ Graphics Smoothing Parameter ------
##
## Density bandwidth for AlcoholUse Heavy: 5.096
## Density bandwidth for AlcoholUse Abstain: 4.268
ttest(Drinks ~ Gender, data = SleepStudy)
##
## Compare Drinks across Gender with levels 1 and 0
## Grouping Variable: Gender
## Response Variable: Drinks
##
##
## ------ Describe ------
##
## Drinks for Gender 1: n.miss = 0, n = 102, mean = 7.539, sd = 4.929
## Drinks for Gender 0: n.miss = 0, n = 151, mean = 4.238, sd = 2.720
##
## Mean Difference of Drinks: 3.301
##
## Weighted Average Standard Deviation: 3.768
##
##
## ------ Assumptions ------
##
## Note: These hypothesis tests can perform poorly, and the
## t-test is typically robust to violations of assumptions.
## Use as heuristic guides instead of interpreting literally.
##
## Null hypothesis, for each group, is a normal distribution of Drinks.
## Group 1: Sample mean assumed normal because n > 30, so no test needed.
## Group 0: Sample mean assumed normal because n > 30, so no test needed.
##
## Null hypothesis is equal variances of Drinks, homogeneous.
## Variance Ratio test: F = 24.291/7.396 = 3.284, df = 101;150, p-value = 0.000
## Levene's test, Brown-Forsythe: t = 5.471, df = 251, p-value = 0.000
##
##
## ------ Infer ------
##
## --- Assume equal population variances of Drinks for each Gender
##
## t-cutoff for 95% range of variation: tcut = 1.969
## Standard Error of Mean Difference: SE = 0.483
##
## Hypothesis Test of 0 Mean Diff: t-value = 6.836, df = 251, p-value = 0.000
##
## Margin of Error for 95% Confidence Level: 0.951
## 95% Confidence Interval for Mean Difference: 2.350 to 4.252
##
##
## --- Do not assume equal population variances of Drinks for each Gender
##
## t-cutoff: tcut = 1.977
## Standard Error of Mean Difference: SE = 0.536
##
## Hypothesis Test of 0 Mean Diff: t = 6.160, df = 142.754, p-value = 0.000
##
## Margin of Error for 95% Confidence Level: 1.059
## 95% Confidence Interval for Mean Difference: 2.242 to 4.360
##
##
## ------ Effect Size ------
##
## --- Assume equal population variances of Drinks for each Gender
##
## Standardized Mean Difference of Drinks, Cohen's d: 0.876
##
##
## ------ Practical Importance ------
##
## Minimum Mean Difference of practical importance: mmd
## Minimum Standardized Mean Difference of practical importance: msmd
## Neither value specified, so no analysis
##
##
## ------ Graphics Smoothing Parameter ------
##
## Density bandwidth for Gender 1: 2.227
## Density bandwidth for Gender 0: 1.136
# Filter only for "normal" and "high" stress
StressSubset2 <- subset(SleepStudy, Stress %in% c("normal", "high"))
# Remove any rows with missing weekday bedtime
StressSubset2 <- subset(StressSubset2, !is.na(WeekdayBed))
# Assign the grouping variable
StressSubset2$StressGroup <- StressSubset2$Stress
# Confirm it's working
print(table(StressSubset2$StressGroup))
##
## high normal
## 56 197
# Run the t-test
ttest(WeekdayBed ~ StressGroup, data = StressSubset2)
##
## Compare WeekdayBed across StressGroup with levels normal and high
## Grouping Variable: StressGroup
## Response Variable: WeekdayBed
##
##
## ------ Describe ------
##
## WeekdayBed for StressGroup normal: n.miss = 0, n = 197, mean = 24.885, sd = 1.028
## WeekdayBed for StressGroup high: n.miss = 0, n = 56, mean = 24.715, sd = 1.053
##
## Mean Difference of WeekdayBed: 0.170
##
## Weighted Average Standard Deviation: 1.033
##
##
## ------ Assumptions ------
##
## Note: These hypothesis tests can perform poorly, and the
## t-test is typically robust to violations of assumptions.
## Use as heuristic guides instead of interpreting literally.
##
## Null hypothesis, for each group, is a normal distribution of WeekdayBed.
## Group normal: Sample mean assumed normal because n > 30, so no test needed.
## Group high: Sample mean assumed normal because n > 30, so no test needed.
##
## Null hypothesis is equal variances of WeekdayBed, homogeneous.
## Variance Ratio test: F = 1.108/1.056 = 1.049, df = 55;196, p-value = 0.792
## Levene's test, Brown-Forsythe: t = -0.054, df = 251, p-value = 0.957
##
##
## ------ Infer ------
##
## --- Assume equal population variances of WeekdayBed for each StressGroup
##
## t-cutoff for 95% range of variation: tcut = 1.969
## Standard Error of Mean Difference: SE = 0.156
##
## Hypothesis Test of 0 Mean Diff: t-value = 1.089, df = 251, p-value = 0.277
##
## Margin of Error for 95% Confidence Level: 0.308
## 95% Confidence Interval for Mean Difference: -0.138 to 0.479
##
##
## --- Do not assume equal population variances of WeekdayBed for each StressGroup
##
## t-cutoff: tcut = 1.988
## Standard Error of Mean Difference: SE = 0.159
##
## Hypothesis Test of 0 Mean Diff: t = 1.075, df = 87.048, p-value = 0.286
##
## Margin of Error for 95% Confidence Level: 0.315
## 95% Confidence Interval for Mean Difference: -0.145 to 0.486
##
##
## ------ Effect Size ------
##
## --- Assume equal population variances of WeekdayBed for each StressGroup
##
## Standardized Mean Difference of WeekdayBed, Cohen's d: 0.165
##
##
## ------ Practical Importance ------
##
## Minimum Mean Difference of practical importance: mmd
## Minimum Standardized Mean Difference of practical importance: msmd
## Neither value specified, so no analysis
##
##
## ------ Graphics Smoothing Parameter ------
##
## Density bandwidth for StressGroup normal: 0.407
## Density bandwidth for StressGroup high: 0.536
Each hypothesis test provided insights into how sleep, stress, and habits affect the academic and emotional well-being of college students. Below is a summary: