Re: [R] predicting values from multiple regression

From: Ista Zahn <izahn_at_psych.rochester.edu>
Date: Sun, 20 Mar 2011 15:48:30 -0400

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

______________________________________________
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.
Received on Sun 20 Mar 2011 - 19:51:56 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 20 Mar 2011 - 20:50:23 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive