```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, include = TRUE,
fig.align="center",warnings = FALSE,fig.width = 5,fig.height=3)
```

This take home exam is worth a total of 100 points.  For the problems in which calculations are needed, please include your \texttt{R} code with your answers.  Turn in this exam to Sakai by Friday, May 5 at 3 pm.

1.  The World Health Organization has estimated 12 million deaths occur worldwide, every year due to Heart diseases. Half the deaths in the United States and other developed countries are due to cardio vascular diseases. The early prognosis of cardiovascular diseases can aid in making decisions on lifestyle changes in high risk patients and in turn reduce the complications.

The dataset \texttt{heartdisease.csv} contains information on 3656 complete observations from a study of residents of Framingham, Massachusetts.  Information on the variables can be found at <https://www.kaggle.com/datasets/dileep070/heart-disease-prediction-using-logistic-regression>

a. Create a model predicting probability of 10 year risk of heart disease with only age, currentSmoker, and cigsPerDay as explanatory variables.  

```{r}
```

(i). [3 pts] Interpret the parameter associated with age in the context of the problem.

(ii). [3 pts] Interpret the parameter associated with currentSmoker in the context of the problem.

(iii). [4 pts] Predict the probability of 10 year risk of heart disease for a 30 year old smoker who smokes 5 cigarettes a day.

b. [5 pts] Perform a formal hypothesis test to determine if the logistic regression model for predicting for 10 year risk of heart disease with age, currentSmoker, and cigsPerDay is statistically significant by doing the following tasks.

```{r}
```

c. [5 pts] Perform a formal hypothesis test to determine if adding currentSmoker to a logistic regression model that already includes age and cigarettes per day is statistically significant.

```{r}
```

d. [2 pts] Intuitively, why does your answer in (c) make sense?

e. [5 pts] Determine what is the "best" logistic regression model using backwards selection and AIC as your selection criterion.  Write out the final regression model as a function of the logit of the probability of 10 year risk of heart disease.
```{r}
```

f. [3 pts] What is the log-likelihood of your "best" logistic regression model in (e)?
```{r}
```

2. The following summary is from a linear regression on work-life balance as predicted from the number of hours worked per week for MBA alumni. $$\bar{x} = 14, \bar{y} = 20, s_x^2 = 64, s_y^2 = 100, r = 0.8, n = 25.$$

a. [4 pts] Write the least squares regression line.
```{r}
```

b. [3 pts] What is the predicted work-life balance for an alumnus who works 50 hours per week?
```{r}
```

c. [3 pts] What percent of variation in work-life balance can be explained through its linear relationship with number of hours worked per week?
```{r}
```

d. [4 pts] What are the total sums of squares of the model?
```{r}
```

e. [4 pts] What is the mean squared error of the model?
```{r}
```

f. [4 pts] What are the model sums of squares?
```{r}
```

g. [5 pts] Calculate an appropriate t-statistic and p-value for testing if a simple linear model is statistically significant.
```{r}
```

h. [3 pts] What is the distribution of the test statistic in (g) under the null hypothesis?
```{r}
```


3. The dataset *nfl* contains information about the regular season games from the 2021 regular season, including

- *Week*: The Week the game took place

- *Day*: The Day of the week the game took place

- *Date*: The Date of the game

- *Time*: The time the game started (in Eastern Time)

- *AwayTeam*: The game's away team

- *HomeTeam*: The game's home team

- *YdsDiff*: The difference in the offensive yards between the home team and away team

- *TODiff*: The difference in turnovers between the home team and away team

- *PtsDiff*: The difference in points scored between the home team and away team

a. Suppose we think that the point difference is not dependent on any other explanatory variables.

(i). [2 pts] What do we expect the point differential between a randomly selected home and away team to be?
```{r}
```

(ii). [4 pts] Calculate a 95% confidence interval for the expected point differential.  Interpret this interval in the context of the problem.
```{r}
```

(iii). [4 pts] Bookmakers often maneuver their point spreads to account for the belief that, on average, home teams win by two points.  Perform a hypothesis test on the counterargument that home teams do not, on average, win by three points.  Be sure to formally state all the necessary information to perform a formal hypothesis test.  Assume $\alpha = 0.05$.
```{r}
```

(iv). [2 pts] Compare your answers to part (b) and (c).  Are they compatible?  Explain why or why not.

b. Now, suppose we want to predict point differential based on yard differential, turnover differential, and day of the week the game was played.

(i). [4 pts] Calculate a least squares regression line using \texttt{R}.  Formally state the regression line.
```{r}
```

(ii). [2 pts] Interpret the parameter associated with turnover differential in the context of the problem.

(iii). [3 pts] Report and interpret the r-squared in the context of the problem.
```{r}
```

(iv). [4 pts] Calculate and interpret a 90% prediction interval for point differential for a game played on Monday with a 50 yard difference, 1 turnover difference.
```{r}
```

(v). [3 pts] Is there an issue of multicollinearity with this model?  Explain why or why not.
```{r}
```

(vi). [2 pts] Determine if the assumptions of homoskedasticity and normality are violated.
```{r}
```

4. [10 pts] Write any number.

