rjdverse / rjdemetra

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

Problem with annual data. #86

Closed niklaag closed 3 years ago

niklaag commented 3 years ago

Hello, I have a small issue related to annual data.

In one of my projects I'm interested in using RJDemetra to estimate the irregular component in annual time series. However, when I'm trying to specify the model, I get the following error message:

Error in .jcall(rslt, "Ljava/lang/Object;", "getData", name, rjdemetra_java$clobject) : java.lang.NullPointerException

Here's a short snip of the code preceding the problem. The problem occurs when I try to specify x1 below.

`rm(list = ls())

library(rJava) library(readxl) library(xlsx) library(RJDemetra)

dataset <- read_excel("r_input2.xlsx", col_names = TRUE)

s <- ts(dataset, start=c(2020-dim(dataset)[1]), frequency=1)

myspec <- tramoseats_spec(spec = c("RSA3"), outlier.enabled = TRUE, outlier.ao = TRUE, outlier.ls = FALSE, outlier.tc = FALSE, transform.function = c("Log"), )

x1 <- tramoseats(s[, "x1"], spec = myspec)`

When I tried this in NbDemetra it worked fine. I also reinstalled R and RStudios and tried with the latest devtools version available.

Thanks.

AQLT commented 3 years ago

Hello,

It comes from the fact that the function tramoseats produces a formatted output with a lot of indicators and the extraction of one of them gives you an error. A workaround is to use the jtramoseats function that only returns a java object and to use the function get_indicators to get the variables you want. The function get_dictionary gives you all the parameters that you can export. Below an example to export the irregular component.

library(RJDemetra)
y <- ts(c(93, 92, 91, 87, 91, 93, 94, 99, 103, 106, 111, 112, 
          110, 108, 111, 111, 112, 114, 110, 95, 100, 103, 100, 99, 98, 
          100, 101, 103, 104, 104),start = 1990)
mod <- jtramoseats(y)
get_indicators(mod, "i")
#> $i
#> Time Series:
#> Start = 1990 
#> End = 2019 
#> Frequency = 1 
#>  [1] 1.0026792 1.0000024 1.0085145 0.9777485 1.0057924 1.0027378 0.9897434
#>  [8] 1.0030314 1.0027013 0.9956372 1.0092964 1.0067423 1.0000555 0.9886013
#> [15] 1.0068459 0.9977333 0.9977926 1.0134165 0.9928425 0.8661731 0.9090189
#> [22] 0.9457237 0.9471534 0.9660163 0.9686838 0.9856985 0.9858016 0.9941756
#> [29] 0.9965835 0.9956195
head(get_dictionary(mod), 10)
#>  [1] "y"    "y_f"  "t"    "t_f"  "sa"   "sa_f" "s"    "s_f"  "i"    "i_f"

Created on 2021-03-16 by the reprex package (v1.0.0)