Seasonal Adjustment in R

The package ‘Seasonal’ facilitates seasonal adjustment in R. The R package provides an easy-to-handle wrapper around the X-13ARIMA-SEATS Fortran libraries provided by the US Census Bureau. X-13ARIMA-SEATS is the state-of-the-art seasonal adjustment software produced, distributed, and maintained by the Census Bureau. The software permits extensive time series modeling and model selection capabilities for linear regression models with ARIMA errors (regARIMA models). Futhermore, the software has the capability to generate ARIMA model-based seasonal adjustment using a version of the SEATS procedure originally developed by Victor Gómez and Agustín Maravall at the Bank of Spain as well as nonparametric adjustments from the X-11 procedure. Finally, the program allows diagnostics of the quality and stability of the adjustments achieved under the options selected as well as the ability to efficiently process many series at once. The R package ‘Seasonal’ allows the user to access this software directly from R.

The following tutorial demonstrates how to seasonally adjust a time series in R using the ‘Seasonal’ package. For this purpose we use a R dataset called ‘AirPassengers’. This dataset contains the classic Box & Jenkins airline data. That is, the dataset contain the monthly totals of international airline passengers from 1949 to 1960. The data entail a high degree of seasonality, which become apparent when looking at the figure below.

Seasonal fluctuations make it difficult to interpret monthly changes of time series, i.e. it becomes difficult to determine how much of the change in a time series is due to fundamentals and how much of the change is due to seasonal factors. The seasonal adjustment procedure corrects the data for seasonal factors and produces data that are free of any seasonal influence. After seasonally adjusting data, we are now able to interpret monthly changes in the data and attribute this changes to fundamentals. The following figure displays both, the original series as well as the seasonally adjusted series. Note that the seasonally adjusted series in red is much smoother than the original. You can find the R code that seasonally adjusts data and produces these figures at the end of the post.

The following R code seasonally adjust the AirPassanger data and reproduces the figures included in this post.

# start with an empty workspace

# install and load seasonal package 
# install.packages("seasonal")

# use the R dataset AirPassengers. This dataset 
# contains the classic Box & Jenkins airline data. 
# Monthly totals of international airline 
# passengers, from 1949 to 1960.

# seasonal adjust time series using X11. 
sa_series <- seas(AirPassengers,x11 = "")

# plot original and seasonally adjusted series.
This entry was posted in Computing and Others, Data, Econometrics, Statistic and tagged , , , , , . Bookmark the permalink.

One Response to Seasonal Adjustment in R

  1. Pingback: Seasonal adjustment | Economic Theory Blog

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s