# rjdmarkdown with HTML output

The functions developped in `rjdmarkdown` are:

- `print_preprocessing()` for the pre-processing model;
- `print_decomposition()` for the decomposition;
- `print_diagnostics()` to print diagnostics tests on the quality of the seasonal adjustment.

The result is different between X-13ARIMA and TRAMO-SEATS models.

    library(rjdmarkdown)
    library(RJDemetra)
    sa_x13 <- x13(ipi_c_eu[, "FR"])
    sa_ts <- tramoseats(ipi_c_eu[, "FR"])

# X-13-ARIMA model

    print_preprocessing(sa_x13, format = "html")

Pre-processing (RegArima)

Summary

336 observations

Trading days effect (7 variables)

Easter [1] detected

3 detected outliers

Likelihood statistics

Number of effective observations = 323

Number of estimated parameters = 14

Loglikelihood = -624.720, AICc = 1278.803, BICc = 1.252

Standard error of the regression (ML estimate) = 1.665

ARIMA model

ARIMA coefficients
| Coefficients | Std. Error | T-stat | P (> | t|) |
--- | --- | --- | --- | --- | ---
Theta(1) | -0.527 | 0.048 | -10.922 | 0.000 | ***
BTheta(1) | -0.487 | 0.051 | -9.585 | 0.000 | ***
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ’ ’ 1
ARIMA (0,1,1)(0,1,1)

Regression model

Regression coefficientss
| Coefficients | Std. Error | T-stat | P (> | t|) |
--- | --- | --- | --- | --- | ---
Monday | -0.134 | 0.164 | -0.818 | 0.414 |
Tuesday | -0.002 | 0.163 | -0.015 | 0.988 |
Wednesday | 0.242 | 0.163 | 1.479 | 0.140 |
Thursday | -0.531 | 0.163 | -3.252 | 0.001 | **
Friday | 0.432 | 0.164 | 2.640 | 0.009 | **
Saturday | 0.153 | 0.163 | 0.936 | 0.350 |
Leap year | -0.046 | 0.501 | -0.092 | 0.927 |
Easter [1] | -1.094 | 0.335 | -3.269 | 0.001 | **
LS (11-2008) | -8.442 | 1.307 | -6.460 | 0.000 | ***
LS (1-2009) | -7.274 | 1.306 | -5.568 | 0.000 | ***
LS (5-2008) | -5.020 | 1.257 | -3.993 | 0.000 | ***
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ’ ’ 1

    print_decomposition(sa_x13, format = "html", caption = NULL)

Decomposition (X-11)

Mode: additive

S-I Ratio

M-statistics
| Value | Description
--- | --- | ---
M-1 | 0.061 | The relative contribution of the irregular over three months span
M-2 | 0.034 | The relative contribution of the irregular component to the stationary portion of the variance
M-3 | 0.840 | The amount of period to period change in the irregular component as compared to the amount of period to period change in the trend
M-4 | 0.420 | The amount of autocorrelation in the irregular as described by the average duration of run
M-5 | 0.697 | The number of periods it takes the change in the trend to surpass the amount of change in the irregular
M-6 | 0.236 | The amount of year to year change in the irregular as compared to the amount of year to year change in the seasonal
M-7 | 0.075 | The amount of moving seasonality present relative to the amount of stable seasonality
M-8 | 0.206 | The size of the fluctuations in the seasonal component throughout the whole series
M-9 | 0.055 | The average linear movement in the seasonal component throughout the whole series
M-10 | 0.166 | The size of the fluctuations in the seasonal component in the recent years
M-11 | 0.137 | The average linear movement in the seasonal component in the recent years
Q | 0.272 |
Q-M2 | 0.301 |
Final filters: M3x5, Henderson-13 terms

Relative contribution of the components to the stationary portion of the variance in the original series, after the removal of the long term trend
| Component
--- | ---
Cycle | 1.646
Seasonal | 49.667
Irregular | 0.411
TD & Hol. | 0.057
Others | 49.814
Total | 101.596

    print_diagnostics(sa_x13, format = "html")

Diagnostics tests
| P (> | t|) |
--- | --- | ---
mean | 0.682 |
skewness | 0.726 |
kurtosis | 0.018 |
ljung box | 0.023 |
ljung box (residuals at seasonal lags) | 0.888 |
ljung box (squared residuals) | 0.315 |
qs test on sa | 1.000 |
qs test on i | 1.000 |
f-test on sa (seasonal dummies) | 0.980 |
f-test on i (seasonal dummies) | 0.922 |
Residual seasonality (entire series) | 0.969 |
Residual seasonality (last 3 years) | 0.897 |
f-test on sa (td) | 0.980 |
f-test on i (td) | 1.000 |
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ’ ’ 1

# TRAMO-SEATS model

Some others graphics can also be added with the `ggdemetra` package, for example to add the seasonally adjusted series and its forecasts:

    library(ggdemetra)
    ggplot(data = ipi_c_eu_df, mapping = aes(x = date, y = FR)) +
        geom_line() +
        labs(title = NULL,
             x = NULL, y = NULL) +
        geom_sa(component = "y_f", linetype = 2,
                frequency = 12, method = "tramoseats") +
        geom_sa(component = "sa", color = "red") +
        geom_sa(component = "sa_f", color = "red", linetype = 2)

Seasonal adjustment of the French industrial production index

    print_preprocessing(sa_ts, format = "html")

Pre-processing (Tramo)

Summary

336 observations

Series has been log-transformed

Trading days effect (6 variables)

Easter [6] detected

3 detected outliers

Likelihood statistics

Number of effective observations = 323

Number of estimated parameters = 15

Loglikelihood = 875.751, AICc = 1262.750, BICc = -8.028

Standard error of the regression (ML estimate) = 0.016

ARIMA model

ARIMA coefficients
| Coefficients | Std. Error | T-stat | P (> | t|) |
--- | --- | --- | --- | --- | ---
Phi(1) | 0.352 | 0.256 | 1.376 | 0.170 |
Phi(2) | 0.134 | 0.130 | 1.026 | 0.305 |
Theta(1) | -0.187 | 0.256 | -0.728 | 0.467 |
BTheta(1) | -0.611 | 0.047 | -13.010 | 0.000 | ***
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ’ ’ 1
ARIMA (2,1,1)(0,1,1)

Regression model

Regression coefficientss
| Coefficients | Std. Error | T-stat | P (> | t|) |
--- | --- | --- | --- | --- | ---
Monday | -0.002 | 0.002 | -1.385 | 0.167 |
Tuesday | 0.001 | 0.002 | 0.353 | 0.724 |
Wednesday | 0.003 | 0.002 | 1.938 | 0.054 | .
Thursday | -0.005 | 0.002 | -3.342 | 0.001 | ***
Friday | 0.003 | 0.002 | 2.010 | 0.045 |
Saturday | 0.002 | 0.002 | 1.128 | 0.260 |
Easter [6] | -0.011 | 0.003 | -3.201 | 0.002 | **
LS (11-2008) | -0.079 | 0.013 | -6.143 | 0.000 | ***
LS (1-2009) | -0.071 | 0.013 | -5.509 | 0.000 | ***
AO (8-2001) | 0.045 | 0.013 | 3.498 | 0.001 | ***
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ’ ’ 1

    print_decomposition(sa_ts, format = "html", caption = NULL)

Decomposition (SEATS)

Mode: multiplicative

S-I Ratio

Model

AR: \(1+0.352B+0.134B^{2}\)

D: \(1-B-B^{12}+B^{13}\)

MA: \(1-0.187B-0.611B^{12}+0.114B^{13}\)

SA

D: \(1-2.000B+B^{2}\)

MA: \(1-1.314B+0.340B^{2}\)

Innovation variance: 0.467

Trend

D: \(1-2.000B+B^{2}\)

MA: \(1+0.040B-0.960B^{2}\)

Innovation variance: 0.049

Seasonal

AR: \(1+0.352B+0.134B^{2}\)

D: \(1+B+B^{2}+B^{3}+B^{4}+B^{5}+B^{6}+B^{7}+B^{8}+B^{9}+B^{10}+B^{11}\)

MA: \(1+0.718B+0.461B^{2}+0.310B^{3}+0.132B^{4}-0.049B^{5}-0.217B^{6}-0.355B^{7}-0.445B^{8}-0.470B^{9}-0.377B^{10}-0.166B^{11}-0.411B^{12}-0.133B^{13}\)

Innovation variance: 0.160

Irregular

Innovation variance: 0.206

Relative contribution of the components to the stationary portion of the variance in the original series, after the removal of the long term trend
| Component
--- | ---
Cycle | 2.181
Seasonal | 66.768
Irregular | 0.106
TD & Hol. | 0.069
Others | 30.507
Total | 99.630

    print_diagnostics(sa_ts, format = "html")

Diagnostics tests
| P (> | t|) |
--- | --- | ---
mean | 0.659 |
skewness | 0.976 |
kurtosis | 0.901 |
ljung box | 0.002 | **
ljung box (residuals at seasonal lags) | 0.882 |
ljung box (squared residuals) | 0.484 |
qs test on sa | 1.000 |
qs test on i | 1.000 |
f-test on sa (seasonal dummies) | 1.000 |
f-test on i (seasonal dummies) | 1.000 |
Residual seasonality (entire series) | 1.000 |
Residual seasonality (last 3 years) | 0.977 |
f-test on sa (td) | 0.927 |
f-test on i (td) | 1.000 |
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ’ ’ 1

# Reproductibility

To produce this document, the `knitr` options were set as followed:

    knitr::opts_chunk$set(
      collapse = TRUE,
      comment = "#>", out.width = "100%",
      fig.dim = c(7, 5),
      warning = FALSE, message = FALSE
    )

And the options `results='asis', fig.cap = "S-I Ratio"` were used in the chunks.