Exercise

# Prediction

Once we have fit a regression model, we can use it to make predictions for unseen observations or retrieve the fitted values. Here, we explore two methods for doing the latter.

A traditional way to return the fitted values (i.e. the \(\hat{y}\)'s) is to run the `predict()`

function on the model object. This will return a vector of the fitted values. Note that `predict()`

will take an optional `newdata`

argument that will allow you to make predictions for observations that are not in the original data.

A newer alternative is the `augment()`

function from the `broom`

package, which returns a `data.frame`

with the response varible (\(y\)), the relevant explanatory variables (the \(x\)'s), the fitted value (\(\hat{y}\)) and some information about the residuals (\(e\)). `augment()`

will also take a `newdata`

argument that allows you to make predictions.

Instructions

**100 XP**

The fitted model `mod`

is already in your environment.

- Compute the fitted values of the model as a vector using
`predict()`

. - Compute the fitted values of the model as one column in a
`data.frame`

using`augment()`

.