Bug in Identification Analysis after estimation with Posterior Mode using Slice Sampler

When running an identification analysis with posterior mode, after an estimation using a slice sampler with options:

  • posterior_sampling_method = 'slice'
  • posterior_sampler_options = ('slice_initialize_with_mode', 1)

The identification “run” script (located in the +identification folder) sets options_.mode_compute to 0 (see line 302). Later, in the check_posterior_sampler_options function (line 322), the condition: "if (isequal(options_.mode_compute,0) && isempty(options_.mode_file))"

The condition is triggered. This causes Dynare to mistakenly conclude that the user is attempting to run slice sampling with mode without a defined mode, leading to an early termination of the process.

Suggested (Preliminary) Fix: A possible modification that I tested is to alter the condition to: "if (isequal(options_.mode_compute,0) && isempty(options_.mode_file) && ~isfield(options_, 'options_ident'))"

This change helps distinguish when the procedure is part of an identification analysis. However, I suspect there might be a more direct and reliable way to handle this scenario, and it might cause errors when using estimation after identification.

Steps to Reproduce:

  1. An estimation using the slice sampler with the following options:
    • posterior_sampling_method = 'slice'
    • posterior_sampler_options = ('slice_initialize_with_mode', 1)
  2. After estimation, an identification analysis using posterior mode (I am not sure posterior mode is necessary).
  3. Observe that the identification “run” script sets options_.mode_compute to 0, and later, the condition in check_posterior_sampler_options incorrectly halts the process because it assumes a missing mode.

here is a minimal mod file (attached) that will produce the bug:

bug_test.mod data_file.csv

var y;

varexo u;

parameters r;

r = 0.5;

model;

y = r * y(-1) + u;

end;

shocks;

var u; stderr 1;

end;

estimated_params;

r, , NORMAL_PDF, 0, 1;

end;

varobs y;

estimation(order=1, datafile= 'data_file.csv', mh_replic = 50,posterior_sampling_method = 'slice', consider_all_endogenous, posterior_sampler_options = ('slice_initialize_with_mode',1)); identification(parameter_set = posterior_mode);

Edited by Yaakov Chen zion