Tell me more ×
Cross Validated is a question and answer site for statisticians, data analysts, data miners and data visualization experts. It's 100% free, no registration required.

I'm using a STL decomposition to make forecasts in R (using the forecast package), but I'm not sure how to incorporate my regressors into the model.

I'm using the forecast function:

f = forecast(stl(my.data, s.window = 'periodic'), h = 12, method = 'arima')

The function above accepts the xreg parameter, but how do I specify the model regressors and the forecast regressors?

Is there a function that does this or do I have to do it 'by hand'?

share|improve this question

1 Answer

up vote 1 down vote accepted

You will have to do it by hand. The forecast.stl() function fits an ARIMA model to the de-seasonalized data, forecasts it, and then re-seasonalizes the forecasts. It is not set up to handle model regressors. If you include an xreg term it will use it when fitting the model, but then it will complain when forecasting because it won't know how to deal with future regressors.

forecast.stl() is a very simple function and could easily be modified to handle regressors. All you need is one extra argument for future regressors, and then change the line that calls forecast() with the fitted ARIMA model to include the future regressors.

share|improve this answer
Thanks, i'll work on that modification. – Fernando Aug 16 '12 at 12:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.