rjdverse / rjdemetra

R interface to JDemetra+ v 2.x
https://rjdverse.github.io/rjdemetra
52 stars 16 forks source link

default to.date is passed #102

Closed ThomasLaurentInsee closed 2 years ago

ThomasLaurentInsee commented 2 years ago

Hello,

The by default to.date, as defined in spec_transform.R, is passed (31-12-2020). It should be moved forward (2100 ?) or set to a value that implied that the whole serie will be considered (as window(end=NULL) do).

AQLT commented 2 years ago

Indeed, it is odd, I'm not sure it has an impact since in the function span_r2jd (https://github.com/jdemetra/rjdemetra/blob/b6ca1e9e8f0d15eb960c59989cc4a9fa01f202c5/R/spec_rjd.R#L790) only the needed information is used. To be tested.

AQLT commented 2 years ago

I confirm it has no impact but I will change it for clarity.

library(RJDemetra)
y = ts(ipi_c_eu[,"FR"],start = 2020, frequency = 12)
spec = x13_spec(estimate.from = "2025-01-01",
                outlier.from = "2025-01-01")
mod = x13(y, spec)
mod$regarima$specification$span
#>          type         d0         d1 n0 n1
#> estimate From 2025-01-01 2020-12-31  0  0
#> outlier  From 2025-01-01 2020-12-31  0  0
mod$regarima$specification$estimate
#>  preliminary.check            span tolerance
#>               TRUE From 2025-01-01     1e-07
mod$regarima$specification$outliers
#>  enabled            span   ao   tc   ls    so usedefcv cv method tcrate
#>     TRUE From 2025-01-01 TRUE TRUE TRUE FALSE     TRUE  4 AddOne    0.7
mod$regarima
#> y = regression model + arima (0, 1, 1, 0, 1, 1)
#> Log-transformation: no
#> Coefficients:
#>           Estimate Std. Error
#> Theta(1)   -0.7261      0.041
#> BTheta(1)  -0.6692      0.046
#> 
#>              Estimate Std. Error
#> Monday        -0.3564      0.316
#> Tuesday       -1.7265      0.319
#> Wednesday     -0.8741      0.316
#> Thursday       0.8502      0.320
#> Friday         1.0392      0.320
#> Saturday       0.6015      0.326
#> Leap year     -1.0575      0.976
#> Easter [1]    -2.0775      0.655
#> TC (4-2050)  -22.6730      2.593
#> TC (3-2050)  -19.7840      2.580
#> LS (11-2038) -11.0964      1.973
#> AO (5-2041)   11.5111      2.283
#> LS (1-2039)   -6.8908      1.974
#> 
#> 
#> Residual standard error: 2.585 on 283 degrees of freedom
#> Log likelihood = -712.2, aic =  1456 aicc =  1458, bic(corrected for length) = 2.186

Created on 2022-03-11 by the reprex package (v2.0.1)

ThomasLaurentInsee commented 2 years ago

Ok, thanks. But if the parameters are ignored by spec_rjd in that case, wouldn't it be better to keep it at NA ?

For example, if no span is specified in x13_spec, you will only have type ="All" with non-NA values.

> spec = x13_spec()
> mod = x13(y, spec)
> mod$regarima$specification$span
         type         d0         d1 n0 n1
estimate  All 1900-01-01 2020-12-31  0  0
outlier   All 1900-01-01 2020-12-31  0  0
AQLT commented 2 years ago

Those dates were the default values of JDemetra+. When you change the "Type" value of a span, you have those default dates. In RJDemetra the type parameter is automatically set with the other parameters, but the different dates where only used when needed. But Indeed the results of mod$regarima$specification$span wasn't clear. However mod$regarima$specification$outliers$span and mod$regarima$specification$estimate$span provide a simplified message. I changed it in the last released for clarity:

library(RJDemetra)
y = ts(,start = 2020, frequency = 12)
spec = x13_spec(estimate.from = "2010-01-01",
                outlier.to = "2015-01-01")
mod = x13(ipi_c_eu[,"FR"], spec)
mod$regarima$specification$span
#>          type         d0         d1 n0 n1
#> estimate From 2010-01-01       <NA>  0  0
#> outlier    To       <NA> 2015-01-01  0  0
mod$regarima$specification$estimate$span
#> [1] "From 2010-01-01"
mod$regarima$specification$outliers$span
#> [1] "Until 2015-01-01"

mod = x13(ipi_c_eu[,"FR"])
mod$regarima$specification$span
#>          type d0 d1 n0 n1
#> estimate  All NA NA  0  0
#> outlier   All NA NA  0  0
mod$regarima$specification$estimate$span
#> [1] "All"
mod$regarima$specification$outliers$span
#> [1] "All"