When in doubt, first consult the included online help. ?predict.lm
Offers this example, which seems to meet the request 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") (note that all the functions come with R and are loaded by default) And predict.lm can be found in the "See also" section of ?predict. -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 On 2/25/14 2:57 PM, "varin sacha" <varinsa...@yahoo.fr> wrote: >Hi, >I have realized a multiple linear regression. >To know how well my model does in terms of prediction, I can compute >prediction intervals bands and decide if they are narrow enough to be of >use. If they are too wide, then they probably are not useful. > >So what I am trying to do is : >Theoretically I know that I can use the "predict" command in R to >generate the prediction interval for a set of points. The idea is to find >the linear regression using the lm command. Then I can use the predict >command to get the prediction interval for a set of points in the domain. >Then I plot out the predicted values as well as the upper and lower >limits of the prediction intervals for those values. >My problem is to practice what I theoretically know, especially using R. > >My linear model is the following : >LinearModel.1 <- lm(GDP.per.head ~ Competitivness.score + Quality.score, >data=Dataset) >summary(LinearModel.1) >predict(LinearModel.1, se.fit = FALSE, scale = NULL, df = Inf,interval = >c("none", "confidence", "prediction"),level = 0.95, type = c("response", >"terms"),terms = NULL) > >Could you please help me with my R codes ? > >Thanks for your precious help, > [[alternative HTML version deleted]] > ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.