rjdverse / rjd3highfreq

R access to high-frequency data algorithms in JDemetra+ version 3.x
https://rjdverse.github.io/rjd3highfreq/
European Union Public License 1.2
2 stars 8 forks source link

Get name of component in `multiAirlineDecomposition` #6

Closed TanguyBarthelemy closed 1 year ago

TanguyBarthelemy commented 1 year ago

When I run the function multiAirlineDecomposition, I don't get the name of the different component in the decomposition part:

df_daily <- read.csv2("https://raw.githubusercontent.com/TanguyBarthelemy/Tsace_RJD_Webinar_Dec22/b5fcf6b14ae47393554950547ef4788a0068a0f6/Data/TS_daily_births_franceM_1968_2020.csv") |> 
    dplyr::mutate(log_births = log(births))

frenchCalendar <- rjd3toolkit::national_calendar(days = list(
    rjd3toolkit::fixed_day(7, 14), # Bastille Day
    rjd3toolkit::fixed_day(5, 8, validity = list(start = "1982-05-08")), # End of 2nd WW
    rjd3toolkit::special_day('NEWYEAR'), # Nouvelle année
    rjd3toolkit::special_day('MAYDAY'), # 1st may
    rjd3toolkit::special_day('EASTERMONDAY'), # Lundi de Pâques
    rjd3toolkit::special_day('ASCENSION'), # Jeudi ascension
    rjd3toolkit::special_day('WHITMONDAY'), # Lundi de Pentecôte
    rjd3toolkit::special_day('ASSUMPTION'), # Assomption
    rjd3toolkit::special_day('ALLSAINTSDAY'), # Toussaint
    rjd3toolkit::special_day('ARMISTICE'), # End of 1st WW
    rjd3toolkit::special_day('CHRISTMAS')) # Noël
)

q <- rjd3toolkit::holidays(
    calendar = frenchCalendar, 
    "1968-01-01", length = nrow(df_daily), type = "All", nonworking = 7L)

pre.mult <- rjd3highfreq::fractionalAirlineEstimation(
    y = df_daily$log_births, 
    x = q, # q = regs de calendrier
    periods = 7, 
    ndiff = 2, ar = FALSE, mean = FALSE, 
    outliers = c("ao", "wo"), criticalValue = 0, 
    precision = 1e-9, approximateHessian = TRUE)

amb.multi <- multiAirlineDecomposition(
    y = pre.mult$model$linearized, # input time series
    periods = c(7, 365.2425), # DOW pattern
    ar = F, 
    stde = FALSE, # Calculate standard deviations
    nbcasts = 0, nfcasts = 0)  # Numbers of back- and forecasts
> names(amb.multi$decomposition)
NULL
> str(amb.multi$decomposition) 
List of 4  
 $ : num [1:19359] 7.75 7.75 7.75 7.75 7.75 ...  
 $ : num [1:19359] 0.03299 0.01761 0.01265 0.00499 0.00751 ...  
 $ : num [1:19359] 0.09951 -0.03004 -0.01431 -0.00577 -0.01379 ...  
 $ : num [1:19359] 0.01238 0.0078 0.00394 0.0044 0.0018 ...

Also I don't find this information in the dictionary:

library("rJava")

ndiff = 2
ar = FALSE
y = pre.mult$model$linearized
periods = c(7, 365.2425)
stde = FALSE
nbcasts = 0
nfcasts = 0

jrslt <- .jcall("jdplus/highfreq/base/r/FractionalAirlineProcessor", 
                "Ljdplus/highfreq/base/core/extendedairline/decomposition/LightExtendedAirlineDecomposition;", 
                "decompose", as.numeric(y), .jarray(periods), as.integer(ndiff), 
                ar, stde, as.integer(nbcasts), as.integer(nfcasts))
rjd3toolkit::.proc_dictionary2(jrslt)
 [1] "likelihood.ll"           
 [2] "likelihood.adjustedll"   
 [3] "likelihood.ssqerr"       
 [4] "likelihood.nparams"      
 [5] "likelihood.nobs"         
 [6] "likelihood.neffectiveobs"
 [7] "likelihood.df"           
 [8] "likelihood.aic"          
 [9] "likelihood.aicc"         
[10] "likelihood.bic"          
[11] "likelihood.bicc"         
[12] "likelihood.bic2"         
[13] "likelihood.hannanquinn"  
[14] "ucarima.size"            
[15] "pcov"                    
[16] "parameters"              
[17] "score"                   
[18] "y"                       
[19] "t"                       
[20] "s"                       
[21] "i"                       
[22] "sa"                      
[23] "t_stde"                  
[24] "s_stde"                  
[25] "i_stde"                  
[26] "ncmps"                   
[27] "cmp(*)"                  
[28] "cmp_stde(*)"

Thank you!

TanguyBarthelemy commented 1 year ago

Finally I think I can close it with the PR #7