Compute mode with occbin Bayesian estimation

Hi there,

I’m trying understand how to do Bayesian estimation in a model with occbin. I checked out tests/occbin/filter · master · Dynare / dynare · GitLab, and managed to run the NKM file. Now, I want to try to compute the mode myself, instead of using the saved mode. When I try to do this, I run into problems, different ones depending on the mode_compute setting, but for example with mode_compute = 4, I get “Index exceeds the number of array elements. Index must not exceed 2.” When I try 1 or 6, MATLAB often crashes after “Fval obtained by the minimization routine (minus the posterior/likelihood)): -1585.316870”.

See attached the modified .mod file. I’ve only changed the estimation command.
NKM_find_mode.mod (11.8 KB)

Thanks for pointing this out. There is a bug with a fix at dsge_likelihood.m: add missing penalty for Occbin (!2086) · Merge requests · Dynare / dynare · GitLab

Thank you, this works well. The problem that I get now is a posterior kernel optimization problem, see below. Does this mean I have to use another optimization routine, or is something else wrong? I understood that mode_compute = 4 is the preferred option, especially since the model is quite simple. I am using the same .mod file as above.

POSTERIOR KERNEL OPTIMIZATION PROBLEM!
 (minus) the hessian matrix at the "mode" is not positive definite!
=> posterior variance of the estimated parameters are not positive.
You should try to change the initial values of the parameters using
the estimated_params_init block, or use another optimization routine.
Warning: The results below are most likely wrong! 
> In dynare_estimation_1 (line 308)
In dynare_estimation (line 118)
In NKM_find_mode.driver (line 459)
In dynare (line 281) 

MODE CHECK

Fval obtained by the minimization routine (minus the posterior/likelihood)): -1586.177633

RESULTS FROM POSTERIOR ESTIMATION
parameters
        prior mean     mode    s.d.  prior pstdev

varphip   100.0000 100.0000  0.0879   norm 25.0000 
phipi       2.0000   1.9992  0.0018   norm 0.2500 
phiy        0.5000   0.4969  0.0004   norm 0.2500 
h           0.8000   0.7940  0.0007   beta 0.1000 
rhos        0.8000   0.7949  0.0007   beta 0.1000 
rhoi        0.8000   0.8243  0.0007   beta 0.1000 
sigz        0.0050   0.0045  0.0001   invg 0.0050 
sigs        0.0050   0.0054  0.0001   invg 0.0050 
sigi        0.0020   0.0023  0.0001   invg 0.0020 


Log data density [Laplace approximation] is NaN.

Error using calibrate_mh_scale_parameter
The covariance matrix has to be a symetric positive definite matrix!

Error in dynare_estimation_1 (line 451)
            options_.mh_jscale = calibrate_mh_scale_parameter(objective_function, ...

Error in dynare_estimation (line 118)
    dynare_estimation_1(var_list,dname);

Error in NKM_find_mode.driver (line 459)
oo_recursive_=dynare_estimation(var_list_);

Error in dynare (line 281)
    evalin('base',[fname '.driver']);

Have you tried other mode-finders? The optimization seems stuck at the initial point.

Yes, I’ve tried them all now. Unfortunately they all return the same error message:

Log data density [Laplace approximation] is NaN.

Or, for mode_compute 6, 7, or 8 MATLAB runs for hours and hours without progress. Is there a way to retrieve the method how you initially found the mode?

Sorry, but I don’t have that information. You would need to check their replication package. But they did not use Dynare AFAIK.