Skip to contents

Seasonal Adjustment with X13-ARIMA

Usage

x13(
  ts,
  spec = c("rsa4", "rsa0", "rsa1", "rsa2c", "rsa3", "rsa5c"),
  context = NULL,
  userdefined = NULL
)

x13_fast(
  ts,
  spec = c("rsa4", "rsa0", "rsa1", "rsa2c", "rsa3", "rsa5c"),
  context = NULL,
  userdefined = NULL
)

.jx13(
  ts,
  spec = c("rsa4", "rsa0", "rsa1", "rsa2c", "rsa3", "rsa5c"),
  context = NULL,
  userdefined = NULL
)

Arguments

ts

an univariate time series.

spec

the model specification. Can be either the name of a predefined specification or a user-defined specification.

context

list of external regressors (calendar or other) to be used for estimation

userdefined

a vector containing additional output variables (see x13_dictionary()).

Value

the x13() function returns a list with the results, the estimation specification and the result specification, while x13_fast() is a faster function that only returns the results. The .jx13() functions only returns results in a java object which will allow to customize outputs in other packages (use rjd3toolkit::dictionary() to get the list of variables and rjd3toolkit::result() to get a specific variable). In the estimation functions x13() and x13_fast() you can directly use a specification name (string). If you want to customize a specification you have to create a specification object first.

Examples

y <- rjd3toolkit::ABS$X0.2.09.10.M
x13_fast(y, "rsa3")
#> Model: X-13
#> Log-transformation: yes 
#> SARIMA model: (2,1,1) (0,1,1)
#> 
#> SARIMA coefficients:
#>    phi(1)    phi(2)  theta(1) btheta(1) 
#>    0.3804    0.2140   -0.7025   -0.5626 
#> 
#> Regression model:
#> TC (2000-06-01) AO (2000-07-01) 
#>          0.1548         -0.2951 
#> 
#> Seasonal filter: S3X3; Trend filter: H-23 terms
#> M-Statistics: q Good (0.560); q-m2 Good (0.617)
#> QS test on SA: Uncertain (0.035); F-test on SA: Good (0.999)
#> 
#> For a more detailed output, use the 'summary()' function.
x13(y, "rsa5c")
#> Model: X-13
#> Log-transformation: yes 
#> SARIMA model: (0,1,1) (1,1,1)
#> 
#> SARIMA coefficients:
#>  theta(1)   bphi(1) btheta(1) 
#>   -0.8155   -0.4341   -0.8246 
#> 
#> Regression model:
#>          monday         tuesday       wednesday        thursday          friday 
#>       -0.009156        0.004523       -0.001181        0.013349       -0.001501 
#>        saturday          easter TC (2000-06-01) AO (2000-07-01) 
#>        0.014993        0.051061        0.162337       -0.306371 
#> 
#> Seasonal filter: S3X3; Trend filter: H-23 terms
#> M-Statistics: q Good (0.385); q-m2 Good (0.427)
#> QS test on SA: Bad (0.004); F-test on SA: Good (0.986)
#> 
#> For a more detailed output, use the 'summary()' function.
regarima_fast(y, "rg0")
#> Log-transformation: no 
#> SARIMA model: (0,1,1) (0,1,1)
#> 
#> SARIMA coefficients:
#>  theta(1) btheta(1) 
#>   -0.8764   -0.3876 
#> 
#> No regression variables
#> 
#> For a more detailed output, use the 'summary()' function.
regarima(y, "rg3")
#> Method: RegARIMA
#> Log-transformation: yes 
#> SARIMA model: (2,1,1) (0,1,1)
#> 
#> SARIMA coefficients:
#>    phi(1)    phi(2)  theta(1) btheta(1) 
#>    0.3804    0.2140   -0.7025   -0.5626 
#> 
#> Regression model:
#> TC (2000-06-01) AO (2000-07-01) 
#>          0.1548         -0.2951 
#> 
#> For a more detailed output, use the 'summary()' function.

sp <- x13_spec("rsa5c")
sp <- rjd3toolkit::add_outlier(sp,
    type = c("AO"), c("2015-01-01", "2010-01-01")
)
sp <- rjd3toolkit::set_transform(
    rjd3toolkit::set_tradingdays(
        rjd3toolkit::set_easter(sp, enabled = FALSE),
        option = "workingdays"
    ),
    fun = "None"
)
x13(y, spec = sp)
#> Model: X-13
#> Log-transformation: no 
#> SARIMA model: (3,1,1) (0,1,1)
#> 
#> SARIMA coefficients:
#>    phi(1)    phi(2)    phi(3)  theta(1) btheta(1) 
#>    0.1656    0.0878   -0.1129   -0.8608   -0.2292 
#> 
#> Regression model:
#>              td              lp AO (2010-01-01) AO (2015-01-01) AO (2000-06-01) 
#>           1.002          29.639          37.048          27.995         199.754 
#> AO (2000-07-01) LS (2005-04-01) LS (2015-07-01) 
#>        -194.689         -82.306          81.333 
#> 
#> Seasonal filter: S3X2; Trend filter: H-23 terms
#> M-Statistics: q Good (0.552); q-m2 Good (0.624)
#> QS test on SA: Good (0.138); F-test on SA: Good (0.996)
#> 
#> For a more detailed output, use the 'summary()' function.
sp <- set_x11(sp,
    henderson.filter = 13
)
x13_fast(y, spec = sp)
#> Model: X-13
#> Log-transformation: no 
#> SARIMA model: (3,1,1) (0,1,1)
#> 
#> SARIMA coefficients:
#>    phi(1)    phi(2)    phi(3)  theta(1) btheta(1) 
#>    0.1656    0.0878   -0.1129   -0.8608   -0.2292 
#> 
#> Regression model:
#>              td              lp AO (2010-01-01) AO (2015-01-01) AO (2000-06-01) 
#>           1.002          29.639          37.048          27.995         199.754 
#> AO (2000-07-01) LS (2005-04-01) LS (2015-07-01) 
#>        -194.689         -82.306          81.333 
#> 
#> Seasonal filter: S3X2; Trend filter: H-13 terms
#> M-Statistics: q Good (0.533); q-m2 Good (0.604)
#> QS test on SA: Good (0.117); F-test on SA: Good (0.997)
#> 
#> For a more detailed output, use the 'summary()' function.