---
title: "Homework 6"
subtitle: "Psychology 2812B FW22"
output: html_document
---

# Lab Component

## 1. Parenthood dataset

Load the `parenthood.csv` dataset using:

```{r, message=FALSE, warning=FALSE}
library(tidyverse)
parenthood <- read_csv("https://www.gribblelab.org/2812/data/parenthood.csv")
glimpse(parenthood)
```

The dataset contains 100 observations of 4 variables:

- `dan.sleep`: how much sleep Daniella had that night
- `baby.sleep`: how much sleep Daniella's baby had that night
- `dan.grump`: a grumpiness index of how grumpy Daniella was that day
- `day`: the day

## 2. Examine correlations

Use `ggpairs()` from the `GGally` package to visualize the correlations between each pair of variables in the dataset. Describe what you see and what it means.

```{r}
# your code goes here
```

> your text goes here

## 3. Model Daniella's grumpiness

Fit a "full model" `mod.full` in which you predict `dan.grump` based on the other three variables: `dan.sleep`, `baby.sleep`, and `day`. Show the model `summary()` and describe and interpret:

- the overall Multiple R-squared
- the overall p-value for the model as a whole
- the model coefficients (called "Estimate" in the `summary()` output)

```{r}
# your code goes here
```

> your text goes here

## 4. Plot model coefficients

Plot the slopes (model coefficients) relative to zero to better visualize them.

```{r}
# your code goes here
```

## 5. Check assumptions

Check normality by producing a Q-Q plot. Interpet.

```{r}
# your code goes here
```

> your text goes here

Check linearity by producing a plot of residuals and interpret.

```{r}
# your code goes here
```

> your text goes here

Check for normality using `shapiro.test()`. Pass `shapiro.test()` the residuals of your model using `residuals()`

```{r}
# your code goes here
```

> your text goes here

Check for heteroscedasticity by reference to the residual plot above. Interpet.

> The variance of the residuals is not different across the range of fitted values so we can assume we have not violated the homoscedasticity assumption.

Check for heteroscedasticity using `ncvTest()` from the `car` package and interpet.

```{r}
# your code goes here
```

> your text goes here

## 6. Refine the model

Use the `step()` procedure with the `direction=both()` option to test if you can refine the model further by eliminating any variables from the full model that don't account for unique portions of variance in `dan.grump`. Start the procedure from the full model.

Describe the output of the `step()` procedure and what it means. Describe the refined model and how it differs (if it differs) from the full model, and why.

```{r}
# your code goes here
```

> your text goes here

## 7. Predict

Using your refined model, predict how grumpy Daniella will be (i.e. the grumpiness index `dan.grump`) on a future day if she obtains 6.0 hours of sleep.

```{r}
# your code goes here
```

> your text goes here

With reference to the model coefficient(s), how much does the `dan.grump` index change and in what direction, for every additional hour of sleep?

> your text goes here


# Home Component

You are being considered for a position as the new coach of a basketball team. You just finished a meeting with the owners, who are interested in replacing the existing coach because the team's performance has been going downhill. The owners of the team have attributed this downward trend to poor recruitment of new players, who have been poor performers. The owners tell you that their analysis of the data from the previous seasons indicates that one particularly weak area has been "field goals" (when a player attempts to score a basket from the 3-point line or beyond). The team's players, in particular the new recruits, tend to be poor at field goals. The problem is, as the owners tell you, that data are not available on field goal percentages, for players who are candidate recruits; so when it comes time to recruit new players there is no easy way to pick new recruits who are good field goal shooters. The owners tell you that they have been collecting data for years and years on the new recruits and their field goal percentages, and a series of other measures that are available for the new potential recruits as well. She suggests that "if you can use the historical data to be able to predict who among the potential new recruits will be the best field goal shooters, you are hired!"

In the file called `https://www.gribblelab.org/2812/data/bball.csv` you will find historical data on 105 previous recruits. The variables are:

- GAMES : # games played in previous season
- PPM : average points scored per minute
- MPG : average minutes played per game
- HGT : height of player (centimetres) 
- FGP : field-goal percentage (% successful shots from 3-point line) 
- AGE : age of player (years) 
- FTP : percentage of successful penalty free throws 

In the file `https://www.gribblelab.org/2812/data/bball2.csv` you
will find data on 5 potential new recruits.

## 8. Develop a model

Use multiple regression to develop a refined model based on the data in `bball.csv` that will allow you to predict the field goal percentages for the 5 new recruits. Use `summary()` to show the refined model that you propose. Show your work. Explain in words the process you used to arrive at your final model. Describe the influence each variable in your refined model has on predicting `FGP`, with reference to the coefficients (slope parameters).

### Model

```{r}
# your code goes here
```

> your text goes here

### Linearity

```{r}
# your code goes here
```

> your text goes here

### Normality

```{r}
# your code goes here
```

> your text goes here

### Homoscedasticity

```{r}
# your code goes here
```

> your text goes here

## 9. Propose a player

Based on your model, which player will you suggest to the owners that they hire? Explain your decision.

```{r}
# your code goes here
```

> your text goes here

## 10. Precision

Given your model, what is the precision (in units of `FGP`) with which you can predict field goal percentage?

```{r}
# your code goes here
```

> your text goes here

## 11. Age & Height

After giving them your recommendation and explaining your model, the owners ask you "does the player's age have anything to do with this?" Answer with reference to your model.

> your text goes here

"What about the player's height? Would I be better off taking on taller players?" Answer with reference to your model.

> your text goes here

According to the multiple regression model you developed, how many more (or fewer) field goals would a player score if they were 3 inches taller? Explain with reference to your model. Assume 2.54 centimetres per inch.

> your text goes here
