For all my forecast models (arima with Fourier, tbats, ets and stlf from the "forecast" package in R) I use the following:

model <- auto.arima(x, xreg=fourierf(x, K=y, h=52)) 


model <- tbats(x) 


model <- ets(x)


model <- stlf(x)


forecast(model, h=52)

h=52 as that takes my data to the end of this quarter.

I also used multiple regression separately.

I then decided to use ARIMA with the dummy variables I'd used in my regression model:

model <- auto.arima(x, xreg=dummy)


forecast(model, xreg=dummy, h=52)

However it doesnt matter if I use h=52 or h=1 or leave it blank, the forecast automatically seems to forecast the total length of my data set i.e. if I had 404 values it forecasted 404 values forward.

Just wondering why this happens and can I restrict the forecast to less?


You use dummy twice - once in fitting, once in forecasting. Thus, dummy presumably has 404 entries, as many as your historical series. forecast() correspondingly gives you one forecast per entry in dummy. (The forecasts will thus also depend on your historical covariate information, which you presumably don't want.)

Solution: feed only as many future covariate values into forecast() as you want forecasts for. (And make sure those covariate values actually are future values.)

  • $\begingroup$ So I need two tables of dummies. One to work out the model and second one with future dummies for the forecast? Thanks! $\endgroup$ – Oli Paul Feb 16 '16 at 9:49
  • $\begingroup$ Yes, that's it! $\endgroup$ – S. Kolassa - Reinstate Monica Feb 16 '16 at 12:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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