Confidence Interval for MLR
Assume that the error term ϵ in the multiple linear regression (MLR) model is independent of xk (k = 1, 2, ..., p), and is normally distributed, with zero mean and constant variance. For a given set of values of xk (k = 1, 2, ..., p), the interval estimate for the mean of the dependent variable, , is called the confidence interval.
In data set stackloss, develop a 95% confidence interval of the stack loss if the air flow is 72, water temperature is 20 and acid concentration is 85.
We apply the lm function to a formula that describes the variable stack.loss by the variables Air.Flow, Water.Temp and Acid.Conc. And we save the linear regression model in a new variable stackloss.lm.
> stackloss.lm = lm(stack.loss ~
+ Air.Flow + Water.Temp + Acid.Conc.)
Then we wrap the parameters inside a new data frame variable newdata.
We now apply the predict function and set the predictor variable in the newdata argument. We also set the interval type as "confidence", and use the default 0.95 confidence level.
fit lwr upr
1 24.582 20.218 28.945
> detach(stackloss) # clean up
The 95% confidence interval of the stack loss with the given parameters is between 20.218 and 28.945.
Further detail of the predict function for linear regression model can be found in the R documentation.