[R] predict.lm variables found question

2006-11-09 Thread Larry White
hello,

I'm trying to predict some values based on a linear regression model.
I've created the model using one dataframe, and have the prediction
values in a second data frame (call it newdata). There are 56 rows in
the dataframe used to create the model and 15 in newdata.

I ran predict(model1, newdata) and get the warning: 'newdata' had 15
rows but variable(s) found have 56 rows

When i checked help(predict.lm) I found this:

Variables are first looked for in newdata and then searched for in
the usual way (which will include the environment of the formula used
in the fit). A warning will be given if the variables found are not of
the same length as those in newdata if it was supplied. 

My questions are - how can I just get predicted values for the 15 rows
in the newdata data frame, and if that's not possible, how can I tell
which of the 56 predicted values are derived from newdata only, if
any.

Thanks in advance for your help.

Larry

__
R-help@stat.math.ethz.ch 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.


Re: [R] predict.lm variables found question

2006-11-09 Thread Peter Dalgaard
Larry White [EMAIL PROTECTED] writes:

 hello,
 
 I'm trying to predict some values based on a linear regression model.
 I've created the model using one dataframe, and have the prediction
 values in a second data frame (call it newdata). There are 56 rows in
 the dataframe used to create the model and 15 in newdata.
 
 I ran predict(model1, newdata) and get the warning: 'newdata' had 15
 rows but variable(s) found have 56 rows
 
 When i checked help(predict.lm) I found this:
 
 Variables are first looked for in newdata and then searched for in
 the usual way (which will include the environment of the formula used
 in the fit). A warning will be given if the variables found are not of
 the same length as those in newdata if it was supplied. 
 
 My questions are - how can I just get predicted values for the 15 rows
 in the newdata data frame, and if that's not possible, how can I tell
 which of the 56 predicted values are derived from newdata only, if
 any.

You need to have all your predictors represented in newdata. You seem
to have at least one of them missing (a typo in a variable name could
do that). 

-- 
   O__   Peter Dalgaard Ă˜ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
R-help@stat.math.ethz.ch 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.