---
title: "Final Exam Template"
author: "Insert Name"
date: "Math 141, Spring 2021"
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 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, and we have discussed these accommodations, I have incorporated the additional time in your assignment.

4. You may reference your Lab Assignments (both the versions you submitted and the comments you received), your course notes, textbooks (both ModernDive and OpenIntro), 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 and Tom as a joint direct message on Slack. For equity reasons, we will not answer conceptual or clarifying questions. Since we maybe 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 2021 World Happiness Report represents a survey of the state of global happiness in the years 2020 and 2021, based largely on data gathered by the Gallup World Poll in 2019 - 2021, and supplemented by data from the COVID Data HUB run by Imperial College London and the YouGov team. The researchers who created the report were interested in analyzing which quality of life factors were most influential in explaining a country's happiness (or unhappiness) level. 

Data from the report can be loaded with the following code:

```{r message = F}
happy <- read_csv("https://reed-statistics.github.io/math141s21/data/happy.csv")
```


The `happy` dataset aggregates sample data from people in 149 countries in order to create population-weighted average scores for each country. The report includes measurements on 6 variables, along with a happiness ranking, for each country. A brief description of the variables in the data set is provided below. *A more detailed description can be found in this [codebook]("https://reed-statistics.github.io/math141s21/files/Happy_Codebook_abridged.pdf"), although note that variables names have been modified in the `happy` dataset from their original form.*

- `Happiness` is the national average happiness score rated on a scale of 0 to 10, with 0 representing the least happiness and 10 representing the greatest happiness.

- `GDP` is the country's Gross Domestic Product per capita in purchasing power parity, and represents the country's mean standard of living. It incorporates differences in cost of living and inflation rates between countries.

- `HLE` is the country's healthy live expectancy at birth, measured in years.

- `Social` support measures the proportion of individuals sampled in the country who responded `yes` to the question "If you were in trouble, do you have relatively or friends you can count on to help you whenever you need them, or not?"

- `Freedom` to make life choices is the national average of responses to the question "Are you satisfied or dissatisfied with your freedom to choose what you do with your life?"

- `Generosity` represents the difference in proportion of that country's respondents who donated to charity in the past month, compared to the average proportion among countries with similar GDP per capita.

- `Corruption` is the national proportion of survey respondents who answered `yes` to the question "Is corruption widespread throughout the government or not?"



## Exam

Write your answers to questions in the Final Exam .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




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





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






### Problem 6




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





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