Run the following to load a dataset that records various data about mammals, including brain weight. The brain weight is given in grams, the body weight in kilograms, and the gestation weight in days.

```
library(Sleuth3)
brains <- case0902
```

(Note: if `install.packaegs("Sleuth3")`

doesnâ€™t work, try `install.packages("Sleuth3", repos="http://R-Forge.R-project.org")`

instead)

### Problem 1: Linear Regression

#### Part 1(a)

Suppose you want to use linear regression to investigate the relationship between brain weight and body weight. Find a way to transform the variables that would allow you to do that. (Hint: try taking the log of *both* variables. See Tuesdayâ€™s lecture where we explored the relationship between gdp per capita and life expectancy). Use a scatterplot to assess whether a relationship is linear.

#### Solution

A plot where we take the log of both variables works nicely.

```
ggplot(brains, mapping = aes(x = log(Body), y = log(Brain))) +
geom_point() +
geom_smooth(method = "lm")
```

#### Part 1(b)

Produce the diagnostic plots. Display and investigate outliers, if any. (See Tuesdayâ€™s lecture on the relationship between gdp per capita and life expectancy)

Letâ€™s now plot the diagnostic plots

#### Solutions

```
library(ggfortify)
fit <- lm(log(Brain) ~ log(Body), data = brains)
autoplot(fit)
```