Error in 2º order estimation, while 1º order estimation works fine

Greetings,

I am having some trouble to estimate a model with 2º order solutions, however estimation it is working fine for 1º order solution. I saw similar posts here in the forum but none of them was capable to deal with my problem. The general error displayed by Dynare concerns computing the likelihood for the initial parameters values:

ESTIMATION_CHECKS: There was an error in computing the likelihood for initial parameter values.
ESTIMATION_CHECKS: If this is not a problem with the setting of options (check the error message below),
ESTIMATION_CHECKS: you should try using the calibrated version of the model as starting values. To do
ESTIMATION_CHECKS: this, add an empty estimated_params_init-block with use_calibration option immediately before the estimation
ESTIMATION_CHECKS: command (and after the estimated_params-block so that it does not get overwritten):

Error using chol
Matrix must be positive definite

I tried every particle filter available and filter initializations (nonlinear_filter_initialization =1, 2 and 3, keep getting -inf as likelihood) , every algorithms for mode computations and also tried the jumping mcmc matrix as an identity matrix (mcmc_jumping_covariance = identity_matrix). The files for execution are below:

main_NK_estimation2.m (3.0 KB) soe_nk_data.m (3.2 KB) SOE_NK_estimation2.mod (6.2 KB)

The main_NK_estimation2.m file calls the mod file SOE_NK_estimation2.mod that activates dynare procedure and uses the data in soe_nk_data.m to perform estimation. Just put all the files in the same folder and execute main_NK_estimation2.m to see the error. Set order = 1 in the estimation command of the mod file and observe that it is working fine.

The model is stationary and I use 3 observable variables. Ratio of International Reserves and Output (R/Y), Ratio of External Debt and Output (d/Y), log of Output (log Y). Data are in deviations of their respective quadratic trends, but concerning the observable ratios R/Y and d/Y I set them to be around their steady state values in the model (it is a target parameter of the model. In particular, I calibrate R/Y = Rbar = 0.82 and d/Y = dbar = 0.14). One can also observe that stoch_simul is working fine for order = 2. Any suggestions will be appreciated.

Thanks in advance.

  1. The particle filters require measurement error to be specified. I added estimated measurement error in the estimated_params-block.
  2. Default initialization with the state covariance does not work in your model as there is insufficient stochastics for the states. So I used a different initialization: nonlinear_filter_initialization=2

SOE_NK_estimation2.mod (6.4 KB)

1 Like

Thanks for your fast answer professor Johannes ! This makes perfect sense, I wasn’t aware that we need measurement errors when we use particle filters. However, I’ve downloaded and executed yours mod file and I still got error. A bit different though, the filter is enable to find an initial value for the log posterior:

Estimation using a non linear filter!

Initial value of the log posterior (or likelihood): 444.8816

However, 1 second later displays an error message:

Error using chol
Matrix must be positive definite.

Error in sequential_importance_particle_filter (line 78)
StateVectorVarianceSquareRoot = chol(ReducedForm.StateVectorVariance)’;%reduced_rank_cholesky(ReducedForm.StateVectorVariance)’;

Error in non_linear_dsge_likelihood (line 228)
LIK = feval(DynareOptions.particle.algorithm, ReducedForm, Y, start, DynareOptions.particle, DynareOptions.threads, DynareOptions,
Model);

Error in gmhmaxlik_core (line 105)
*** logpo2 = - feval(ObjFun,proposal,varargin{:});***

Error in gmhmaxlik (line 100)
*** [PostMode, PostVariance, Scale, PostMean] = gmhmaxlik_core(fun, OldPostMode, bounds, gmhmaxlikOptions, Scale, flag, MeanPar,***
*** OldPostVariance, varargin{:});***

Error in dynare_minimize_objective (line 271)
*** [opt_par_values, hessian_mat, Scale, fval] = gmhmaxlik(objective_function, start_par_value, …***

Error in dynare_estimation_1 (line 219)
*** [xparam1, fval, exitflag, hh, options_, Scale, new_rat_hess_info] =***
*** dynare_minimize_objective(objective_function,xparam1,options_.mode_compute,options_,[bounds.lb***
*** bounds.ub],bayestopt_.name,bayestopt_,hh,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_);***

Error in dynare_estimation (line 105)
*** dynare_estimation_1(var_list,dname);***

Error in SOE_NK_estimation2.driver (line 447)
oo_recursive_=dynare_estimation(var_list_);

Error in dynare (line 293)
evalin(‘base’,[fname ‘.driver’]) ;

But if it works on your machine it is suggesting that I should reinstall dynare (and update it to the latest veriosn)? I am currently using 4.6.2 version.

I only made sure the mod-file runs. I did not attempt a full estimation. From what I can see, the problem derives from explosive simulations. You might need to set

options_.particle.pruning=1;
1 Like

Thanks for your answer ! You are right, higher order solutions are implying explosives paths, but solutions are fine when I use the pruning option in the stoch_simul command. However, I still get the same problem in the estimation step after setting :

options_.particle.pruning=1;

I include this command after varobs and before estimation command. This is strange since solutions appears to be fine after the pruning process, so I would not expect explosive simulations here. To replicate just execute the .m file main_NK_estimation3.m with the other files in the same folder.

main_NK_estimation3.m (4.3 KB) SOE_NK_estimation3.mod (7.9 KB) data.mat (3.6 KB)

Since first-order works fine, I am tempting to let go the estimation for higher orders solutions. Rather, I might use higher-order solutions with parameters calibrated from this first-order exercise.

Seizing the opportunity here, is there any way to generate the output of oo_.MeanForecast outside the estimation command? I observed in the forecast section that confidence intervals are generated by a simulation of the stochastic shocks rather than draws of parameters from the posterior distribution. And if there is not, it is possible to get a sample from the posterior distribution so I can compute myself the content of oo_.MeanForecast using higher order solutions?

(Of course I would have to implement a particle filter to compute the state variables implied by data, so I can provide a starting point for the forecast).

Thanks in advance for all the support.

  1. You must specify measurement error using Dynare’s interface, i.e. not specify it as a structural shock. Use SOE_NK_estimation3.mod (7.8 KB)
  2. Which type of uncertainty do you want to take into account? Parameter uncertainty? Disturbance uncertainty or both?

Much thanks for your reply.

(1) I did your suggestion and the filter started ! With non infinity values for the likelihood. However, after some seconds I still got the error “Matrix must be Positive Semi Definite”. I think this may be due identification problems. I will include more structural shocks and observables in the model and try again.

(2) I want Parameter uncertainty. Is there any way to implement confidence bands of parameter uncertainty outside the estimation command?

  1. No, this problem is due to a bug in error handling in Dynare. See the change in non_linear_dsge_likelihood.m . You also need to set options_.pruning=1 as it is currently not inherited from options_.particles.pruning.
  2. You can do that via a posterior_function. See e.g. https://github.com/JohannesPfeifer/DSGE_mod/blob/master/Jermann_Quadrini_2012/Jermann_Quadrini_2012_NK/generate_var_decomp_posterior.m for an implementation.
1 Like