"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

______________________________________________
[email protected] 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.

Reply via email to