rjdverse / rjdemetra

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

User-def Calendar Implementation #148

Closed AdamWallach closed 2 months ago

AdamWallach commented 2 months ago

Hello, I am working on a piece of code that would closely replicate the results given by regular Demetra for national calendar, with all various holidays, including moving ones. The issue I am facing, is that it seems the calendar regressors have not been properly implemented by me, giving slightly skewed results. My question is, how do I model the national calendar right? [at the moment, it is a vector with n working days of meach month, - mean working days: workdays <- giveworkdays("2000-01-01","2020-12-31")[,2] #this function includes easter and related moving catholic holidays workdays <- workdays - mean(workdays) calendar <- ts(workdays,start=c(2000,1),end=c(2020,12),frequency=12)]

With the following specs later on: par <- tramoseats_spec(spec = "RSAfull",usrdef.varEnabled = TRUE,usrdef.varType = "Calendar",usrdef.var = calendar,tradingdays.option = "UserDefined")

AQLT commented 2 months ago

Hi, You are using the write code to include them so the difference must come from the way you build your calendar regressor. You can see here more details on how it is computed in Jdemetra: https://jdemetra-new-documentation.netlify.app/a-calendar-correction. In particular, in JDemetra+ what is used not just the number of working days of each months, but a contrast reference is used (see the previous page) -> I the problem comes from here. Morover, the long-term mean correction doesn't corresponds to the number of working days (in particular a different mean is used for each month), but you shouldn't have any difference if you have a seasonal differenciation in your ARIMA model.