rjdverse / rjd3x13

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

Specify different critical values for different outlier types (in X13) #6

Open TanguyBarthelemy opened 1 year ago

TanguyBarthelemy commented 1 year ago

(copy of the issue palatej/rjd3x13#21)

Ok then, how to specity different critical values for different outlier types (in X13) ?

This program returns an error :

spec_x13_d <- rjd3x13::spec_x13("rsa5c")

spec_x13_d <- rjd3toolkit::set_outlier(
    spec_x13_d,
    outliers.type = c("LS", "TC"),
    critical.value = c(5, 2))
> Error in if (missing(critical.value) | is.na(critical.value)) { : 
>   the condition has length > 1
AQLT commented 1 year ago

Your previous code works now since https://github.com/rjdemetra/rjd3toolkit/pull/1. However, it doesn't seems to work:

y = rjd3toolkit::ABS$X0.2.09.10.M
spec <- rjd3toolkit::set_outlier(
  rjd3x13::spec_regarima("rsa5c"),
  outliers.type = c("AO","LS"),
  critical.value = c(1, 100))
list2DF(spec$outlier$outliers) # OK
#>         
#> 1 AO  LS
#> 2  1 100
ud_var <- c("regression.nao", "regression.nls")
spec$outlier$defva
#> [1] 1
rjd3x13::fast_regarima(y,spec, userdefined = ud_var)$user_defined
#> $regression.nao
#> [1] 20
#> 
#> $regression.nls
#> [1] 10
#> 
#> attr(,"class")
#> [1] "user_defined"
spec$outlier$defva <- 0 
rjd3x13::fast_regarima(y,spec, userdefined = ud_var)$user_defined
#> $regression.nao
#> [1] 2
#> 
#> $regression.nls
#> [1] 0
#> 
#> attr(,"class")
#> [1] "user_defined"
spec$outlier$defva <-  NULL
rjd3x13::fast_regarima(y,spec, userdefined = ud_var)$user_defined
#> $regression.nao
#> [1] 2
#> 
#> $regression.nls
#> [1] 0
#> 
#> attr(,"class")
#> [1] "user_defined"
spec$outlier$defva <-  100
rjd3x13::fast_regarima(y,spec, userdefined = ud_var)$user_defined
#> $regression.nao
#> [1] 0
#> 
#> $regression.nls
#> [1] 0
#> 
#> attr(,"class")
#> [1] "user_defined"
TanguyBarthelemy commented 12 months ago

Ok thank you Alain again for your quick answer. I was using an obsolete version of rjd3x13 and I didn't check the other issues from the rjduniverse ! Do you want to close this issue and raise another for your remark or keep this one up ?