X-13arima-seats Binary

broken image


Binary

This post was written by Dirk Eddelbuettel and Christoph Sax and posted by both author's respective blogs.

Seasonal is a powerful interface between R and X-13ARIMA-SEATS, the seasonal adjustment software developed by the United States Census Bureau. It offers access to almost all features of X-13, including seasonal adjustment via the X-11 and SEATS approaches, automatic ARIMA model search, outlier detection, and support for user-defined holiday variables such as the Chinese New Year or Indian Diwali. A substantial part of the output of X-13ARIMA-SEATS can be shown on the website. Click and drag to zoom into the graph. Double click to restore the original view. Manipulating the R-Call. The R-Call to seasonal can be modified and run online. In the picture below, the ARIMA model has been adjusted to include an autoregressive parameter of order 2.

X-13arima-seats Binary

The seasonal package by Christoph Sax brings a very featureful and expressive interface for working with seasonal data to the R environment. It uses the standard tool of the trade: X-13ARIMA-SEATS. This powerful program is provided by the statisticians of the US Census Bureau based on their earlier work (named X-11 and X-12-ARIMA) as well as the TRAMO/SEATS program by the Bank of Spain. X-13ARIMA-SEATS is probably the best known tool for de-seasonalization of timeseries, and used by statistical offices around the world.

Sadly, it also has a steep learning curve. One interacts with a basic command-line tool which users have to download, install and properly reference (by environment variables or related means). Each model specification has to be prepared in a special ‘spec' file that uses its own, cumbersome syntax.

As seasonal provides all the required functionality to use X-13ARIMA-SEATS from R — see the very nice seasonal demo site — it still required the user to manually deal with the X-13ARIMA-SEATS installation.

So we decided to do something about this. A pair of GitHub repositories provide both the underlying binary in a per-operating system form (see x13prebuilt) as well as a ready-to- use R package (see x13binary) which uses the former to provide binaries for R. And the latter is now on CRAN as package x13binary ready to be used on Windows, OS-X or Linux. And the seasonal package (in version 1.2.0 – now on CRAN – or later) automatically makes use of it. Installing seasaonal and x13binary in R is now as easy as:

which opens the door for effortless deployment of powerful deasonalization. By default, the principal function of the package employs a number of automated techniques that work well in most circumstances. For example, the following code produces a seasonal adjustment of the latest data of US retail sales (by the Census Bureau) downloaded from Quandl:

This tests for log-transformation, performs an automated ARIMA model search, applies outlier detection, tests and adjusts for trading day and Easter effects, and invokes the SEATS method to perform seasonal adjustment. And this is how the adjusted series looks like:

Of course, you can access all available options of X-13ARIMA-SEATS as well. Here is an example where we adjust the latest data for Chinese exports (as tallied by the US FED), taking into account the different effects of Chinese New Year before, during and after the holiday:

which generates the following chart demonstrating a recent flattening in export activity measured in USD.

We hope this simple examples illustrates both how powerful a tool X-13ARIMA-SEATS is, but also just how easy it is to use X-13ARIMA-SEATS from R now that we provide the x13binary package automating its installation.

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:

  • X11: in short, seasonal adjustment is achieved through linear ARMA-like filtering and outlier detection
  • TRAMO: time series regression with ARIMA noise, missing observations and outliers
  • SEATS: signal extraction in ARIMA time series

X-13arima

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.

X-13arima-seats Binary

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.

X-13arima-seats

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.

X-13arima-seats

This post was written by Dirk Eddelbuettel and Christoph Sax and posted by both author's respective blogs.

Seasonal is a powerful interface between R and X-13ARIMA-SEATS, the seasonal adjustment software developed by the United States Census Bureau. It offers access to almost all features of X-13, including seasonal adjustment via the X-11 and SEATS approaches, automatic ARIMA model search, outlier detection, and support for user-defined holiday variables such as the Chinese New Year or Indian Diwali. A substantial part of the output of X-13ARIMA-SEATS can be shown on the website. Click and drag to zoom into the graph. Double click to restore the original view. Manipulating the R-Call. The R-Call to seasonal can be modified and run online. In the picture below, the ARIMA model has been adjusted to include an autoregressive parameter of order 2.

The seasonal package by Christoph Sax brings a very featureful and expressive interface for working with seasonal data to the R environment. It uses the standard tool of the trade: X-13ARIMA-SEATS. This powerful program is provided by the statisticians of the US Census Bureau based on their earlier work (named X-11 and X-12-ARIMA) as well as the TRAMO/SEATS program by the Bank of Spain. X-13ARIMA-SEATS is probably the best known tool for de-seasonalization of timeseries, and used by statistical offices around the world.

Sadly, it also has a steep learning curve. One interacts with a basic command-line tool which users have to download, install and properly reference (by environment variables or related means). Each model specification has to be prepared in a special ‘spec' file that uses its own, cumbersome syntax.

As seasonal provides all the required functionality to use X-13ARIMA-SEATS from R — see the very nice seasonal demo site — it still required the user to manually deal with the X-13ARIMA-SEATS installation.

So we decided to do something about this. A pair of GitHub repositories provide both the underlying binary in a per-operating system form (see x13prebuilt) as well as a ready-to- use R package (see x13binary) which uses the former to provide binaries for R. And the latter is now on CRAN as package x13binary ready to be used on Windows, OS-X or Linux. And the seasonal package (in version 1.2.0 – now on CRAN – or later) automatically makes use of it. Installing seasaonal and x13binary in R is now as easy as:

which opens the door for effortless deployment of powerful deasonalization. By default, the principal function of the package employs a number of automated techniques that work well in most circumstances. For example, the following code produces a seasonal adjustment of the latest data of US retail sales (by the Census Bureau) downloaded from Quandl:

This tests for log-transformation, performs an automated ARIMA model search, applies outlier detection, tests and adjusts for trading day and Easter effects, and invokes the SEATS method to perform seasonal adjustment. And this is how the adjusted series looks like:

Of course, you can access all available options of X-13ARIMA-SEATS as well. Here is an example where we adjust the latest data for Chinese exports (as tallied by the US FED), taking into account the different effects of Chinese New Year before, during and after the holiday:

which generates the following chart demonstrating a recent flattening in export activity measured in USD.

We hope this simple examples illustrates both how powerful a tool X-13ARIMA-SEATS is, but also just how easy it is to use X-13ARIMA-SEATS from R now that we provide the x13binary package automating its installation.

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:

  • X11: in short, seasonal adjustment is achieved through linear ARMA-like filtering and outlier detection
  • TRAMO: time series regression with ARIMA noise, missing observations and outliers
  • SEATS: signal extraction in ARIMA time series

X-13arima

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.

X-13arima-seats

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:

  • seasonal supports both X11 and SEATS methods. x12 does not support SEATS yet.
  • Although it is a question of taste, seasonal is probably better polished visually, e.g. graphical outlier selection is very neat and so is interactive shiny-based model discovery.
  • In case of external regressors, seasonal does not require writing those to a file as x12 does. It's a minor inconvenience though.
  • seasonal has a function genhol for easier generation of holiday-related seasonal effects. This simple function is really great if you need to use it.
  • x12 only provides coefficient estimate table for external regressors, not AR or MA coefficients contrary to seasonal. Unless I am missing something, ARMA coefficients aren't part of the final x12 estimated fit object.

Some advantages of x12 over seasonal:

  • summary method in x12 also provides M-quality statistics for the model which is a nice guidance during modelling procedure. These statistics are however only available for X11 method. If you estimate an X11 model with seasonal, those statistics can only for now be read in the output file. It's also quite nice that x12 provides a possibility for an extended summary output with fullSummary=TRUE option.
  • plotting capabilities are quite similar, though x12 provides a nice plot with original series combined with forecasts and their confidence band.
  • x12 takes an S4-type OOP approach to model estimation. While it's not as intuitive as seasonal, it gets quite useful if you have to deal with many series sharing similar parametrization. x12 would also allow easier parallelization via x12Batch class. It's more a difference in approach rather than a (dis)advantage.

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





broken image