Particle filter dynare

Yes, indeed the particle filter is computationally expensive. That is why we rely on the Kalman filter for linear models.

Where is this user manual for the unstable version. Specifically for the particle filter syntax?

When downloading and installing the unstable version, you can find the up-to-date manual in the doc-folder. It’s called dynare.pdf

By including mode_check, the mode check plots are created. How can we get the parameter trajectories and parameter densities plots to be created? I am able to create them with other estimation programs, but not this one.

Which estimation command exactly did you use?

I have been playing around with the linear_model.mod program.


Are the option-options the new, or the old approaches to programming SMC.
For example,

options_.particle.number_of_particles = 20000; options_.particle.resampling.status = 'systematic'; options_.particle.resampling.neff_threshold = .1;

can also be programmed within the estimation command:

or more specifically, my question is which approach is preferable?

Also, is there documentation regarding these options?>

options_.gstep(1) = 1e-4;
options_.gstep(2) = .1;

options_.mode_check_neighbourhood_size = 0.05;


In general, you can set any Dynare option manually the way you see it above. If you use the preprocessor interface, all it does is translate the commands to statements like the one above. The preprocessor interface is less prone to mistakes and therefore usually more preferable.

The gstep part is size of the gradient step used in numerical solvers.

mode_check_neighbourhood_size is in the manual.

set_dynare_threads is a command to

[quote]set the number of threads used by some MEX files when compiled
with OpenMP support (i.e with --enable-openmp is given to configure) or any
other parallel library.

That is good insight. Thanks.

My next question has to do with programming Particle filters.
The command filter_algorithm=sis
is the sequential importance sampling. However, by adding

resampling=systematic or generic
Doe this make the particle filter the sequential importance resampling filter? It seems obvious, but the manual does not explicitly say this.

Does this option work with any of the other filters? It must not do anything to the APF

Lastly, the mode_compute=11 runs the on-line estimation. Does this option over ride the particle filters in the filter_algorithm=

Concerning the first question on filter_algorithm=sis and resampling=systematic the answer is yes. And it is the default.

resampling_threshold only works with generic and is useless with systematic or none. With apf it induces a second resampling step on current particles which is not necessary. The literature then recommands resampling=none for apf.

Keep in mind that maximum likelihood will not function in presence of resampling since it generates a discontinuity of the criterion with respect to the structural parameters. In that case, avoid gradient-based methods.

Concerning mode_compute=11 it is an auxiliary particle filter and it overrides the other options that control other particle filters. It is useful to obtain fast estimation on parameters by including them as extra states but suffers from a severe lack of theoretical foundations.

Thank you for the detailed reply. That makes things clear.
Can someone check the NKLF option with the linear_model.mod . It runs for several minutes before crashing.

Could you please provide the mod-file

The NLKF filter starts out strong, but then crashes at Simplex iteration number: 4964-4-3, maybe after 20 minutes.

linear_model_nlkf.mod (1.44 KB)

Notice that this file expects the linear_model.mode.mat file, but This board won’t let me upload .mat files. Be sure to eliminate the mode_file=linear_model_mode in the estimation command.

Thanks for looking into this bug.


You may try it again with the proposed change at

Dear Professor Pfeifer,

I learn that dynare 4.6.1 is able to do estimation for order higher than 1. While I try to implement the estimation which I have specified as log-linear model. However, the dynare reports that higher order estimation cannot deal with log-lineared model.

error: non_linear_dsge_likelihood (line 59)
non_linear_dsge_likelihood: It is not possible to use a non linear filter with the option loglinear!

I understand that the higher-order estimation or particle filter is relatively new. But is it possible to find any simple example or instruction in the dynare manual on the issue—how to use the estimation command with higher-order properly?


Examples are at tests/particle · master · Dynare / dynare · GitLab

Note that the problem is not with using a log-linearized model, but rather you asking to log-linearize a model using Dynare functionality. It is usually better to work with auxiliary equations to get a log-linearization. See

Dear Professor,

Many thanks for your reply. It helps!


Dear Professor Pfeifer,

I try to run the .mod files from tests/particle · master · Dynare / dynare · GitLab. However, after running the .mod files and choosing the mode - finder I get the following error message.

Reference to non-existent field ‘ghs2’.

Error in non_linear_dsge_likelihood (line 179)
ReducedForm.constant = ReducedForm.steadystate + .5*dr.ghs2(restrict_variables_idx);

Error in initial_estimation_checks (line 153)
[fval,info] =

Error in dynare_estimation_1 (line 164)
oo_ =

Error in dynare_estimation (line 105)

Error in noisy_ar1.driver (line 177)

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

I am using dynare 4.6.4. How can I fix it?


Could you please try the unstable version?

Hi Professor,

Thank You for Your reply, I installed dynare 4.8 the latest unstable version. And now after running the same code I get such an error.
Error using initial_estimation_checks (line 99)
initial_estimation_checks:: particle filtering requires measurement error on the observables

Error in initial_estimation_checks (line 99)
error(‘initial_estimation_checks:: %s requires measurement error on the observables’,disp_string)

Error in dynare_estimation_1 (line 154)
oo_ =

Error in dynare_estimation (line 118)

Error in noisy_ar1.driver (line 179)

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

You picked exactly one the files that is not supposed to work. Try e.g. the first_spec.mod.