Initial negative infinity log posterior on non-linear estimation

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

  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;

% 4. Computation

%%Steady State

  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;

var e = sigma^2;
var e_m1 = 1e-5;
var e_m2 = 1e-5;


stoch_simul(order = 2, nograph);

% 5. Estimation
alpha, 0.5, uniform_pdf, 0.5, 0.173;
beta, 0.9, uniform_pdf, 0.75, 0.144;

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

         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

  1. 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?
  2. are there any ways that we can skip the mode computation? And directly dive into Random-Walk Metropolis Hastings?
  3. 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?

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

Hi Johannes,

I try to find a working example for non-linear particle filter estimation, and I was looking at the test files of Dynare. I think I might have found an issue here

This line fails exactly for the same -Inf starting point when running on my laptop. Is it a Dynare bug? Or did I use the wrong test file? Or did I use the test file incorrectly? Do tests under /particle work for the current version?

There seem to be two issues here:

  1. You must specify the measurement error using the Dynare interface: rbc.mod (1.9 KB)
  2. There seems to be a bug:

Gotcha, thanks for that prompt PR.
I was wondering where did you specify the measurement error terms in the file you attached above? It seems that you removed the two “measurement error shocks” I set manually, but I don’t know where the replacements are.


var e = sigma^2;
var c_obs = 1e-5;
var k_obs = 1e-5;

Great, I manually updated the Dynare files using your branch, and it’s currently working.
Final question on this: are there any differences in specifying the measurement errors between the way I did and the way you suggested? Thanks!

In terms of results, no. In terms of internal Dynare handling, yes.