[R] forecasting linear regression from lagged variable

AaronB aaron at communityattributes.com
Wed Nov 30 22:40:04 CET 2011


I'm currently working with some time series data with the xts package, and
would like to generate a forecast 12 periods into the future. There are
limited observations, so I am unable to use an ARIMA model for the forecast.
Here's the regression setup, after converting everything from zoo objects to
vectors.

hire.total.lag1 <- lag(hire.total, lag=-1, na.pad=TRUE)
lm.model <- lm(hire.total ~ case.total + hire.total.lag1)

hire.total is a monthly historical time series from Jan 2010 to Oct 2011.
hire.total.lag1 is the same time series, lagged 1 period backwards.
case.total is a monthly historical time series from Jan 2010 to Oct 2011,
plus forecasts forward another 12 periods.

I'd like to use this model to forecast hire.total for the next period, and
use each successive prediction of hire.total as the lag1 "observation" for
the next prediction. I have enough "observed" values for case.total to
forecast out as far as I need. I might be able to construct this using a
loop, but I have a feeling it will be messy and slow. Any suggestions?







--
View this message in context: http://r.789695.n4.nabble.com/forecasting-linear-regression-from-lagged-variable-tp4125091p4125091.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list