DSGE Estimation - Financial Accelerator

Hi,

I was trying to replicate the DSGE estimation of The financial accelerator in an estimated New Keynesian model. This paper applies the Bernanke-Gertler-Gilchrist financial accelerator model to Canadian data.

I followed Johannes Pfeifer’s guide, and firstly did the stochastic simulation by directly using the paper’s empirical results as parameters and initial values. My simulation successfully gave the IRFs.

However, when I tried to estimate the parameters, I used

estimated_params_init(use_calibration); end;

Dynare continuously told me that “POSTERIOR KERNEL OPTIMIZATION PROBLEM!”. At this point, I was confused because my stochastic simulation is okay, and my initial values for estimation directly come from the calibration. I thought it should be all right, but not. If possible, can anyone have a look at my file “bgg.mod” and give me some hints? The block for estimation starts with line 150. Thanks.
bgg.mod (3.8 KB)

The data file is missing.

Thanks for your reply, Professor. Below is my data file.
est_data.mat (8.2 KB)

Please take a look at Pfeifer(2013): “A Guide to Specifying Observation Equations for the Estimation of DSGE Models” sites.google.com/site/pfeiferecon/Pfeifer_2013_Observation_Equations.pdf . You are performing a fundamental mistake by parameters depend on estimated parameters and not using either model local variables or a steady_state_model-block. It also seems that you are matching zero mean model variables to non-zero mean data.

Hi Professor,

Thanks for your reply. I checked my previous codes and your guide, and found two mistakes. Specifically, the steady state values (ss) for my endogenous variables should not be used in the initval; end; block. The reason is that my model’s equations are log-linearized. So, y,c,etc. are the conventional hat notation, that is the percentage deviation from the ss. Therefore, I specified their initial values as 0, that is the equilibrium.

Second, because of my model’s equations, I need to specify the relationship between my endogenous variables and the data. For instance, y_obs = y*yss + yss; However, after this modification, Dynare still told me “POSTERIOR KERNEL OPTIMIZATION PROBLEM!”. At this point, I’m unclear about the meaning of your comment “You are performing a fundamental mistake by parameters depend on estimated parameters and not using either model local variables or a steady_state_model-block.”?

If possible, can you have a look at my attached new file and give me some hints? Thank you.
bgg.mod (4.0 KB)

xi_ss = (theta - 1)/theta;
R_ss = pi_ss/beta;

f_ss = (S*R_ss)/pi_ss;
z_ss = f_ss - 1 + delta;

lambdac = 1/(1 + b_ss*(pi_ss/(pi_ss - beta))^(gamma - 1));
lambdam = lambdac * b_ss * (pi_ss/(pi_ss - beta))^(gamma);

ky_ratio = (alpha*xi_ss)/z_ss;
cy_ratio = 1 - delta*ky_ratio;

whlambda = ((1 - alpha)*lambdac*xi_ss) / cy_ratio;

hss = whlambda/(eta+whlambda);
Ass = 1;

yss = Ass*hss*(ky_ratio)^(alpha/(1-alpha));
iss = delta*ky_ratio*yss;

css = yss - iss;
mss = css*b_ss*(pi_ss/(pi_ss-beta))^gamma;

are all dependent objects. Thus, it should be

%% Endogenous variables
var y, c, m, i, h, k, n, w, z, R, f, q, lambda, xi, pi_v, mu, e, b, A, x,
    y_obs, i_obs, m_obs, pi_v_obs, R_obs;

%% Shocks
varexo eps_R, eps_e, eps_b, eps_A, eps_x;

%% parameters
parameters beta, eta, theta, delta, b_ss, pi_ss, nu, S, psi, chi, alpha,
gamma, phi, rho_pi, rho_y, rho_mu, sigma_R, rho_A, sigma_A, rho_b,
sigma_b, rho_e, sigmae, rho_x, sigma_x
;

%% parameters' values
beta=0.9928;
eta=1.315;
theta=6;
delta=0.025;
b_ss=0.062;
pi_ss=1.0079;
nu=0.9728;
S=1.0075;

psi=0.0420;
chi=0.5882;
alpha=0.3384;
gamma=0.0598;
phi=0.7418;
rho_pi=1.4059;
rho_y=0.2947;
rho_mu=0.6532;
sigma_R=0.0058;
rho_A=0.7625;
sigma_A=0.0096;
rho_b=0.7206;
sigma_b=0.0103;
rho_e=0.6156;
sigmae=0.0073;
rho_x=0.6562;
sigma_x=0.0331;


%% model
model;
#xi_ss = (theta - 1)/theta;
#R_ss = pi_ss/beta;

#f_ss = (S*R_ss)/pi_ss;
#z_ss = f_ss - 1 + delta;

#lambdac = 1/(1 + b_ss*(pi_ss/(pi_ss - beta))^(gamma - 1));
#lambdam = lambdac * b_ss * (pi_ss/(pi_ss - beta))^(gamma);

#ky_ratio = (alpha*xi_ss)/z_ss;
#cy_ratio = 1 - delta*ky_ratio;

#whlambda = ((1 - alpha)*lambdac*xi_ss) / cy_ratio;

#hss = whlambda/(eta+whlambda);
#Ass = 1;

#yss = Ass*hss*(ky_ratio)^(alpha/(1-alpha));
#iss = delta*ky_ratio*yss;

#css = yss - iss;
#mss = css*b_ss*(pi_ss/(pi_ss-beta))^gamma;

((1-gamma)*lambdac - 1)*c = gamma*lambda + ((lambdam*(R_ss - 1))/R_ss)*
    (b + (gamma-1)*m) - gamma*e;

(gamma*R)/(R_ss - 1) = b + c - m;

(whlambda/(eta + whlambda))*h = (eta/(eta + whlambda))*(w + lambda);
% Replace the h in C.3 by B.11

y = alpha*k(-1) + (1-alpha)*h + (1-alpha)*A;

y = cy_ratio*c + (1 - cy_ratio)*i;
% iy_ratio = 1 - cy_ratio

w = y + xi - h;

z = y + xi - k(-1);

mu = m - m(-1) + pi_v;

R = rho_pi*pi_v + rho_mu*mu + rho_y*y + sigma_R*eps_R;

f = (z_ss*z)/f_ss + ((1-delta)/f_ss)*q - q(-1);

q = chi*(i - k(-1)) - x;

pi_v = beta*pi_v(+1) + ((1-beta*phi)*(1-phi)*xi)/phi;

lambda(+1) = lambda - R + pi_v(+1);

k = delta*i + delta*x + (1-delta)*k(-1);

f(+1) = R - pi_v(+1) + psi*(q + k - n);

n/(nu*f_ss) = 2*f - (R(-1) - pi_v) - psi*(k(-1) + q(-1)) + (psi + 1)*n(-1);
% CD page 9 Table 1 directly gives that kn_ratio is 2.

% Below is AR1 processes for the four endogenous shocks.
e = rho_e*e(-1) + sigmae*eps_e;

b = rho_b*b(-1) + sigma_b*eps_b;

A = rho_A*A(-1) + sigma_A*eps_A;

x = rho_x*x(-1) + sigma_x*eps_x;

y_obs = y*yss + yss; 

i_obs = i*iss + iss;
m_obs = m*mss +mss;

pi_v_obs = pi_v*pi_ss + pi_ss;
R_obs = R*R_ss + R_ss;

end;


%% initial values for endogenous variables
initval;

xi=0;
R=0;
f=0;
z=0;

h=0;
y=0;
A=0;

eps_R=0;
eps_e=0;
eps_b=0;
eps_A=0;
eps_x=0;

end;

%% find steady state (ss)
steady;

%% shocks
shocks;

var eps_R; stderr 1;
var eps_e; stderr 1;
var eps_b; stderr 1;
var eps_A; stderr 1;
var eps_x; stderr 1;

end;

%% stochastic simulation
stoch_simul(periods = 1000, irf=40,  order=1);


%% estimation
estimated_params;

% NAME, INITVAL, LB, UB, PRIOR_SHAPE, PRIOR1, PRIOR2, PRIOR3, PRIOR4, JSCALE
psi, , 0, 1;% inv_gamma_pdf, 0.04, 1;
chi, , 0, 1;% inv_gamma_pdf, 0.5, 1;
gamma, , 0, 1;% inv_gamma_pdf, 0.05, 1;
alpha, , 0, 1;% inv_gamma_pdf, 0.3, 1; % beta distribution is a suitable prior for proportions.
phi, , 0, 1;% inv_gamma_pdf, 0.5, 1;

rho_pi, , 0, 3;% inv_gamma_pdf, 1.2, 1;
rho_y, , 0, 1;% inv_gamma_pdf, 0.25, 1;
rho_mu, , 0, 1;% inv_gamma_pdf, 0.6, 1;
sigma_R, , 0, 1;% inv_gamma_pdf, 0.004, 1;
rho_A, , 0, 1;% inv_gamma_pdf, 0.7, 1;

sigma_A, , 0, 1;% inv_gamma_pdf, 0.007, 1;
rho_b, , 0, 1;% inv_gamma_pdf, 0.6, 1;
sigma_b, , 0, 1;% inv_gamma_pdf, 0.009, 1;
rho_e, , 0, 1;% inv_gamma_pdf, 0.5, 1;
sigmae, , 0, 1;% inv_gamma_pdf, 0.006, 1;

rho_x, , 0, 1;% inv_gamma_pdf, 0.6, 1;
sigma_x, , 0, 1;% inv_gamma_pdf, 0.025, 1;

end;

estimated_params_init(use_calibration);
end;

varobs y_obs, i_obs, m_obs, pi_v_obs, R_obs;

estimation(datafile=est_data,mode_compute=4);