EDIT: for those of you who encounter the same issue, see Johanne’s PullRequest below which fixes the bug. I believe it will be “officially fixed” in the next tagged Dynare version (4.7.0?). Besides that, the way I specify the “measurement errors” is not ideal. See the post I marked as “solution” below

I’m trying to estimate some parameters of a plain vanilla RBC model, but with the particle filter provided by Dynare. The estimation works for `order = 1`

case (which I believe is just Kalman filter), but fails on initializing the draws for `order = 2`

.

Here copy-pasted is the mod file, (and I’ll attach it with the “fake data” I created.

```
%----------------------------------------------------------------
% 1. Defining variables
%----------------------------------------------------------------
var y c k z c_obs k_obs;
varexo e e_m1 e_m2;
%----------------------------------------------------------------
% 2. Parameters values
%----------------------------------------------------------------
parameters beta delta alpha rho sigma;
alpha = 0.4;
beta = 0.96;
delta = 0.10;
rho = 0.7;
sigma = 0.01;
%----------------------------------------------------------------
% 3. Model (Euler Equation, Budget Constraint, Laws of Motion
%----------------------------------------------------------------
model;
c^(-1) = beta*c(+1)^(-1)*(alpha*exp(z(+1))*(k^(alpha-1))+1-delta); % Euler
c+k-(1-delta)*k(-1) = y; % Budget Constraint
y = exp(z)*(k(-1)^alpha); % Production Function
z = rho*z(-1)+e; % TFP AR(1)
c_obs = c - steady_state(c) + e_m1;
k_obs = k - steady_state(k) + e_m2;
end;
%----------------------------------------------------------------
% 4. Computation
%----------------------------------------------------------------
%%Steady State
steady_state_model;
k = ((1/beta-1+delta)/alpha)^(1/(alpha-1));
c = k^alpha-delta*k;
y = k^alpha;
z = 0;
c_obs = 0;
k_obs = 0;
end;
shocks;
var e = sigma^2;
var e_m1 = 1e-5;
var e_m2 = 1e-5;
end;
steady;
stoch_simul(order = 2, nograph);
%----------------------------------------------------------------
% 5. Estimation
%----------------------------------------------------------------
estimated_params;
alpha, 0.5, uniform_pdf, 0.5, 0.173;
beta, 0.9, uniform_pdf, 0.75, 0.144;
end;
varobs c_obs, k_obs;
estimation(datafile = './fake_data_2.csv', order = 2);
```

I think the model I set makes sense, and there’s no stochastic singularity: I have three shocks (one shock for TFP, two “measurement errors” for `c`

and `k`

observations. And I’m trying to estimate `alpha`

and `beta`

. And I know the identification is fine because my hand-written codes give the correct estimation results, so I guess it’s just the way I use Dynare is wrong.

The output and the error message I got is

```
Estimation using a non linear filter!
You are using a gradient-based mode-finder. Particle filtering introduces discontinuities in the
objective function w.r.t the parameters. Thus, should use a non-gradient based optimizer.
Please choose a mode-finder:
0 - Continue using gradient-based method (it is most likely that you will no get any sensible result).
6 - Monte Carlo based algorithm
7 - Nelder-Mead simplex based optimization routine (Matlab optimization toolbox required)
8 - Nelder-Mead simplex based optimization routine (Dynare's implementation)
9 - CMA-ES (Covariance Matrix Adaptation Evolution Strategy) algorithm
Please enter your choice: 7
EIGENVALUES:
Modulus Real Imaginary
0.7 0.7 0
0.8821 0.8821 0
1.26 1.26 0
1.804e+16 -1.804e+16 0
There are 2 eigenvalue(s) larger than 1 in modulus
for 2 forward-looking variable(s)
The rank condition is verified.
Initial value of the log posterior (or likelihood): -Inf
```

I was wondering

- the prior that I set is tight enough so the log posterior shouldn’t be -Inf at any possible sampling point. How can it even happen?
- are there any ways that we can skip the mode computation? And directly dive into Random-Walk Metropolis Hastings?
- maybe it’s too much to ask, but are there any commands that I used in the file is wrong? Or am I missing any option settings?

Thanks!

fake_data_2.csv (8.4 KB) rbc.mod (1.9 KB)