---
title: "Final Exam"
author: "Insert Name"
date: "Math 141, Spring 2022"
output:
  pdf_document
urlcolor: blue
---

```{r setup, include=FALSE}
# Do not modify this chunk.
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
library(knitr)
library(moderndive)
library(infer)
```




## Instructions

1. Download the Final Exam .Rmd Template (this file).

2. Work through the exam questions in the .pdf file on [Gradescope](https://www.gradescope.com/courses/227442), recording your answers in the .Rmd template, and submit the document as a knitted .pdf file with your answers on Gradescope. Only what appears in the .pdf file will be graded, so if what you see in the .pdf doesn't reflect what you intend for the answer, modify your .rmd file so the .pdf reflects your answer.

3. You may take up to 180 minutes to complete this exam. You may start the exam at any time, but you must cease working and submit your .pdf file 180 minutes after you begin. You should plan to spend up to 165 minutes on the exam itself, and should use the remaining 15 minutes to knit the document and submit. You will be unable to submit the assignment to gradescope after this time has elapsed. If you have academic accommodations permitting additional time on the exam, we will discuss how these accommodations will be implemented via email.

4. You may reference your Lab and Homework Assignments (both the versions you submitted and the comments you received), your course notes, textbooks (both *ModernDive* and *Intro to Modern Statistics*), lecture slides, and lecture videos. 

5. You may also reference any built-in help functions in R (for example, you may look at the results of typing `?ggplot` into the console or the cheat sheets on the help menu). 

6. You **MAY NOT** reference any other physical or online sources, repost any questions from this exam, or receive help on this assignment from others in any way. Failure to abide by this policy is an Honor Code violation.

7. If you have technical questions, send them to Nate as a direct message on Slack. For equity reasons, I will not answer conceptual or clarifying questions. Since I may be unable to answer your question during the time frame you are taking the exam, document the issue on the exam and then move on to the next problem.

8. Knit your document early and often! If a code chunk is preventing you from knitting the document and you are unable to resolve the problem, replace `{r}` at the top of the code chunk with `{r eval = F, echo = T}`. The code will not run, but will be printed in your .pdf which can possibly earn some partial credit.

9. For each problem, put your solution between the bars of red stars.


## Data

This exam will make use of one data set. Perform some preliminary data exploration to understand the distribution of each variable, along with the relationships among the variables. 

To facilitate exploration, you may want to make a copy of this .Rmd file called `Final_Scratchwork` where you can make changes to the data without impacting the version of this template you will use to submit your exam.



### Data

The National Health and Nutrition Examination Survey (NHANES) is a program of studies designed to assess the health and nutritional status of adults and children in the United States. The survey is unique in that it combines interviews and physical examinations. NHANES is a major program of the National Center for Health Statistics (NCHS). NCHS is part of the Centers for Disease Control and Prevention (CDC) and has the responsibility for producing vital and health statistics for the Nation.

The NHANES program began in the early 1960s and has been conducted as a series of surveys focusing on different population groups or health topics. The survey examines a nationally representative sample of about 5,000 persons each year.

The NHANES interview includes demographic, socioeconomic, dietary, and health-related questions. The examination component consists of medical, dental, and physiological measurements, as well as laboratory tests administered by highly trained medical personnel.

A description of variables in the `NHANES` data set can be viewed by running the following code:

```{r eval = F, echo = F}
library(NHANES)
?NHANES
```

The full NHANES data set contains 10,000 observations on 76 variables corresponding to the years 2009 - 2012. However, for this exam, we will work with a subset of this data, which can be loaded with the following code:

```{r message = F, warning = F}
NHANES_exam <- read_csv("https://reed-statistics.github.io/math141s22-wells-website/data/NHANES_exam.csv")
```



The original NHANES data set uses a complex survey design and survey weights that oversample certain subpopulations. However, our particular `NHANES_exam` dataset resamples from the original data according to the survey weights in order to undo the effects of oversampling. As a result, for the purposes of this exam, we may treat the survey data as if it were a simple random sample from the American population.





## Exam

Write your answers to questions in the FinalExam.pdf between the bars of red stars below. You may copy and paste the questions from the .pdf file into the space below (but you do not need to).


### Problem 1




*************************************************************





*************************************************************





### Problem 2




*************************************************************





*************************************************************







### Problem 3




*************************************************************





*************************************************************








### Problem 4




*************************************************************





*************************************************************





### Problem 5




*************************************************************





*************************************************************


