[R] predict.lm if regression vector is longer than predicton vector
S Ellison
S.Ellison at LGCGroup.com
Wed Oct 3 17:10:31 CEST 2012
> Of course I can extend the new dataframe with a few thousands
> NAs, but is there a more elegant solution?
That should not be necessary: predict.lm should work on any number of newdata rows, whether longer or shorter than the original data set.
However, the help page for predict.lm says (among other things)
"If the fit is rank-deficient, some of the columns of the design
matrix will have been dropped. Prediction from such a fit only
makes sense if 'newdata' is contained in the same subspace as the
original data. That cannot be checked accurately, so a warning is
issued."
Could that be the situation you are in? If it is, it's not the new data that causes the problem, but the original fit.
S Ellison
*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}
More information about the R-help
mailing list