How to do it...

Perform the following steps to predict values with multiple regression:

  1. Fit a linear model with the income, prestige, and women variables:
        > model = lm(income ~ prestige + women, Prestige)  
  1. Assign values to be predicted into newdata:
        > newdat = data.frame(prestige = c(75,80), women=c(14,13))
  1. 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
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset