Exercise

Prediction Interval

In the last exercise you used your equation (\(liking = 1.501 + 0.778 * money\)) to make a prediction about how much someone would like them if you gave them 2.5 units of money.

We expect that the amount the person would like us would be close to our prediction, but would likely be a little off due to error. We can calculate the interval that the persons liking would fall in though a prediction interval!

The formula for a prediction interval is $$\hat{yi} \pm margin of error$$ where the margin of error is $$2 * se{res}$$. Here, the standard error is approximately the standard deviation of the residuals. Luckily for us, R has a function to do this for us.

We use the predict() function, which takes an object containing your model, a data frame containing the value you would like an interval for, an argument containing the size of the interval and the argument interval = "predict". For example, for a 90% prediction interval we might put: predict(model, newdata, level = 0.9, interval = "predict").

Let's try to find the 95% prediction interval for our prediction that if you give someone 3 units of money, they will like you an amount of 3.835.

Instructions

100xp

In your script, add a line of code to calculate the 95% prediction interval for the amount someone from our sample would like us if we gave them 3 units of money.