[R] predicting values from multiple regression
Ista Zahn
izahn at psych.rochester.edu
Sun Mar 20 20:48:30 CET 2011
Hi Anna,
On Sun, Mar 20, 2011 at 2:54 PM, Anna Lee <ana-lee at web.de> wrote:
> Hey List,
>
> I did a multiple regression and my final model looks as follows:
>
> model9<-lm(calP ~ nsP + I(st^2) + distPr + I(distPr^2))
>
> Now I tried to predict the values for calP from this model using the
> following function:
>
> xv<-seq(0,89,by=1)
> yv<-predict(model9,list(distPr=xv,st=xv,nsP=xv))
The second argument to predict.lm is newdata, which should be a
data.frame. see ?predict.lm.
Beyond that though, I'm not sure what you are trying to accomplish.
The way you've set this up you would get predicted values for cases
like
distPr st nsp
0 0 0
1 1 1
2 2 2
. . .
89 89 89
Is that really what you want?
Best,
Ista
>
> The predicted values are however strange. Now I do not know weather
> just the model does not fit the data (actually all coefficiets are
> significant and the plot(model) shows a good shape) or wether I did
> something wrong with my prediction command. Does anyone have an
> idea???
>
> --
>
>
> Thanks a lot, Anna
>
> ______________________________________________
> R-help at 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.
>
--
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org
More information about the R-help
mailing list