dsa {dsa}R Documentation

Seasonally Adjust Daily Time Series

Description

Seasonally adjust daily time series using the dsa approach

Usage

dsa(
  series,
  span.start = NULL,
  model = NULL,
  Log = FALSE,
  automodel = "reduced",
  ic = "bic",
  include.constant = FALSE,
  fourier_number = 24,
  max_fourier = 30,
  s.window1 = 53,
  s.window2 = 53,
  s.window3 = 13,
  t.window1 = NULL,
  t.window2 = NULL,
  t.window3 = NULL,
  cval = 7,
  robust1 = TRUE,
  robust2 = TRUE,
  robust3 = TRUE,
  regressor = NULL,
  forecast_regressor = NULL,
  reg_create = NULL,
  reg_dummy = NULL,
  outlier = TRUE,
  outlier_types = c("AO", "LS", "TC"),
  delta = 0.7,
  model_span = NULL,
  feb29 = "sfac",
  trend_month = 3,
  outer3 = NULL,
  inner3 = NULL,
  h = 365,
  reiterate3 = NULL,
  scaler = 1e+07,
  mean_correction = TRUE,
  progress_bar = TRUE
)

Arguments

series

Input time series in xts format

span.start

Define when seasonal adjustment should begin

model

ARIMA order of non-seasonal part

Log

Boolean. Should multiplicate or additive model be used

automodel

Set of models to be considered for automatic model detection. Either "full" or "reduced" set of fourier regressors included

ic

Information criterion that is used for automodelling. One of "bic", "aic" or "aicc"

include.constant

Should drift be allowed for model that includes differencing

fourier_number

Number of trigometric regressors to model annual and monthly seasonality

max_fourier

Maximum number of trigonometric regressors allowed if the number is selected automatically, i.e. fourier_number=NULL

s.window1

STL parameter s.window for the day of the week effect

s.window2

STL parameter s.window for the day of the month effect

s.window3

STL parameter s.window for the day of the year effect

t.window1

STL parameter t.window for the day of the week effect

t.window2

STL parameter t.window for the day of the month effect

t.window3

STL parameter t.window for the day of the year effect

cval

Critical value for outlier adjustment

robust1

Boolean. Should robust STL be used for the day of the week effect

robust2

Boolean. Should robust STL be used for the day of the month effect

robust3

Boolean. Should robust STL be used for the day of the year effect

regressor

Pre-specified regressors

forecast_regressor

Pre-specified regressors to be used for forecasting

reg_create

Names of Holidays for which regressors will be created

reg_dummy

If specified dummy variables of specified length are created and used as regressors

outlier

Should an outlier adjustment be conducted?

outlier_types

The following are possible: "LS", "TC", "AO", "IO"

delta

The decay rate for TC outliers

model_span

Last x years used for regARIMA modelling

feb29

How should February 29th be derived: interpolation of adjusted series ("sa") or combined factor ("sfac")

trend_month

Length of support period for trend estimation

outer3

Number of iterations of outer loop in STL for day of the year effect

inner3

Number of iterations of inner loop in STL for day of the year effect

h

Forecast horizon in number of days

reiterate3

Number of total iterations of STL for the day of the year effect

scaler

for additive model, if max(abs(series)) > 1e5, scale series

mean_correction

Boolean. Should seasonal factors be standardised so that their mean (over all full cycles) is 0 for additive and 1 for multiplicative models

progress_bar

Boolean. Should a progress bar be displayed

Details

This function can be used to seasonally and calendar adjust daily time series and decomposing the series into a seasonally adjusted series, a day-of-the-week, a moving holiday, a day-of-the-month and a day-of-the-year component.

If mean_correction=TRUE (default), the seasonal and calendar factors are corrected, so that over all full years, the mean of the components is 0 in additive models. They will be close to 1 if a multiplicative decomposition (i.e. Log=TRUE) is used. Deviations from 1 may result, because the mean correction is applied to the components before inverting taking logs.

For long series, the ARIMA modelling and the outlier adjustment may take a long time. It may therefore be a good idea, to specify the ARIMA model used, e.g. model=c(3,1,0). If the series does not contain influential outliers, the outlier adjustment could be skipped by setting outlier=FALSE.

See vignette for further examples.

Value

dsa returns a daily object which contains the output of the seasonal adjustment of a daily time series.

output Contains the calendar and seasonally adjusted series, original series, implicit calendar and seasonal component, and Loess based trend as an xts object

fourier_terms The number of sine and cosine terms used to model the seasonal pattern in the RegARIMA model

reg RegARIMA results

info Basic information on transformation (Log/Level), differencing and forecast horizon

stl A list of length 3, containing the STL results of the day-of-week, day-of-the-month and day-of-the-year adjustment, respectively

outlier Result of the outlier adjustment

sa_result The original series and the intermediate adjustment results after the day-of-week adjustment (s1_adjusted), calendar adjustment (s1k1_adjusted), day-of-the-month adjustment (s1k1s2_adjusted), and the final adjusted series after the day-of-the-year adjustment (seas_adj) as an xts object

sa_result2 The original series only adjusted for single components as an xts object. Namely the original series itself (original), the original only adjusted for the day-of-the week (s1_adjusted), calendar (k1_adjusted), day-of-the-month (s2_adjusted), and day-of-the-year (s3_adjusted)

sfac_result The seasonal and calendar components as an xts object. Namely, the day-of-the-week (s1_fac), calendar (cal_fac), day-of-the-month (s2_fac), and day-of-the-year component (s3_fac)

Author(s)

Daniel Ollech

References

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

Ollech, Daniel (2021). Seasonal Adjustment of Daily Time Series. Journal of Time Series Econometrics (forthcoming).

Examples

x = daily_sim(n=4)$original # series with length 4 years
res <- dsa(x, cval=7, model=c(3,1,0),fourier_number = 13)

[Package dsa version 1.0.12 Index]