I am getting a little desperate with the current code I am working on.
It deals with two new-keynesian countries trading with each other and constituting a monetary union.
I do not have tricky features in it (no fiscal sector, no nontradables, no sticky wages) and until recently I did not see an issue with the model.
In order to analyse second-order moments I added price dispersion to the model equations.
At a first-order approximation this should not change anything but unfortunately suddenly dynare tells me that I have indeterminacy due to rank failure.
This seems extremely odd to me and I wonder whether there is a simple explanation for this (see code below.
Thanks in advance for any hints/comments!
- Code: Select all
close all; clc;
var %Home country variables
C %consumption
Pie %CPI inflation
w %real wage
mc %real marginal costs
Y %output
x1 x2 %auxiliary variablers (Schmitt-Grohé and Uribe)
pop %optimal price relative to actual price level
Pie_H %Home inflation
b %real debt
d %price dispersion
N %labour
%Foreign country variables
C_star
Pie_star
w_star
mc_star
Y_star
x1_star
x2_star
pop_star
Pie_F
b_star
N_star
d_star
%'global' variables
ToT %terms of trade
R %nom. interest rate
err % monetary policy shock
;
varexo e;
parameters beta sigma kappa epsilon theta phi varphi omegaH omegaF n;
beta = 0.99; %discount factor
sigma = 3; %risk aversion
kappa = 3; %Frisch elasticity
epsilon = 11; %elast. of subs. btw. diff. goods
theta = 0.5; %Calvo
phi = 3; %strength of MP
varphi = 11; %elasticity of subs. btw. H- and F-goods
omegaH = 0.5; %hh steady state import share
omegaF = 0.5; %hh steady state import share in country F
n = 0.5; %size of foreign country
model;
%%%%%%%% HOME/FOREIGN ECONOMY %%%%%%%%%%
C^(-sigma) = beta*((R-0.001*b)/Pie(+1))*C(+1)^(-sigma); %Euler equation
C_star^(-sigma) = beta*((R-0.001*b_star)/Pie_star(+1))*C_star(+1)^(-sigma);
N^(kappa)*C^(sigma) = w; %labour supply
N_star^(kappa)*C_star^(sigma) = w_star;
Y = N/d;
Y_star = N_star/d_star;
d = (1-theta)*pop^(-epsilon) + (theta*Pie_H^(epsilon))*d(-1); %law of motion for price dispersion
d_star = (1-theta)*pop_star^(-epsilon) + (theta*Pie_F^(epsilon))*d_star(-1);
mc = w*((1-omegaH) + omegaH*(ToT^(1-varphi)))^(1/(1-varphi)); %real marginal costs (linear prod. fct) with A=1 (mc=w/A)
mc_star = w_star*((1-omegaF) + omegaF*(ToT^(varphi-1)))^(1/(1-varphi));
x1 = (epsilon/(epsilon-1))*x2; %auxiliary Schmitt-Grohe and Uribe/FOC of firms
x1_star = (epsilon/(epsilon-1))*x2_star;
x1 = Y*(pop^(1-epsilon)) + ((Pie_H(+1)*(pop(+1)/pop))^(epsilon-1))*theta*beta*(1/Pie(+1))*((C(+1)/C)^(-sigma))*x1(+1);
x1_star = Y_star*(pop_star^(1-epsilon)) + ((Pie_F(+1)*(pop_star(+1)/pop_star))^(epsilon-1))*theta*beta*(1/Pie_star(+1))*((C_star(+1)/C_star)^(-sigma))*x1_star(+1);
x2 = Y*(pop^(-epsilon))*mc + ((Pie_H(+1)*(pop(+1)/pop))^(epsilon))*theta*beta*(1/Pie(+1))*((C(+1)/C)^(-sigma))*x2(+1);
x2_star = Y_star*(pop_star^(-epsilon))*mc_star+ ((Pie_F(+1)*(pop_star(+1)/pop_star))^(epsilon))*theta*beta*(1/Pie_star(+1))*((C_star(+1)/C_star)^(-sigma))*x2_star(+1);
1 = theta*Pie_H^(1-epsilon) + (1-theta)*pop^(1-epsilon); %law of motion of inflation
1 = theta*Pie_F^(1-epsilon) + (1-theta)*pop_star^(1-epsilon);
Y = (1-omegaH)*(((1-omegaH) + omegaH*(ToT^(1-varphi)))^(varphi/(1-varphi)))*C + omegaF*(n/(1-n))*(((1-omegaF)*(ToT^(1-varphi)) + omegaF)^(varphi/(1-varphi)))*C_star ; %market clearing
Y_star = omegaH*((1-n)/n)*(((1-omegaH)*(ToT^(varphi-1)) + omegaH)^(varphi/(1-varphi)))*C + (1-omegaF)*(((1-omegaF) + omegaF*(ToT^(varphi-1)))^(varphi/(1-varphi)))*C_star;
Pie = Pie_H*(((1-omegaH) + omegaH*(ToT^(1-varphi)))/((1-omegaH) + omegaH*(ToT(-1)^(1-varphi))))^(1/(1-varphi)); %CPI inflation
Pie_star = Pie_F*(((1-omegaF) + omegaF*(ToT^(varphi-1)))/((1-omegaF) + omegaF*(ToT(-1)^(varphi-1))))^(1/(1-varphi));
ToT/ToT(-1) = Pie_F/Pie_H; %terms of trade definition (ToT=P_F/P_H)
R = (1/beta)*((1-n)*Pie + n*Pie_star)^(phi)+err; %Taylor rule
b + C = ((R-0.001*b)/Pie)*b(-1)+ Y*((1-omegaH) + omegaH*ToT^(1-varphi))^(1/(varphi-1));
(1-n)*b = -n*b_star;
err = 0.7*err(-1) + e;
end;
shocks;
var e=0.01;
end;
initval;
C=((epsilon-1)/epsilon)^(1/(kappa+sigma));
mc = (epsilon-1)/epsilon;
w = mc;
Pie = 1;
R = 1/beta;
ToT = 1;
x2 = C*w;
pop = 1;
Pie_H = 1;
x1 = (epsilon/(epsilon-1))* x2;
Y = C;
N=Y;
C_star=((epsilon-1)/epsilon)^(1/(kappa+sigma));
mc_star = (epsilon-1)/epsilon;
w_star = mc_star;
x2_star = C_star*w_star;
x1_star = (epsilon/(epsilon-1))* x2_star;
pop_star = 1;
Pie_F = 1;
Pie_star = 1;
Y_star = C_star;
N_star = Y_star;
b =0;
b_star = 0;
d = 1;
d_star = 1;
end;
steady;
check;
steady(solve_algo=4);
stoch_simul(periods=200,irf=50,order=1);% pruning, replic=1000);