Homework 6

Due 11/17/24

Author

Your name here - update this!!!!

Modified

July 11, 2025

Directions

Please turn in this homework on Sakai. This homework must be submitted using a Quarto document. Please keep it rendered as an html! I know past homeworks said pdf, but all Quarto docs should be rendered as html for this class!

You can download the .qmd file for this assignment from Github

Tip

It is a good idea to try rendering your document from time to time as you go along! Note that rendering automatically saves your Qmd file and rendering frequently helps you catch your errors more quickly.

Hypothesis test & CI instructions
  • For book exercises, make sure to include all steps in a hypothesis test (where applicable) as outlined in the class notes.

  • Do not forget to include a discussion on whether you think the test (or CI) conditions have been satisfied. Are there assumptions you need to make in order for them to be satisfied? Whether you believe they are satisfied or not, continue to run the hypothesis test (or CI) as instructed.

Book exercises

4.4 Mental health, Part I

4.6 Thanksgiving spending, Part I

4.8 Age at first marriage, Part I

5.6 Working backwards, Part II

5.10 t⋆ vs. z⋆

5.12 Auto exhaust and lead exposure

1 R exercises

1.1 Load all the packages you need below here

1.2 R1: Are American adults getting enough sleep?

This problem uses data from the National Health and Nutrition Examination Survey (NHANES), a survey conducted annually by the US Centers for Disease Control (CDC). The complete NHANES dataset contains 10,000 observations, which will be the artificial target population.

A 2016 study from the CDC reported that more than a third of American adults are not getting enough sleep on a regular basis. The National Sleep Foundation recommends that adults need between 7 to 9 hours of sleep per night to function well. Consistent sleep deprivation is known to increase risk of health problems, negatively affect cognitive processes, and contribute to depressive symptoms.

The dataset nhanes.samp.adult in the oibiostat package contains sleep information for 135 participants ages 21 years or older that were randomly sampled from the NHANES population. The variable SleepHrsNight contains the self-reported number of hours a participant usually gets at night on weekdays or workdays.

Here is code to load the package and data:

library(oibiostat)
data("nhanes.samp.adult")

If the oibiostat package is giving you trouble, I have uploaded an .RData version of the dataset, which you can download then load with something like my following code:

library(here)
load(here("data", "nhanes.samp.adult.RData"))

1.2.1 Explore the distribution of in nhanes.samp.adult

Part a

Using numerical and graphical summaries, describe the distribution of nightly sleep hours in nhanes.samp.adult.

Part b

Based on the distribution of nightly sleep hours in the sample, does it seem that the population mean nightly sleep hours may be outside the range defined as adequate (7 - 9 hours)?

1.2.2 Calculate a 95% confidence interval for nightly sleep hours using nhanes.samp.adult and interpret the interval

You can either use the math from class to calculate this OR the t.test() function.

1.2.3 Conduct a hypothesis test to assess whether on average, American adults are getting enough sleep. Let \(\mu_0\) be 8 hours, the midpoint of the range defined as adequate.

Please make sure to include all hypothesis test steps and make sure conditions are met (think CLT). There is additional information on expectations of hypothesis tests in the directions.