Non-Linear DSGE Estimation

Hi, I am trying to replicate the detrended DSGE model from chapter 4 of the Handbook of Bayesian Econometrics by Marco Del Negro and Fran Shordfeide (2010). I can get it to run a stochastic simulation, where it successfully finds a steady state, but when I try to an estimation using my own data, it says a steady state cannot be found from my initial values.

Im not sure what the problem is here. I determined the initial values using the means of historical series, with level variables being taken as a proportion of GDP. The data was log differenced. I suspect the problem might lie here? But I am new to dynare so it might well just be shoddy code. If so could someone maybe point out the flaws?

Here are the two .mod’s:
1.) Simulation

var C H W R K I Y A B a ydiff idiff;

varexo eps_a eps_b;

parameters alpha beta nu gamma delta b_star rho_a rho_b;
    delta = 0.025;  beta = 0.99;         nu = 0.7;      alpha = 0.66;
    b_star = 1;     gamma = exp(0.003);  rho_a = 0.95;  rho_b = 0.9;

initval;
    R = 0.11;  Y = 1;  H = 0.36;  C = 0.78;  I = 0.22;   
    W = 0.62;  K = 2;  A = 1;     B = 1;     a = 0;
end;

model;
    1/C = beta * ((1/C(+1)) * exp(-a(+1)) * (R(+1) + (1 - delta)));
    W/C = (1/B) * (H/B)^(1/nu);
    W = alpha * (Y/H);
    R = (1 - alpha) * (Y/K) * exp(a);
    Y = (H^alpha) * (K(-1) * exp(-a)) ^ (1-alpha);
    Y = C + I;
    K = (1 - delta) * K(-1) * exp(-a) + I;
    log(A) = rho_a * log(A(-1)) + eps_a;
    a = log(gamma) + (rho_a - 1) * log(A(-1)) + eps_a;
    log(B) = (1-rho_b) * log(b_star) + rho_b*log(B(-1)) + eps_b;
    ydiff = log(Y) - log(Y(-1));  
    idiff = log(I) - log(I(-1));          
end;

steady(maxit = 1000);
check;

shocks;
    var eps_a; stderr 0.01;
    var eps_b; stderr 0.01;
end;

stoch_simul(order = 2, irf = 40);

2.) Estimation

var C H W R K I Y A B a ydiff idiff;

varexo eps_a eps_b;

parameters alpha beta nu gamma delta b_star rho_a rho_b;
    delta = 0.025; beta = 0.99;

initval;
    R = 0.11;  Y = 1;  H = 0.36;  C = 0.78;  I = 0.22;   
    W = 0.62;  K = 2;  A = 1;     B = 1;     a = 0;
end;

model;
    1/C = beta * ((1/C(+1)) * exp(-a(+1)) * (R(+1) + (1 - delta)));
    W/C = (1/B) * (H/B)^(1/nu);
    W = alpha * (Y/H);
    R = (1 - alpha) * (Y/K) * exp(a);
    Y = (H^alpha) * (K(-1) * exp(-a)) ^ (1-alpha);
    Y = C + I;
    K = (1 - delta) * K(-1) * exp(-a) + I;
    log(A) = rho_a * log(A(-1)) + eps_a;
    a = log(gamma) + (rho_a - 1) * log(A(-1)) + eps_a;
    log(B) = (1-rho_b) * log(b_star) + rho_b*log(B(-1)) + eps_b;
    ydiff = log(Y) - log(Y(-1));  
    idiff = log(I) - log(I(-1));          
end;

shocks;
    var eps_a; stderr 1;
    var eps_b; stderr 1;
end;

estimated_params;
    alpha, 0.66, beta_pdf, 0.66, 0.02;
    gamma, 0.003, normal_pdf, 0, 0.01; 
    nu, 0.8, gamma_pdf, 2, 1;
    rho_a, 0.95, beta_pdf, 0.95, 0.02;
    rho_b, 0.95, beta_pdf, 0.8, 0.1;
    stderr eps_a, 0.01, inv_gamma_pdf, 0.01, 4;
    stderr eps_b, 0.01, inv_gamma_pdf, 0.01, 4;
end;

varobs ydiff idiff;

estimation(datafile = mydata, nobs = 115, mh_replic = 5000, order = 2);

Thanks!

Generally, for estimation you should aim at providing steady states not just initial values as the latter may not work for other parameter values. That is the case in your files. You use

gamma, 0.003

to start estimation, but exp(0.003) for simulation.

Thank you. I’ve managed to get things working already and noticed the mistake I made there. But I’ve yet to get figure out the steady states. Have been looking into a steadystate.m file. Struggling with that though.