PA 9: Mystery Animal

Linear Regression

Download starter .qmd template

1 Data

The data contain the weights of a particular animal species before and after a year of eating only roasted duck.

mystery_animal <- read_csv("https://raw.githubusercontent.com/zoerehnberg/STAT331-S23/main/practice_activities/mystery_animal.csv")

2 Visualize the Data

Let’s start by visualizing the data. Create a scatterplot of the weights and fit a linear regression line. Make sure you use good graphic design principles in your plot!

# Create your plot here.

3 Linear Regression

Now let’s look at the model. Fit a linear regression to determine if the Duck Diet is associated with the animal species gaining weight, losing weight, or neither.

# Fit your linear regression model here.

Based on the linear regression model, these animals tend to ____________ weight on the Duck Diet.

4 Residuals

Finally, let’s look at model fit. Extract the residuals (observed value minus predicted value) of your linear model. Plot the residuals versus weight_before.

Tip

There are a few different ways to obtain your residuals. My favorite is the augment() function from the broom package. I like this option because it gives you all of the information from your linear regression in a tidy tibble!

# Extract and plot the residuals here.

5 Canvas Submission: Mystery Animal

What animal do you see in the residual plot?