DSA - Seasonal Adjustment of Daily Time Series

Daniel Ollech

2019-04-04

Daily Seasonal Adjustment

The dsa package includes functions to seasonally adjust time series with daily observations. Daily time series can contain three different seasonalities. Exemplarily, the currency in circulation is influenced by a weekday effect as the demand for banknotes increases towards the weekend. Monthly recurring troughs and peaks can often be observed, because salary payments tend to be concentrated around the turn of the month. Due to an increase in consumption the demand for currency reaches its high around Christmas time. In addition to these seasonal influences, the currency in circulation is positively impacted by Easter and other public holidays whose date changes from year to year. The procedure for daily calendar and seasonal adjustment (DSA) made available here combines a local regression based iterative seasonal adjustment routine with a time series regression model for the estimation of moving holiday and outlier effects. Details on the procedure can be found in Ollech (2018).

To get started

We’ll simulated some seasonal daily data using the daily_sim() function and afterwards seasonally adjust that series using the dsa() function.

library(dsa)
set.seed(5)
x = daily_sim(5)$original
res <- dsa(x, cval=7, model=c(3,1,0),fourier_number = 13, reg.create=NULL) 
#> 
  |                                                                       
  |                                                                 |   0%
  |                                                                       
  |===                                                              |   5%
  |                                                                       
  |======                                                           |  10%
  |                                                                       
  |===============                                                  |  24%
  |                                                                       
  |=========================                                        |  38%
  |                                                                       
  |===========================================                      |  67%
  |                                                                       
  |==============================================                   |  71%
  |                                                                       
  |==================================================               |  76%
  |                                                                       
  |===========================================================      |  90%
  |                                                                       
  |=================================================================| 100%

To output the results, it is possible to create an HTML file that contains the most important results and visualisations.

output(res)
#> 
  |                                                                       
  |                                                                 |   0%
  |                                                                       
  |===                                                              |   5%
  |                                                                       
  |============                                                     |  19%
  |                                                                       
  |==============                                                   |  21%
  |                                                                       
  |===============                                                  |  23%
  |                                                                       
  |=================                                                |  26%
  |                                                                       
  |===================                                              |  29%
  |                                                                       
  |======================                                           |  33%
  |                                                                       
  |=========================                                        |  38%
#> 
  |                                                                       
  |===============================                                  |  48%
  |                                                                       
  |=====================================                            |  57%
#> 
  |                                                                       
  |========================================                         |  62%
  |                                                                       
  |==============================================                   |  71%
  |                                                                       
  |==================================================               |  76%
#> 
  |                                                                       
  |========================================================         |  86%
#> 
  |                                                                       
  |==============================================================   |  95%
#> 
  |                                                                       
  |================================================================ |  98%
#> 
  |                                                                       
  |=================================================================| 100%

Figures

It is also possible, to work with the data directly and to use xtsplot() to plot the results.

sa <- res$output[,1]
original <- res$output[,2]
plot(merge(original, sa), main="Results of Daily Seasonal Adjustment")

References

Ollech, Daniel (2018). Seasonal adjustment of daily time series. Bundesbank Discussion Paper 41/2018.