# Use regressors in an STL forecast

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'?

-

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.