# Gali 2015 - Chapter 8 replication

Hello Dear Professor Pfeifer and community,
I’m trying to replicate the NK baseline model for the open economy, presented in Gali (2015), chapter 8.

As far as I could see, it’s quite similar to the replica offered by Professor Pfeifer in Github.

Dynare reports that “numerical initial values or parameters incompatible with the following equations: 4, 8”.

I have no clue what’s causing it because they are identical to the ones presented in Gali’s book.

Thank you for your time and kind support.
gali_chap8_3.mod (2.6 KB)
gali_chap8_3.mod (2.6 KB)

Your parameter definitions must be sequentially executable:

``````% It replicates the Basic New Keynesian Model from Gali (2015), chapt. 8.

var  y,     Pi_h,       in,     s,
n,    muhat,       yn,     v,
sn,       z,        a;

varexo e_z, e_a, e_v,y_star;
% ----------------------- Parameters -----------------------
parameters  alpha, beta, theta, epsilon, sigma, phi, phi_y, phi_pi,
rho, rho_a, rho_z, rho_v,  mi, psi_ya, psi_y,
lambda, kappa,kappa_upsilon, y_s, upsilon, eta, omegahat,
Phi, sigma_upsilon, gamma_a, gamma_z, gamma_star, psi_star, psi_z;

alpha = 0.25; beta= 0.99; theta= 0.75; epsilon= 9;sigma= 1; phi=5; phi_y=0.5/4;
phi_pi=1.5;

% eta= 4;
rho=-log(beta); rho_a=0.9; rho_z=0.25; rho_v=0.5;
Theta = (1-alpha)/(1-alpha+alpha*epsilon);
mi= log(epsilon/(epsilon-1)); psi_ya = (1+phi)/(sigma*(1-alpha)+phi+alpha);
psi_y= -(1-alpha)*( mi-log(1-alpha) )/( sigma*(1-alpha)+phi+alpha );
lambda = (1-theta)*(1-beta*theta)*Theta/theta;
y_s = psi_y; upsilon = 0.4;         eta = 1;
omegahat = sigma*eta+(1-upsilon)*(sigma*eta-1);
sigma_upsilon = sigma/(1+upsilon*(omegahat-1));
kappa = lambda*(sigma+(phi+alpha)/(1-alpha));
kappa_upsilon = lambda*(sigma_upsilon+(phi+alpha)/(1-alpha));

Phi = 1/(1+upsilon*(omegahat-1));

gamma_a = (1+phi)/(sigma_upsilon*(1-alpha)+phi+alpha);
gamma_star = - upsilon*(omegahat-1)*sigma_upsilon*((1-alpha))/(sigma_upsilon*(1-alpha)+phi+alpha);
gamma_z = - upsilon*omegahat*Phi*(1-alpha)/(sigma_upsilon*(1-alpha)+phi+alpha);

psi_star = (1-upsilon)*Phi-upsilon*gamma_z;
psi_z = (1-upsilon)*Phi-sigma_upsilon*gamma_z;

% ----------------------- Model -----------------------
model(linear);
y = y(+1)- (1/sigma)*(in-Pi_h(+1)) + (upsilon/sigma)*(s(+1)-s)
+ (1-rho_z)*z/sigma                 ;
Pi_h = beta*Pi_h(+1) - lambda*muhat                 ;
y = a + (1-alpha)*n                                             ;
yn = gamma_a*a +  gamma_z*z + gamma_star*y_star             ;

muhat = -(sigma + (phi+alpha)/(1-alpha))*(y-yn) + upsilon*(omegahat-1)*(s-sn)     ;
in = phi_pi*Pi_h + phi_y*(y-yn) + v ;
y_star = 0;
sn = sigma_upsilon*(yn-y_star)-(1-upsilon)*Phi*z;

a = rho_a*a(-1) + e_a;              % TFP schock
z = rho_z*z(-1) + e_z;              % Prefference schock
v = rho_v*v(-1) + e_v;              % Monetary schock

%nx = upsilon*(omegahat/sigma-1)*s - (upsilon/sigma)*z           ;
%muhat = -(sigma_upsilon + (phi+alpha)/(1-alpha))*(y-yn)     ;
end;

% ----------------------- Shocks -----------------------
shocks;
var e_a; stderr 0.0032;
var e_z; stderr 0.0032;
var e_v; stderr 0.0032;
end;

resid(1);
check;

stoch_simul(irf=15);
``````

gali_chap8_3.mod (2.6 KB)

Thank you, professor Pfeifer.

Yet it now has an issue with “One eigenvalues is close to 0/0”. I believe I could handle this by eliminating nominal variables, as I did in chapter 3.

I beg your pardon for bothering, I’m interested to know why your example runs with many nominal variables and mine replication doesn’t.

Usually, it’s a matter of timing or equations used. You need to carefully debug this.