Perform the following steps to predict values with multiple regression:
- Fit a linear model with the income, prestige, and women variables:
> model = lm(income ~ prestige + women, Prestige)
- Assign values to be predicted into newdata:
> newdat = data.frame(prestige = c(75,80), women=c(14,13))
- Compute the prediction result using the confidence interval with level set as 0.95:
> predict(model, newdata = newdat)
Output:
1 2
12194.80 13072.56
Compute the prediction result using this prediction interval:
> predict(model, newdata = newdat, interval="predict")
Output:
fit lwr upr
1 12194.80 6994.903 17394.69
2 13072.56 7847.050 18298.06