Particle filter estimation - "Matrix must be positive definite" error

Dear All,

I am trying to estimate a model with particle filtering. My model at order 1 (mode_compute=9) works, so I tried to switch to order 2. These are the steps I followed:

  1. I used (log) first differenced data instead of (log) one-side-HP-filtered series (to avoid the mean=0 problem).

  2. I used undemeaned observation equations as suggested in Chapter 8 of Pfeifer’s paper “Guide to Specifying Observation Equations for the
    Estimation of DSGE Models”.

  3. I added measurement errors to the observation equations.

Unfortunately, I keep getting the error “Matrix must be positive definite”. Since the model works in order 1, I suspect I have a problem with my data.

Please find the .mod file and data attached (I am using Dynare 4.5.7). Thank you in advance

prova99OW_estimation_particle.mod (7.5 KB)

data2.mat (7.2 KB)

@frederic.karame Could you maybe have a look?


When running your code, I see that the variance-covariance matrix of states has a zero on the diagonal, which is problematic for the initialization of the particles distribution.

So first, I advise you specify explicitly starting values for the parameters that allow the filter to pass the initialization step (and you do not let Dynare do it automatically from your priors),

Second, you change the way initialization is done. In this case, copy-paste in your mod-file:

options_.particle.initialization = 2;


options_.particle.initialization = 3;
options_.particle.initial_state_prior_std = .01;

before calling estimation()


Thank you very much!