jdemetra / jdplus-main

JDemetra+ v3
European Union Public License 1.2
12 stars 8 forks source link

Cannot set fixed outlier coefficients #398

Closed a-s-russo closed 1 week ago

a-s-russo commented 3 weeks ago

Consider inserting an additive outlier (AO) in a series and setting the 'parameter value' as follows:

image

After clicking on Ok and then applying the changes, the parameter value seems to have 'disappeared'. If I reopen the 'Pre-specified outliers' dialogue box, the parameter value is no longer visible:

image

The AO is being applied to my series with a value of one in the Regressors matrix as expected (Pre-processing -> Regressors), but not with the parameter value I used:

image

Instead of 1.15 I input previously, the above suggests that -0.0043 is being used instead.

I use the term 'value' to refer to the regressor number (which is 1 in this case), and I use the term 'coefficient' for the factor that RegARIMA estimates for the size of the correction (which I want to set to 1.15 in this case).

image

Note that I have been able to successfully specify fixed coefficients via RJDemetra, as shown below with a separate example:

image

If the coefficient is fixed, and the value of the fixed coefficient is 0, will JD+ re-estimate it via RegARIMA, or will it use a coefficient of 0 (meaning that the outlier in effect is not applied to the series)?

The same issue above occurs for LSs as well. The above was done using a single document, not a multi-document, and used JD+ version 3.2.4.

Immurb commented 2 weeks ago

It is only possible to fix any coefficients in the GUI if the transformation is defined (aka not Auto). We should definitely make it clear for the user, by deactivating the option and explaining the cause in the description.

So let me answer all the questions:

a-s-russo commented 2 weeks ago

Thanks so much for the helpful answers @Immurb. I appreciate you answering each of my questions carefully. That all makes sense. I look forward to having your suggestion of making things clearer for the user implemented.

a-s-russo commented 2 weeks ago

One further thing to add @Immurb: there was a reason for my question regarding the meaning of 0 for fixed coefficients:

In R, when we look up the documentation for the add_outlier() function, under Arguments it says "coef: the coefficient if needs to be fixed. If equal to 0 the outliers/ramps coefficients are estimated.

Why does the R interface differ to the GUI? It seems that in RJDemetra, a 0 tells JD+ to re-estimate, but in the GUI, it doesn't mean that.

We're not sure why in R the default value of coef isn't NULL or NA so that any value given to it would indicate a fixed value but if it's NULL/NA then RegARIMA would re-estimate.

Immurb commented 1 week ago

I'm not sure why it is implemented that way in R, maybe @TanguyBarthelemy or @charphi know. Internally each Parameter/Coefficient has a value and a type (Undefined, Initial, Fixed, Estimated). In the GUI I think you can only choose the type for ARIMA parameters, everything else fixes the value.

palatej commented 1 week ago

A few clarifications:

We use the same structure for parameters (in ARIMA or other models) and for regression coefficients. Not the best choice, but changing it would be expensive and error prone. At least, we should indeed adapt the spec boxes to use the correct names and to hide the coefficients when they can't be fixed. The documentation should explain why. I will add it in the issues.

In the ARIMA model, the different types make sense: you can of course estimate the value or fix it, but you can also give an initial value; that is useful when there are different local maximum likelihood solutions (different initial values could give different final estimates).

Considering the coefficients of the regression, you just can fix them or estimate them: there is an analytic solution and initial values would never be used. That's why given coefficients are always considered as fixed. Using 0 doesn't make sense in most cases. The only exception is trading days, when you want to exclude the effects of some day(s).

The choice of the default value in R is indeed misleading. NULL or NA would be better. To be noted that 0 is automatically changed in the R code to NULL. -> small improvement for the next release (-> issue in rjd3toolkit)

a-s-russo commented 1 week ago

Thanks for the clarifications @Immurb and @palatej. Incorporating the suggested changes in a future release would be great.

I agree that a coefficient of 0 is pointless in all cases except for the one @palatej has identified. However, the GUI treatment is better in my view than the R treatment: the former is helpfully consistent regardless of value if type is 'fixed', even if the value is 0. That is easier to understand than having 0 mean 're-estimate' as per the R implementation.

a-s-russo commented 1 week ago

I have one more question given the replies above. @Immurb stated that in the GUI, the 'type can only be set for ARIMA parameters'. However, @palatej then said that for the regression coefficients, 'you just can fix them or estimate them', but then goes on to say that they 'are always considered as fixed'.

I'm confused now: are the coefficients for user-defined variables (regressors) always fixed, always re-estimated, or can the user choose the type ('fixed', or 're-estimate'). If so, how (in the GUI)?

Similar to LSs and AOs, I can't make sense of the corresponding user-defined variable window (even if I choose a non-auto transformation as @Immurb advised):

image

palatej commented 1 week ago

If you give a value, the coefficient is considered as fixed. Otherwise, it is (of course) estimated.

To be noted that the treatment of fixed coefficients is completely different from usual REGARIMA estimation: fixed regression effects are first removed from the series; that's why we must now the transformation of the series to interpret it correctly (should they be applied on the series in levels or in logs?) . The modified series is then processed and the fixed regression effects are finally reintroduced in the results.

More details can be retrieve in the documentation