Hi @B.Rabbit,
That’s the difference b/w confidence interval and prediction interval.
predict(linefit4, newdata, interval="confidence", level = .90) predict(linefit4, newdata, interval="predict", level = .90)
There is a difference b/w the output you will get from the above two line of code. So what’s the difference exactly? The first one is trying to identify the confidence interval of mean of the values which you can expect by the new data. But the 2nd line is predicting the confidence interval of exact value which you can expect by the new data.
You will notice that confidence interval for the 2nd line of code is wider than the first one. Why is that? Because in linear regression the average of the error terms is equal to zero. But for the 2nd line of prediction interval the model is adding error term into it because its non zero for a single value.
Confidence interval y = mean(Beta0) + mean(Beta1) * X + mean(Error), here mean(Error) = 0
Prediction interval y = Beta0 + beta1*X + error, here error is non zero
Hope this will help in understanding the text.
Regards,
Aayush