# State space models for time series forecasting

I am new to time series forecasting and have been slowly working my way through the different approaches available. I've so far mainly been using ets and arima models available in the R forecast package. As I need to forecast at a daily level taking into consideration weekends and public holidays, I have also been exploring arimax models with xreg values. As far as I can tell, it does not seem possible to use xreg values with ets models. With my sample data ets also can't forecast the step function that occurs at weekends accurately - the smoothing means the only saturday is forecast correctly but sunday is also incorrect. I cam across a series of slides from Nate Derby - http://www.sas.com/offices/NA/canada/downloads/presentations/Victoria2008/Time.pdf The final slides elude to the fact that state space models might make it easier to model timeseries. How powerful and implementable are state space models? Is this something I need to seriously consider?

• ets uses a state space model. Presumably you mean a more complex state space model. – Rob Hyndman May 18 '13 at 3:39
• you are correct. i don't know much about the area but have gotten pretty far thanks to the ets() function in the forecast package. I think i need to at least get an understanding of what the more complex state space models can achieve. – orbital May 18 '13 at 9:07

To become better at time-series forecasting, it is no doubt beneficial to expand the number of forecasting methods or models available at your fingertips. Being able to model time-series data using ARIMA and exponential smoothing models is a good notch to have under your belt. Delving into non-linear models, regime switching models, and varying parameter models can only be a good thing for you.

The important thing to keep in mind is that we'd normally like to build simple linear models and not necessarily complicate matters by building non-linear models. This is one thing that you should definitely consider. That is, before considering building non-linear models, first test to see if non-linearity is actually present in the data under consideration.

You mention that you need to take into account weekends and public holidays. This suggests that maybe you need to make sure that the model you choose contains the appropriate seasonal (and non-seasonal, of course) components. Have you tried a seasonal non-seasonal multiplicate arima model? Or, a seasonal non-seasonal additive arima model?

I can only speak in general terms since you haven't given much details about the data you're working with, so a general word of advice would be to let the data do the talking and rather than choose a forecasting model a priori, let the data lead you to the appropriate model. If the data suggests that a non-linear model is worth considering, for sure, consider it.

In addition to F. Tusell's suggestion, another R package worth checking out is tsDyn. It is available at http://cran.r-project.org/web/packages/tsDyn/index.html.

• Thanks Graeme. I am trying to forecast sales volume data. I started with forecasting at a month level, then weekly and daily using both ETS and ARIMA. Both ETS and ARIMA worked very well at the monthly and weekly levels, picking up the yearly seasonal pattern. I need to get the forecasting down to the daily level, for staff scheduling reasons. ETS and ARIMA at the daily level also produced reasonable results but I need to factor in weekends and public holidays and a few main advertising triggers. – orbital May 17 '13 at 22:44
• ETS at the daily level can't dip down to the lows experienced on a sunday. Arima does a better job at this but dips too low going to negative values. I have just learnt that ETS can take xreg variables so that rules them out at the moment. Arimax is my next step for exploration, but I also want to explore state space models. – orbital May 17 '13 at 22:44
• @orbital Your modelling task sounds very interesting. I think that the one-off events, particularly the advertising ones, could be modelled as a binary "on-off" variable, as is done in intervention analysis. A reference at hand is: Wichern, D. W. and R. H. Jones (1977). "Assessing the Impact of Market Disturbances Using Intervention Analysis". I think you can do this using ARIMAX models by letting the exogenous explanatory variable(s) be dummy variable(s). Note also that trigonometric terms can also be used to model deterministic seasonal patterns:see Harvey's Time Series Models (1993), p.138. – Graeme Walsh May 18 '13 at 0:10

Starting with the last question, yes, I think you have every reason to look at state-space models methods to solve your problem. You do not tell which software you are using, but many of them will allow you to introduce regressors, with fixed or time-varying coefficients. In R, for instance, you could look at package dlm among many others.

• I second the recommendation of dlm. I'd add, however, that while dlm lets you get started more quickly than other packages, if you're going to dig into your results you will have to understand the underlying matrices that make up a DLM. DLM's are more like programs rather than a black box with some parameters you tweak. – Wayne May 17 '13 at 19:56
• Thanks for the advise. I have been using R and the wonderful forecast package. – orbital May 17 '13 at 22:29