[R] predict.lm if regression vector is longer than predicton vector

frauke fhoss at andrew.cmu.edu
Wed Oct 3 16:37:15 CEST 2012


Hi everybody, 

recently a member of the community pointed me to the useful predict.lm()
comment. While I was toying with it, I stumbled across the following
problem. 
I do the regression with data from five years. But I want to do a prediction
with predict.lm for only one year. Thus my dataframe for predict.lm(mod,
newdata=dataframe) is shorter than the orginial vector that I did the
regression with. It gives you the following error:
Warning message:
'newdata' had 365 rows but variable(s) found have 1825 rows 
Of course I can extend the new dataframe with a few thousands NAs, but is
there a more elegant solution?

Thank you! Frauke



--
View this message in context: http://r.789695.n4.nabble.com/predict-lm-if-regression-vector-is-longer-than-predicton-vector-tp4644881.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list