Hello all,

I have a simple model based on Leeper. The model runs and it produces the IRFs that I expected it to produce. There is no residual and I have derived the analytical steady states.

```
var c n k z r w y q b g g_shock tau_k tau_l t t_shock;
varexo e_z e_g e_t;
parameters beta theta delta rho a psi psi_g g_ss b_ss tau_k_ss tau_l_ss;
beta = 0.99;
delta = 0.025;
theta = 0.36;
a = 1.72;
rho = 0.95;
psi = .25;
psi_g = .15;
g_ss = 0.0922;
b_ss = 0.3396;
tau_k_ss = 0.184;
tau_l_ss = 0.223;
steady_state_model;
z = 0;
t_shock = 0;
g_shock = 0;
tau_k = tau_k_ss;
tau_l = tau_l_ss;
r = (1 / (beta * (1 - tau_k_ss))) + delta - 1;
q = beta;
n = 1 / (1 + a * ((1 - g_ss)/((1 - tau_l_ss) * (1 - theta)) - (delta * theta)/((1 - tau_l_ss) * (1 - theta) * r)));
k = (r/(theta * n^(1 - theta)))^(1/(theta - 1));
w = (1 - theta) * k^(theta) * n^(-theta);
y = k^(theta) * n^(1 - theta);
g = g_ss * y;
c = y - delta * k - g;
b = b_ss * y;
t = tau_l * w * n + tau_k * r * k + q * b - b - g;
end;
model;
// First order conditions for households.
(((1 - tau_l) * w) / c) = a / (1 - n);
beta * ((1/c(+1)) * (1 - tau_k(+1)) * (r(+1) + 1 - delta)) = (1 / c);
beta * (1/c(+1)) = (q / c);
// Household budget constraints.
c + k + q * b = (1 - tau_l) * w * n + (1 - tau_k) * r * k(-1) + (1 - delta) * k(-1) + b(-1) + t;
// Firm production.
y = exp(z) * k(-1)^(theta) * n^(1 - theta);
w = (1 - theta) * exp(z) * k(-1)^(theta) * n^(-theta);
r = theta * exp(z) * k(-1)^(theta - 1) * n^(1 - theta);
z = rho*(z(-1)) + e_z;
// Government budget constraint.
tau_l * w * n + tau_k * r * k(-1) + q * b = b(-1) + g + t;
// Government rules
log(t / steady_state(t)) = - psi * log((b / steady_state(b))) - psi_g * log((y/steady_state(y)))+ t_shock;
log(g / steady_state(g)) = - psi * log((b / steady_state(b))) - psi_g * log((y/steady_state(y))) + g_shock;
log(tau_l / steady_state(tau_l)) = psi * log((b / steady_state(b))) + psi_g * log((y/steady_state(y)));
log(tau_k / steady_state(tau_k)) = psi * log((b / steady_state(b))) + psi_g * log((y/steady_state(y)));
// Gov shocks
t_shock = rho*(t_shock(-1)) + e_t;
g_shock = rho*(g_shock(-1)) + e_g;
end;
model_diagnostics;
steady;
resid;
shocks;
var e_z = 0.01^2;
var e_t = 0.01^2;
var e_g = 0.01^2;
end;
stoch_simul(periods=2000, drop=200,irf = 100,order=1);//, replic=10000);
```

I extended the model into a two country model. Everything else is the same. I derived the analytical steady state and there is no residual, but I am getting the error of “Blanchard & Kahn conditions are not satisfied: no stable equilibrium.”

It is basically the same model, with almost the same analytical steady state.

```
var c_1 c_2 n_1 n_2 k_1 k_2 z_1 z_2 r_1 r_2 w_1 w_2 y_1 y_2 b_1 b_2 b_1_1 b_1_2 b_2_2 b_2_1 q_1 q_2 sigma_1 sigma_2 tau_n_1 tau_k_1 g_1 tau_n_2 tau_k_2 g_2 g_shock_1 g_shock_2 T_1 T_2 T_shock_1 T_shock_2;
varexo e_z_1 e_z_2 e_sigma_1 e_sigma_2 e_g_1 e_g_2 e_t_1 e_t_2;
parameters beta theta delta rho rhostar a pac omega omegastar b_1_2_bar b_2_1_bar psi psi_g tau_k_1_ss tau_n_1_ss tau_k_2_ss tau_n_2_ss g_1_ss g_2_ss b_1_ss b_2_ss;
beta = 0.99;
delta = 0.025;
theta = 0.36;
a = 1.72;
rho = 0.95;
rhostar = 0.95;
pac = 0.00074;
omega = 0.98;
b_1_2_bar = 0;
b_2_1_bar = 0;
omegastar = 0.98;
psi = 0.25;
psi_g = 0.15;
tau_k_1_ss = 0.184;
tau_n_1_ss = 0.223;
tau_k_2_ss = 0.184;
tau_n_2_ss = 0.223;
g_1_ss = 0.0922;
g_2_ss = 0.0922;
b_1_ss = 0.3396;
b_2_ss = 0.3396;
steady_state_model;
z_1 = 0;
sigma_1 = 0;
T_shock_1 = 0;
g_shock_1 = 0;
tau_k_1 = tau_k_1_ss;
tau_n_1 = tau_n_1_ss;
r_1 = (1 / (beta * (1 - tau_k_1))) + delta - 1;
q_1 = beta;
n_1 = 1 / (1 + a * ((1 - g_1_ss)/((1 - tau_n_1) * (1 - theta)) - (delta * theta)/((1 - tau_n_1) * (1 - theta) * r_1)));
k_1 = (r_1/(theta * n_1^(1 - theta)))^(1/(theta - 1));
w_1 = (1 - theta) * k_1^(theta) * n_1^(-theta);
y_1 = k_1^(theta) * n_1^(1 - theta);
g_1 = g_1_ss * y_1;
c_1 = y_1 - delta * k_1 - g_1;
b_1 = b_1_ss * y_1;
T_1 = tau_n_1 * w_1 * n_1 + tau_k_1 * r_1 * k_1 + q_1 * b_1 - b_1 - g_1;
b_1_1 = b_1;
b_1_2 = 0;
z_2 = 0;
sigma_2 = 0;
T_shock_2 = 0;
g_shock_2 = 0;
tau_k_2 = tau_k_2_ss;
tau_n_2 = tau_n_2_ss;
r_2 = (1 / (beta * (1 - tau_k_2))) + delta - 1;
q_2 = beta;
n_2 = 1 / (1 + a * ((1 - g_2_ss)/((1 - tau_n_2) * (1 - theta)) - (delta * theta)/((1 - tau_n_2) * (1 - theta) * r_2)));
k_2 = (r_2/(theta * n_2^(1 - theta)))^(1/(theta - 1));
w_2 = (1 - theta) * k_2^(theta) * n_2^(-theta);
y_2 = k_2^(theta) * n_2^(1 - theta);
g_2 = g_2_ss * y_2;
c_2 = y_2 - delta * k_2 - g_2;
b_2 = b_2_ss * y_2;
T_2 = tau_n_2 * w_2 * n_2 + tau_k_2 * r_2 * k_2 + q_2 * b_2 - b_2 - g_2;
b_2_1 = 0;
b_2_2 = b_2;
end;
model;
/*
Home Economy - Denoted by country 1
*/
y_1 = exp(z_1) * k_1(-1)^theta * n_1^(1 - theta);
/*
Constraints for home Economy
*/
c_1 + k_1 + q_1 * b_1_1 + q_2 * b_1_2 + 0.5 * pac * (b_1_2 - b_1_2_bar)^2 = (1 - tau_n_1) * w_1 * n_1 + (1 - tau_k_1) * r_1 * k_1(-1) + (1 - delta) * k_1(-1) + b_1_1(-1) + b_1_2(-1) + T_1;
/*
FOC - intra temporal, capital accumulation, and bond accumulation
*/
a / (1 - n_1) = (w_1 / c_1) * (1 - tau_n_1);
1 / c_1 = beta * ((1 / c_1(+1)) * (1 - tau_k_1(+1)) * (r_1(+1) + 1 - delta));
beta * (1 /c_1(+1)) = ((q_2 + pac * (b_1_2 - b_1_2_bar)) / c_1);
beta * (1 /c_1(+1)) = (q_1 / c_1);
/*
Prices
*/
r_1 = theta * exp(z_1) * k_1(-1)^(theta - 1) * n_1^(1-theta);
w_1 = (1 - theta) * exp(z_1) * k_1(-1)^(theta) * n_1^(-theta);
/*
TFP
*/
z_1 = rho * z_1(-1) + exp(sigma_1) * e_z_1;
sigma_1 = omega * sigma_1(-1) + e_sigma_1;
/*
Government of country 1 BC
*/
tau_n_1 * w_1 * n_1 + tau_k_1 * r_1 * k_1(-1) + q_1 * b_1 = b_1(-1) + g_1 + T_1;
// Government rules
log(T_1 / steady_state(T_1)) = - psi * log((b_1 / steady_state(b_1))) - psi_g * log((y_1/steady_state(y_1))) + T_shock_1;
log(g_1 / steady_state(g_1)) = - psi * log((b_1 / steady_state(b_1))) - psi_g * log((y_1/steady_state(y_1))) + g_shock_1;
log(tau_n_1 / steady_state(tau_n_1)) = psi * log((b_1 / steady_state(b_1))) + psi_g * log((y_1/steady_state(y_1)));
log(tau_k_1 / steady_state(tau_k_1)) = psi * log((b_1 / steady_state(b_1))) + psi_g * log((y_1/steady_state(y_1)));
// Gov shocks
T_shock_1 = rho*(T_shock_1(-1)) + e_t_1;
g_shock_1 = rho*(g_shock_1(-1)) + e_g_1;
/*
Foreign Economy denoted by country 2
*/
y_2 = exp(z_2) * k_2(-1)^theta * n_2^(1 - theta);
/*
Constraints for foreign Economy
*/
c_2 + k_2 + q_2 * b_2_2 + q_1 * b_2_1 + 0.5 * pac * (b_2_1 - b_2_1_bar)^2 = (1 - tau_n_2) * w_2 * n_2 + (1 - tau_k_2) * r_2 * k_2(-1) + (1 - delta) * k_2(-1) + b_2_2(-1) + b_2_1(-1) + T_2;
/*
FOC - intra temporal, capital accumulation, and bond accumulation
*/
a / (1 - n_2) = (w_2 / c_2) * (1 - tau_n_2);
1 / c_2 = beta * ((1 / c_2(+1)) * (1 - tau_k_2(+1)) * (r_2(+1) + 1 - delta)) ;
beta * (1 /c_2(+1)) = ((q_1 + pac * (b_2_1 - b_2_1_bar)) / c_2);
beta * (1 /c_2(+1)) = (q_2 / c_2);
/*
Prices
*/
r_2 = theta * exp(z_2) * k_2(-1)^(theta - 1) * n_2^(1-theta);
w_2= (1 - theta) * exp(z_2) * k_2(-1)^(theta) * n_2^(-theta);
/*
TFP
*/
z_2 = rho * z_2(-1) + exp(sigma_2) * e_z_2;
sigma_2 = omega * sigma_2(-1) + e_sigma_2;
/*
Government of country 2 BC
*/
tau_n_2 * w_2 * n_2 + tau_k_2 * r_2 * k_2(-1) + q_2 * b_2 = b_2(-1) + g_2 + T_2;
// Government rules
log(T_2 / steady_state(T_2)) = - psi * log((b_2 / steady_state(b_2))) - psi_g * log((y_2/steady_state(y_2))) + T_shock_2;
log(g_2 / steady_state(g_2)) = - psi * log((b_2 / steady_state(b_2))) - psi_g * log((y_2/steady_state(y_2))) + g_shock_2;
log(tau_n_2 / steady_state(tau_n_2)) = psi * log((b_2 / steady_state(b_2))) + psi_g * log((y_2/steady_state(y_2)));
log(tau_k_2 / steady_state(tau_k_2)) = psi * log((b_2 / steady_state(b_2))) + psi_g * log((y_2/steady_state(y_2)));
// Gov shocks
T_shock_2 = rho*(T_shock_2(-1)) + e_t_2;
g_shock_2 = rho*(g_shock_2(-1)) + e_g_2;
/*
Bond market clearing
*/
b_1 = b_1_1 + b_2_1;
b_2 = b_2_2 + b_1_2;
end;
model_diagnostics;
steady;
resid;
shocks;
var e_z_1 = 0.01^2;
var e_t_1 = 0.01^2;
var e_g_1 = 0.01^2;
var e_z_2 = 0.01^2;
var e_t_2 = 0.01^2;
var e_g_2 = 0.01^2;
end;
stoch_simul(periods=2000, drop=200,irf = 100,order=1);
```

Can anyone point to what might be the problem? I have a feeling that it has something to do with international bonds - but I used a portfolio adjustment cost as suggested by Schmidt-Grohe.

Does home household buying home bond also need to have portfolio adjustment cost? Because right now, I only put the cost when they hold international bonds.

Thanks!