### Name: predict.lm ### Title: Predict method for Linear Model Fits ### Aliases: predict.lm predict.mlm ### Keywords: regression ### ** Examples require(graphics) ## Predictions x <- rnorm(15) y <- x + rnorm(15) predict(lm(y ~ x)) new <- data.frame(x = seq(-3, 3, 0.5)) predict(lm(y ~ x), new, se.fit = TRUE) pred.w.plim <- predict(lm(y ~ x), new, interval="prediction") pred.w.clim <- predict(lm(y ~ x), new, interval="confidence") matplot(new$x,cbind(pred.w.clim, pred.w.plim[,-1]), lty=c(1,2,2,3,3), type="l", ylab="predicted y") ## Prediction intervals, special cases ## The first three of these throw warnings w <- 1 + x^2 fit <- lm(y ~ x) wfit <- lm(y ~ x, weights = w) predict(fit, interval = "prediction") predict(wfit, interval = "prediction") predict(wfit, new, interval = "prediction") predict(wfit, new, interval = "prediction", weights = (new$x)^2) predict(wfit, new, interval = "prediction", weights = ~x^2)