Hi, I have a question about predicting new values from a fitted model in R. For example, if i fit a linear model fit<-lm(y~x) predict(fit) will give the fitted values for each x. I am wondering if there is a way to do some prediction of the fitted for some new values of x that are not in the data points? for example, x=0.5 is not in the original data (not a datapoint), is there a way to predict the fitted value corresponding to x=0.5 easily? Thank you! [[alternative HTML version deleted]]
Jorge Ivan Velez
2008-Apr-25 23:50 UTC
[R] R question about prediction from a fitted model
Hi Lisa, See examples in ?predict.lm HTH, Jorge On Fri, Apr 25, 2008 at 7:47 PM, Lisa <sangwl@gmail.com> wrote:> Hi, I have a question about predicting new values from a fitted model in R. > > For example, if i fit a linear model > > fit<-lm(y~x) > > predict(fit) will give the fitted values for each x. > > I am wondering if there is a way to do some prediction of the fitted for > some new values of x that are not in the data points? > > for example, x=0.5 is not in the original data (not a datapoint), is there > a > way to predict the fitted value corresponding to x=0.5 easily? > > Thank you! > > [[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. >[[alternative HTML version deleted]]