rbagd.eu

home about contacts

Seasonal time series adjustment with X-13ARIMA-SEATS in R

10 Jul 2015

Time series data, particularly in economics, may and does often contain seasonality and trend components. Data analysis and forecasts can be significantly improved if these components are taken into account. It is one of the reasons why many economic data you are presented with is most likely seasonally adjusted. For example, fresh food prices are a neat example of data subject to important seasonal patterns.

A few methods emerged over time to help statisticians adjust time series for seasonality, of which X11 became the dominant one, notably due to its relative simplicity.

Here is a small dictionary:

Some more discussion on X11 and seasonal adjustment is available here. More on filters can be found here. Information on TRAMO/SEATS is available on its website.

Currently, there are two main software packages implementing above described methods. Others also exist but are likely to be not free. X-13ARIMA-SEATS maintained by U.S. Census Bureau is based on X11 method and its improvements but also implements SEATS. Alternatively, JDemetra+ maintained by National Bank of Belgium and Eurostat provides a Java-based implementation for all the above methods. JDemetra+ is well done, cross-platform and provides plenty of point and click options to work with your time series, although documentation is quite seriously lacking. On the other hand, X-13ARIMA-SEATS does not come with a GUI unless you are on Windows but has an excellent reference manual. An advantage for the latter is also the possibility to remain within the R universe.

In R, two packages provide an interface to X-13ARIMA-SEATS software: seasonal and x12. Additionally, the latter has a GUI via x12GUI package providing some button clicking options.

So just to reiterate and eliminate all confusion: X11 is a seasonal adjustment method, its major implementation is found in the software called X-13ARIMA-SEATS while x12 package for R provides only an interface to this software. X-13ARIMA-SEATS superseded its previous version known as X-12-ARIMA (also supported by x12 package), hence the variation in numbering.

Both R packages can be found to be useful in general. seasonal uses SEATS method as default, while x12 supports only X11 method. Both packages also have the same workflow: first, rewrite the user-defined model in a .spc file understood by X13-ARIMA-SEATS binary, run the binary, read the .out file and parse it back into R. Both also aim to implement all or most of the options available in the true X-13ARIMA-SEATS software.

For an occasional use, seasonal is probably preferable as its more intuitive and will probably easier to use. In both cases, X-13ARIMA-SEATS binary has to be downloaded manually and its path set up as explained in documentation of each of the packages.

Here is a small example of a basic modelling option with dummy variables for each month, i.e. fixed seasonal effects.

library(seasonal)
Sys.setenv(X13_PATH = 'dir_to_binary')
seas(AirPassengers, regression.variables="seasonal")

library(x12)
x13path('dir_to_binary/x13as')
x12(AirPassengers, setP(new("x12Parameter"),
                        list(regression.variables="seasonal")))

Note that the two snippets above will give different outputs due to differences in default settings. For identical results, add regression.aictest=NULL, x11='' options within seas function.

Some advantages of seasonal over x12:

Some advantages of x12 over seasonal:

Feel free to test everything I have discussed to find what suits your workflow best.