---
title: "Final Exam Review"
date: "Math 141, Spring 22"
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)
```


For extra practice, several review problems are provided on this Review Sheet. However, they are not comprehensive, so do not limit your studying to just these problems. While the problems are intended to match the difficulty of those on the exam, the length of this review set does not represent the actual length of the exam. Although detailed solutions will not be posted, you are welcome to talk to me about any of them before the test. 


### Problem 1 

Run the following code to load the `HollywoodMovies` data set.
```{r}
library(Lock5Data)
data(HollywoodMovies)
```

This data set contains information on the opening weekend gross income (\texttt{OpeningWeekend}), Rotten Tomatoes critics rating (\texttt{RottenTomatoes}), the Rotten Tomatoes audience score (\texttt{AudienceScore}), the number of theaters showing the movie on opening weekend (\texttt{TheatersOpenWeek}), the production budget (\texttt{Budget}) and the year the movie was released (\texttt{Year}).

a. Create a multilinear model predicting gross opening weekend income using `RottenTomatoes`, `AudienceScore`, `TheatersOpenWeek`, `Budget` and `Year`. Display the output using `get_regression_table` and write down the model's equation.

b. Interpret the slopes of each explanatory variable in context of the model.

c. Create appropriate data visualizations to assist in determining whether inference is reasonable for this multilinear model.

d. Determine which explanatory variables are significant predictors of the opening weekend gross. 

e. For any variables that are not significant predictors, create a simple linear regression model for that variable and the response. Is the variable a significant predictor in the simple linear model? If so, explain why this doesn't contradict your findings in the previous part.






### Problem 2

Run the following code to load the \texttt{CommuteAtlanta} data set.

```{r}
library(Lock5Data)
data(CommuteAtlanta)
```

This data set shows information both on commute distance (in miles) and time (in minutes) for a sample of 500 Atlanta commuters. Suppose we want to build a model for predicting the commute times based on distance.

a. Fit a simple linear model and write down the regression equation.

b. What time does the fitted model predict for a 20-mile commute?

c. Create a scatterplot of the relationship between Distance and Time.

d. Produce a histogram of the distribution of residuals. Comment on whether the normality condition is satisfied.

e. Produce a residual plot and comment on whether the residuals demonstrate constant variability.

f. Create the 95\% confidence interval for the slope of the regression line and interpret in the context of the problem. 

g. Note that the speed limit on most Atlanta freeways is about 55mph. Explain why the confidence interval may not be realistic, and discuss what feature of the model may have led to this.



### Problem 3

How accurate are lie detectors? The following data involve participants who read either deceptive material or truthful material while hooked to a lie detector. Run the following code to generate the data:
```{r}
lie_detector<- tibble( lying = rep(c( "yes", "no"), c(48, 48 )),
detector = rep( c("positive", "negative", "positive", "negative"),c(31, 17, 27, 21 )))
```

The `lying` variable indicates whether the person read deceptive material, while the `detector` variable indicates whether the detector said the person was lying.

a. Create an appropriate graphic comparing the proportion of people the detector indicated were lying in each group.

b. Find and interpret the $90\%$ confidence interval for the proportion of times the lie detector accurately detects a person lying.

c. Test to see if there is evidence that the lie detector says a person is lying more than $50\%$ of the time, regardless of what the person reads.

d. Test to see if there is a difference in the proportion the lie detector says is lying depending on whether the person is lying or telling the truth.

e. Find and interpret the $95\%$ confidence interval for the difference in the proportion the lie detector says is lying between those lying and those telling the truth.



### Problem 4

For each situation given below, identify which of the listed tests is most appropriate. If multiple tests are appropriate, list them all.

#### Tests

- Chi-square test for goodness of fit.
- Chi-square test for independence.
- ANOVA for difference in means
- Test for correlation
- Multiple Linear Regression Model
- $2$-sample $t$ test
- $2$-sample $z$ test
- $1$-sample $t$ test
- $1$-sample $z$ test

#### Situations

a. Three different drugs are being tested on patients who have leukemia and the response variable is white blood cell count.

b. Researchers want to determine whether phone owners do most of their online browsing on their phone. 200 randomly selected phone owners will be surveyed, and the response variable will be whether the respondent use phone for a majority of online browsing.

c. Three different drugs are being tested on patients who are HIV-positive and the respond variable is whether or not the person develops AIDS.

d. Data are collected from 50 towns on number of wood-burning houses and number of people with asthma, and the study is investigating whether there is a linear relationship between the two.

e. Lawmakers want to determine whether support for capital punishment in the US has changed over the last 30 years. They survey a random sample of 2815 individuals and ask whether each favors capital punishment, and compares the results to the responses to the same question in a 1974 survey of 1410 random individuals.

f. The admissions office at a university uses data from high school transcripts such as number of honors courses, number of AP courses, grade in 11th grade English, grade in 9th grade math to develop a model to predict college GPA.

g. A polling agency working in a large city knows the distribution of ethnicity in the city population. They select a sample of 2000 residents and would like to check that the distribution of ethnic groups within their sample is not significantly different from the proportion in the city as a whole.

h. A sabermetrics group wants to know whether American football teams benefit from ``Home Field Advantage.'' A random sample of 20 games from the 2018 regular season is selected, and the group measures the average number of points scored by the home team. In a separate sample of 20 games, the group measured the average number of points scored by the away team.

i. A test is being conducted to see if the average time it takes for a case to go to trial differs between counties in a state. Seven counties will be included and the data will include a random sample of 25 cases from each county.

j. The FDA recommends that the typical adult consume at least 25 grams of fiber per day. To determine whether Americans are following this advice, statisticians survey 200 Americans and ask each to estimate their typical daily fiber consumption. 

k. A test is being conducted to see if the proportion of cases that get settled out of court is different between the different counties in the state. Seven counties will be included and the data will include a random sample of 60 cases from each county.


### Problem 5

The Comprehensive Assessment of Outcomes in Statistics (CAOS) exam is an online multiple-choice test on concepts covered in a typical introductory statistics course. Students can take a pretest version before instruction and then a posttest version after instruction. Scores on the pretest and posttest for a random sample of 10 students with one instructor can be obtained by running the following code:

```{r}
library(Lock5Data)
data(CAOSExam)
```

a. Explain why it would not be appropriate to use $z$-procedures for statistical inference on this model.

b. Was the data gathered using matched-pairs design, or by collecting 2 independent samples?

c. What information would you need to know about the population in order to ensure it is appropriate to use $t$-procedures for statistical inference on this sample?

d. Compute and interpret a $95\%$ confidence interval for the improvement in mean CAOS scores between the two exams.

e. The developers of the CAOS exam give benchmark data based on a very large number of students taking the pretest and posttest. The mean score on the pretest was 44.9 and the mean on the posttest was 54.0. Treat these values as population means, is there evidence at the $5\%$ level that the instructor's students have a mean score on the posttest that is higher than the overall average?

f. Using the parameters from the previous part, can we conclude that the instructor began with stronger students than average?

g. Finally, can we conclude, at the $5\%$ significance level, that the mean \textit{improvement} from pretest to posttest for students with this instructor is higher than the overall norm?



### Problem 6


Suppose that you hold a coin vertically on edge, flick one side to make it spin, then see if it settles on heads or tails. Is this a fair process? To investigate, a student spun the same penny 200 times and recorded 84 heads and 116 tails. Run the following code to load the results:


```{r}
coin<- tibble( result = rep(c( "heads", "tails"), c(84, 116 )))
```

To simulate flipping a fair coin, you can repeatedly sample with replacement from a population consisting of 1 head and 1 tails. The following code simulates 5 sequences of 10 coin flips using a fair coin:

```{r}
population<- tibble(result = c("heads", "tails"))
flips_10_5<- population %>% rep_sample_n(size = 10, reps = 5, replace = TRUE)
```

a. Modify the above code in order to simulate the distribution of the proportion of times a fair coin lands heads when flipped 200 times. Plot the distribution, describe its shape, and compute its exact mean and standard deviation.

b. Based on the graphic and/or summary statistics, does it seem plausible to obtain 84 / 200 heads, if the spinning method were truly fair?

c. Perform a hypothesis test to verify your conclusion. For extra practice, use both simulation methods and theory-based methods to conduct the test.

### Problem 7

Given a specific sample to estimate a specific parameter from a population, what are the expected similarities and differences in the corresponding population distribution, sampling distribution and bootstrap distribution? In particular, for each aspect of a distribution listed below, indicate whether the values for the three distributions are expected to be approximately the same or different. If they are different, explain how.

a. The shape of the distribution.

b. The center of the distribution.

c. The spread of the distribution.

d. What one value in the distribution represents.

e. The information needed in order to create the distribution.


### Problem 8

For each of the following questions, choose the type(s) of variable(s) that the question pertains to, the appropriate graphs that could be used to visualize the data, and the appropriate type of statistic that could be used to summarize the data.

a. What is the current public opinion on assault rifle bans? Do a majority support it?

b. Is there an association between the diameter of a plate used and the amount of food consumed?

c. Do people who take a daily multivitamin live longer than those who do not?

d. How many hours do Reed college students sleep each night?

e. Are men or women more likely to support restrictions on abortion?

f. Do college graduates who take at least 1 statistics course earn more 1 year after graduation than those who do not?

g. How far away are stars in the Milky Way galaxy?

h. What percentage of football field goal attempts from 35 yards or more are successful?

i. Is there a linear relationship between how long a child is breastfed and the child's weight at age 2?

j. Is there an association between the color of a car and whether that car has been pulled over for speeding?


### Problem 9

In a study investigating how students use laptops in class, researchers recruited 45 student volunteers at one university. On average, students cycled through 65 active windows per lecture. The researchers developed a rubric to distinguish productive class-related applications from distracting ones, and recorded the proportion of distracting windows active, and the percent of time that was spent on distracting windows. They found, on average 62\% of open windows were distracting, and that students had  distracting windows open 42\% of the time. Finally, the study measured how students performed on a test of related material, and concluded that students who spent more time on distracting websites generally had lower test scores.

a. What is the implied population of this study? What variables and parameters did the researchers want to study?
b. What was the sampling method?
c. Is this an experiment or observational study?
d. From the information given, explain why we cannot conclude that students who spend more time on distracting websites during class will have lower grades as a result.
e. Discuss how the investigation could be modified in order to make a causal conclusion about the entire population of students. 