rjdverse / rjd3x13

R access to X13-Arima algorithm in JDemetra+ version 3.x
https://rjdverse.github.io/rjd3x13/
European Union Public License 1.2
4 stars 8 forks source link

export trading days tests #13

Closed AQLT closed 5 months ago

AQLT commented 1 year ago

Only one trading day test is exportable:

sa <- rjd3x13::x13(rjd3toolkit::ABS$X0.2.09.10.M,
                   "rsa0",
                   userdefined = c("diagnostics.td-sa-all", "diagnostics.td-sa-last", 
                    "diagnostics.td-i-all", "diagnostics.td-i-last", "diagnostics.td-res-all", 
                    "diagnostics.td-res-last"))
c(sa$user_defined)
#> $`diagnostics.td-sa-all`
#> Value:  9.150547 
#> P-Value:  0.0000 
#> 
#> $`diagnostics.td-sa-last`
#> Value:  9.150547 
#> P-Value:  0.0000 
#> 
#> $`diagnostics.td-i-all`
#> Value:  9.150547 
#> P-Value:  0.0000 
#> 
#> $`diagnostics.td-i-last`
#> Value:  9.150547 
#> P-Value:  0.0000 
#> 
#> $`diagnostics.td-res-all`
#> Value:  9.150547 
#> P-Value:  0.0000 
#> 
#> $`diagnostics.td-res-last`
#> Value:  9.150547 
#> P-Value:  0.0000
tail(rjd3toolkit::diagnostics(sa)[[2]],2)
#>             Statistic      P.value
#> td.ftest.i   9.813542 3.944967e-10
#> td.ftest.sa  9.150547 2.018406e-09
#>                                                                                                Description
#> td.ftest.i  F with 6.0 degrees of freedom in the nominator and 418.0 degrees of freedom in the denominator
#> td.ftest.sa F with 6.0 degrees of freedom in the nominator and 418.0 degrees of freedom in the denominator

How the trading days tests are computed in JD3.0 ? The method seems to have changed since JD2.0 and I didn't manage to compute the values of JD3.0 with rjd3toolkit::td_f().

sa_jd2 <- RJDemetra::x13(rjd3toolkit::ABS$X0.2.09.10.M,
                       "RSA0",
                       userdefined = c("diagnostics.td-sa-all", "diagnostics.td-sa-last", 
                                    "diagnostics.td-i-all", "diagnostics.td-i-last", "diagnostics.td-res-all", 
                                    "diagnostics.td-res-last"))

c(sa_jd2$user_defined)
#> $`diagnostics.td-sa-all`
#> [1] 1.128238e+01 1.095150e-11
#> attr(,"description")
#> [1] "F with 6 degrees of freedom in the nominator and 416 degrees of freedom in the denominator"
#> 
#> $`diagnostics.td-sa-last`
#> [1] 2.74019570 0.01730723
#> attr(,"description")
#> [1] "F with 6 degrees of freedom in the nominator and 88 degrees of freedom in the denominator"
#> 
#> $`diagnostics.td-i-all`
#> [1] 7.834586e+00 5.252002e-08
#> attr(,"description")
#> [1] "F with 6 degrees of freedom in the nominator and 416 degrees of freedom in the denominator"
#> 
#> $`diagnostics.td-i-last`
#> [1] 2.79270949 0.01558277
#> attr(,"description")
#> [1] "F with 6 degrees of freedom in the nominator and 88 degrees of freedom in the denominator"
#> 
#> $`diagnostics.td-res-all`
#> [1] 1.074554e+01 4.236759e-11
#> attr(,"description")
#> [1] "F with 6 degrees of freedom in the nominator and 406 degrees of freedom in the denominator"
#> 
#> $`diagnostics.td-res-last`
#> [1] 2.81945842 0.01458629
#> attr(,"description")
#> [1] "F with 6 degrees of freedom in the nominator and 91 degrees of freedom in the denominator"
tail(sa_jd2$diagnostics$residuals_test,2)
#>                   Statistic      P.value
#> f-test on sa (td) 11.282381 1.095150e-11
#> f-test on i (td)   7.834586 5.252002e-08
#>                                                                                                  Description
#> f-test on sa (td) F with 6 degrees of freedom in the nominator and 416 degrees of freedom in the denominator
#> f-test on i (td)  F with 6 degrees of freedom in the nominator and 416 degrees of freedom in the denominator
palatej commented 5 months ago

Ok. I see the bug in the Java code: a usual copy/paste issue (see jdplus-main-base/jdplus-sa-base-parent/jdplus-sa-base-core/src/main/java/jdplus/sa/base/core/extractors/GenericSaTestsExtractor.java). It will be corrected in v3.2.3