How to correctly weight predicted values from a fitted linear model?

I am using R to fit a linear model.

My code is:

rating_lm <- lm(rating\$flow ~ I(rating\$raw^2) + rating\$raw, data = rating, weights = 1/(rating\$flow)

I then use the following code to get prediction intervals:

b <- predict(rating_lm, interval = "prediction")


The graph below shows: the fitted line (red line), the data points and the prediction intervals (blue lines).

I used the weighting 1/rating\\$flow because we are much more confident in the low measured Y values.

I need to use the fitted linear model in a predictive way with new X data. However, when doing this, I have found that the predicted intervals for the new data are not close to those of the fitted model.

My question is: how can I ensure that the new predicted values, have the same (or very similar), predicted intervals as the fitted model?

• Have you tried specifying the weights in the predict function? The help documentation for it shows almost your exact same example with some discussion. stat.ethz.ch/R-manual/R-patched/library/stats/html/… – AdamO Jul 27 '12 at 7:18
• Hi. I have looked at specifying weights in the predict function. However, I still cannot get the lower and upper bound predictions for a given X value to be equal to approximately the same values my fitted model would give. If you consider the above chart, my fitted model would suggest that for an X value of 400, Y could be between 3 to 7. However, when predicting Y values from new X values, an X value of 400 does not give a range of Y values corresponding to 3 to 7. – mjburns Jul 27 '12 at 8:15