1. Introduction

This is the second project of the STAT 353 course. In this project, we will handle the data of SleepStudy in lock5stat and determine the patterns and relationships between data variables.

In this report, the following questions are going to be addressed:

  1. Is there a significant difference in the average GPA between male and female college students?
  2. Is there a significant difference in the average number of early classes between the first two class years and other class years?
  3. Do students who identify as “larks” have significantly better cognitive skills (cognition z-score) compared to “owls”?
  4. 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)?
  5. Is there a significant difference in the average happiness level between students with at least moderate depression and normal depression status?
  6. 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)?
  7. Do students who abstain from alcohol use have significantly better stress scores than those who report heavy alcohol use?
  8. Is there a significant difference in the average number of drinks per week between students of different genders?
  9. Is there a significant difference in the average weekday bedtime between students with high and low stress (Stress=High vs. Stress=Normal)?
  10. Is there a significant difference in the average hours of sleep on weekends between first two year students and other students?

2. Data

According to the CSV file, the data represents a survey where entries are each individual college student. There are 27 variables and about 253 entries in the dataset. I will assume this sample to be completely random and would qualify for most next since n > 30.

According to Lock5DataGuide3e, “The data were obtained from a sample of students who did skills tests to measure cognitive function, completed a survey that asked many questions about attitudes and habits, and kept a sleep diary to record time and quality of sleep over a two week period.”

3. Analysis

First, we will need to import the dataset by using the following R code:

# Store data into a variable study
study = read.csv("https://www.lock5stat.com/datasets3e/SleepStudy.csv")

We can also use the less R package as a powerful tool for this project

# Load the lessR package
library(lessR)
## 
## lessR 4.4.2                         feedback: gerbing@pdx.edu 
## --------------------------------------------------------------
## > d <- Read("")  Read data file, many formats available, e.g., Excel
##   d is default data frame, data= in analysis routines optional
## 
## Many examples of reading, writing, and manipulating data, 
## graphics, testing means and proportions, regression, factor analysis,
## customization, forecasting, and aggregation from pivot tables
##   Enter: browseVignettes("lessR")
## 
## View lessR updates, now including time series forecasting
##   Enter: news(package="lessR")
## 
## Interactive data analysis
##   Enter: interact()
## 
## Attaching package: 'lessR'
## The following object is masked from 'package:base':
## 
##     sort_by

Then we will address each question individually to discover the patterns using statistical tests. I will use the 95% confidence level for all the tests that determine the significant difference.

Q1. Is there a significant difference in the average GPA between male and female college students?

We will perform a t-test for this scenario. The null hypothesis would be the equality of the means of two student groups, which are male and female.

Using the traditional t-test:

t.test(GPA~Gender, data = study, alt="two.sided", conf=0.95, var.eq=F)
## 
##  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

Using the t-test method from the lessR library:

ttest(GPA~Gender, data = study, alternative="two_sided")
## 
## 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

According to the result, we got the p-value of 0.0001243, and it is less than 0.05, so we will reject the null hypothesis. To conclude, there is a significant difference in the average GPA between male and female college students.

Q2. Is there a significant difference in the average number of early classes between the first two class years and other class years?

The null hypothesis in this case would be that the average number of early classes between the first two class years and other class years is equal.

study$YearGroup <- ifelse(study$ClassYear %in% c(1, 2), "FirstTwo", "Others")
ttest(NumEarlyClass~YearGroup, data = study, alternative="two_sided")
## 
## Compare NumEarlyClass across YearGroup with levels FirstTwo and Others 
## Grouping Variable:  YearGroup
## Response Variable:  NumEarlyClass
## 
## 
## ------ Describe ------
## 
## NumEarlyClass for YearGroup FirstTwo:  n.miss = 0,  n = 142,  mean = 2.070,  sd = 1.657
## NumEarlyClass for YearGroup Others:  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 FirstTwo: Sample mean assumed normal because n > 30, so no test needed.
## Group Others: 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 FirstTwo: 0.701
## Density bandwidth for YearGroup Others: 0.555

In this case, we use the two-sample t-test for the means of early classes. According to the p-value of 0.0000401, we can reject the null hypothesis. Therefore, there is a statistically significant difference in the average number of early classes between the first two class years and other class years at a 95% confidence level.

Q3. Do students who identify as “larks” have significantly better cognitive skills (cognition z-score) compared to “owls”?

The null hypothesis would be larks’ cognition z-score would be less than or equal to the owls’ z-score. We will try to prove the alternative hypothesis.

larks <- study$CognitionZscore[study$LarkOwl == "Lark"]
owls <- study$CognitionZscore[study$LarkOwl == "Owl"]
t.test(larks, owls, alternative = "greater")
## 
##  Welch Two Sample t-test
## 
## data:  larks and owls
## t = 0.80571, df = 75.331, p-value = 0.2115
## alternative hypothesis: true difference in means is greater than 0
## 95 percent confidence interval:
##  -0.1372184        Inf
## sample estimates:
##   mean of x   mean of y 
##  0.09024390 -0.03836735

We got the p-value of 0.211, which indicates that we failed to reject the null hypothesis. Students who identify as “larks” do not have significantly better cognitive skills (cognition z-score) compared to “owls”.

Q4. 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)?

We will also perform a Welch Two Sample t-test for this one with the null hypothesis of the number of classes missed for the two student groups being equal.

ttest(ClassesMissed~EarlyClass, data = study, alt="two_sided", conf=0.95, var.eq=F)
## 
## 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

The p-value for the test is 0.142, which is larger than 0.05. Therefore, we failed to reject the null hypothesis, and there is no statistically significant difference in the average number of classes missed in a semester for the students who had at least one early class and those who didn’t.

Q5. Is there a significant difference in the average happiness level between students with at least moderate depression and normal depression status?

This will again be a two-sample t-test. The null hypothesis will be that the mean happiness level of students with at least moderate depression is equal to students who have normal depression status.

normal <- study$Happiness[study$DepressionStatus == "normal"]
moderate_or_worse <- study$Happiness[study$DepressionStatus != "normal"]
t.test(normal, moderate_or_worse)
## 
##  Welch Two Sample t-test
## 
## data:  normal and moderate_or_worse
## t = 5.6339, df = 55.594, p-value = 0.0000006057
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  3.507836 7.379724
## sample estimates:
## mean of x mean of y 
##  27.05742  21.61364

The p-value = 0.0000006057 indicates that we can reject the null hypothesis. It looks like students who have normal depression have significantly higher happiness levels than the other group.

Q6. 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)?

We will perform a two-sample test for the mean of the sleep quality of two student groups. The null hypothesis would be the equality of the mean sleep quality of those two groups.

ttest(PoorSleepQuality~AllNighter, data = study, alt="two_sided", conf=0.95, var.eq=F)
## 
## 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

The p-value = 0.095 is larger than 0.05. Therefore, we failed to reject the null hypothesis, and there would be no significant difference in sleep quality scores between students in those two groups.

Q7. Do students who abstain from alcohol use have significantly better stress scores than those who report heavy alcohol use?

We will use the two-sample t-test for this question. The alternative hypothesis is that students who abstain from alcohol use have significantly better stress scores than those who report heavy alcohol use. The null hypothesis would be that students who abstain from alcohol use have lower or equal test scores than those who report heavy alcohol use. The alternative sets it to less because a better stress score means a lower value.

abstain <- study$StressScore[study$AlcoholUse == "Abstain"]
heavy <- study$StressScore[study$AlcoholUse == "Heavy"]
t.test(abstain, heavy, alternative = "less")
## 
##  Welch Two Sample t-test
## 
## data:  abstain and heavy
## t = -0.62604, df = 28.733, p-value = 0.2681
## alternative hypothesis: true difference in means is less than 0
## 95 percent confidence interval:
##      -Inf 2.515654
## sample estimates:
## mean of x mean of y 
##  8.970588 10.437500

The p-value = 0.2681 determines that we couldn’t reject the null hypothesis, so there would be no significant difference in stress scores between the two groups.

Q8. Is there a significant difference in the average number of drinks per week between students of different genders?

We will implement the two-sample t-test in this case for the number of drinks per week between students of different genders. The null hypothesis would be the equality of the means number of drinks for students in those two groups, whereas the alternative hypothesis would be that there is a significant difference in the means number of drinks per week between students of different genders.

ttest(Drinks~Gender, data = study, alt="two_sided", conf=0.95, var.eq=F)
## 
## 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

As we can see from the t-test that the value is close to zero indicates that we can reject the null hypothesis. There is a significant difference in the average number of drinks per week between male and female students.

Q9. Is there a significant difference in the average weekday bedtime between students with high and low stress (Stress=High vs. Stress=Normal)?

We also perform the two-sample t-test in this scenario. The null hypothesis would be that the average weekday bedtime between students with high and low stress is equal.

ttest(WeekdayBed~Stress, data = study, alt="two_sided", conf=0.95, var.eq=F)
## 
## Compare WeekdayBed across Stress with levels normal and high 
## Grouping Variable:  Stress
## Response Variable:  WeekdayBed
## 
## 
## ------ Describe ------
## 
## WeekdayBed for Stress normal:  n.miss = 0,  n = 197,  mean = 24.885,  sd = 1.028
## WeekdayBed for Stress 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 Stress 
## 
## 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 Stress 
## 
## 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 Stress 
## 
## 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 Stress normal: 0.407
## Density bandwidth for Stress high: 0.536

The p-value of 0.286 indicates that we can not reject the null hypothesis. Therefore, there is no significant difference in weekday bedtimes between students with high and normal stress.

Q10. Is there a significant difference in the average hours of sleep on weekends between first two year students and other students?

The final question would be best solved by doing the two-sample t-test. The null hypothesis would be the equality of the means of hours of sleep on weekends between first-year students and other students.

study$YearGroup <- ifelse(study$ClassYear %in% c(1, 2), "FirstTwo", "Others")
ttest(WeekdaySleep~YearGroup, data = study, alt="two_sided", conf=0.95)
## 
## Compare WeekdaySleep across YearGroup with levels FirstTwo and Others 
## Grouping Variable:  YearGroup
## Response Variable:  WeekdaySleep
## 
## 
## ------ Describe ------
## 
## WeekdaySleep for YearGroup FirstTwo:  n.miss = 0,  n = 142,  mean = 7.912,  sd = 1.203
## WeekdaySleep for YearGroup Others:  n.miss = 0,  n = 111,  mean = 7.807,  sd = 1.123
## 
## Mean Difference of WeekdaySleep:  0.106
## 
## Weighted Average Standard Deviation:   1.169 
## 
## 
## ------ 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 WeekdaySleep.
## Group FirstTwo: Sample mean assumed normal because n > 30, so no test needed.
## Group Others: Sample mean assumed normal because n > 30, so no test needed.
## 
## Null hypothesis is equal variances of WeekdaySleep, homogeneous.
## Variance Ratio test:  F = 1.448/1.262 = 1.148,  df = 141;110,  p-value = 0.450
## Levene's test, Brown-Forsythe:  t = 0.734,  df = 251,  p-value = 0.464
## 
## 
## ------ Infer ------
## 
## --- Assume equal population variances of WeekdaySleep for each YearGroup 
## 
## t-cutoff for 95% range of variation: tcut =  1.969 
## Standard Error of Mean Difference: SE =  0.148 
## 
## Hypothesis Test of 0 Mean Diff:  t-value = 0.715,  df = 251,  p-value = 0.475
## 
## Margin of Error for 95% Confidence Level:  0.292
## 95% Confidence Interval for Mean Difference:  -0.186 to 0.398
## 
## 
## --- Do not assume equal population variances of WeekdaySleep for each YearGroup 
## 
## t-cutoff: tcut =  1.970 
## Standard Error of Mean Difference: SE =  0.147 
## 
## Hypothesis Test of 0 Mean Diff:  t = 0.721,  df = 243.205, p-value = 0.472
## 
## Margin of Error for 95% Confidence Level:  0.289
## 95% Confidence Interval for Mean Difference:  -0.183 to 0.395
## 
## 
## ------ Effect Size ------
## 
## --- Assume equal population variances of WeekdaySleep for each YearGroup 
## 
## Standardized Mean Difference of WeekdaySleep, Cohen's d:  0.091
## 
## 
## ------ 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 FirstTwo: 0.439
## Density bandwidth for YearGroup Others: 0.493

The p-value is 0.472, which is larger than 0.05. We failed to reject the null hypothesis, so there is no significant difference in the average hours of sleep on weekends between first two year students and other students.

4. Summary

To sum up, I found this project to be quite useful in proving and disproving the relationship between two or more variables in a dataset. I found a lot of interesting discoveries in the students’ data set, as the average GPA is higher for female students than for male students (proven in question 1). A reason that I could think of for this one would be that female students tend to focus more on arts and humanities subjects, where it’s easier to obtain a higher score, while male students might skew towards many engineering majors, where high scores are only for those with exceptional knowledge. I was also quite surprised to find that there would be no significant difference in stress scores between students who abstain from alcohol and those who report heavy alcohol use. It’s useful to perform a test like this since we usually assume that those two would have a cause-and-effect relationship or a somewhat correlation, but in reality, we failed to reject the null hypothesis based on the t-test of the given data (proved in question 7). Another interesting conclusion that I found is the fact that freshmen and sophomores often come to class earlier than their juniors and seniors (proved in question 2). Finally, I also want to point out that there is no significant difference in the average hours of sleep on weekends between first two year students and other students (proven in question 10). This is also fun to know given the fact that first two year students come to class earlier than the other groups, but there is no difference in hours of sleep on weekends for both groups.

5. References

Onyper, S., Thacher, P., Gilbert, J., Gradess, S., “Class Start Times, Sleep, and Academic Performance in College: A Path Analysis,” April 2012; 29(3): 318-335.

6. Appendix


# Q1 code
t.test(GPA~Gender, data = study, alt="two.sided", conf=0.95, var.eq=F)
ttest(GPA~Gender, data = study, alternative="two_sided")

# Q2 code
study$YearGroup <- ifelse(study$ClassYear %in% c(1, 2), "FirstTwo", "Others")
ttest(NumEarlyClass~YearGroup, data = study, alternative="two_sided")

# Q3 code
larks <- study$CognitionZscore[study$LarkOwl == "Lark"]
owls <- study$CognitionZscore[study$LarkOwl == "Owl"]
t.test(larks, owls, alternative = "greater")

# Q4 code
ttest(ClassesMissed~EarlyClass, data = study, alt="two_sided", conf=0.95, var.eq=F)

# Q5 code
normal <- study$Happiness[study$DepressionStatus == "normal"]
moderate_or_worse <- study$Happiness[study$DepressionStatus != "normal"]
t.test(normal, moderate_or_worse)

# Q6 code
ttest(PoorSleepQuality~AllNighter, data = study, alt="two_sided", conf=0.95, var.eq=F)

# Q7 code
abstain <- study$StressScore[study$AlcoholUse == "Abstain"]
heavy <- study$StressScore[study$AlcoholUse == "Heavy"]
t.test(abstain, heavy, alternative = "less")

# Q8 code
ttest(Drinks~Gender, data = study, alt="two_sided", conf=0.95, var.eq=F)

# Q9 code
ttest(WeekdayBed~Stress, data = study, alt="two_sided", conf=0.95, var.eq=F)

# Q10 code
study$YearGroup <- ifelse(study$ClassYear %in% c(1, 2), "FirstTwo", "Others")
ttest(WeekdaySleep~YearGroup, data = study, alt="two_sided", conf=0.95)