Error in GK Model


#1

Hi everyone,
I’m trying to replicate the paper “Financial Intermediation and Credit Policy in Business Cycle Analysis”(Mark Gertler and Nobuhiro Kiyotaki,2010).I wrote the formula to the file as described in the article. However, I fail to reach a steady state. Results shows that the steady state contains NaN or Inf.
I am a total beginner with Dynare and this is my attempt at coding a model.
Any help would be greatly appreciated.
Many thanks,
Xiang

Since I am a new user and can’t upload files, I paste the contents of the file into the body and ask for help.

GK.mod
var Y C L I K Z D Ni Nn Si Sn Qi Qn R Rb v vb vs lambdai lambdan A psi;
varexo e1 e2;
parameters alpha gamma beta pii pin chi epsilon theta omega xi rhoa rhopsi sigmaa sigmapsi delta sigma;
alpha = 0.33;
gamma = 0.5;
beta = 0.99;
pii = 0.25;
pin = 1-pii;
chi = 5.013;
epsilon = 0.1;
theta = 0.1288;
omega = 0.5;
xi = 0.0019;
rhoa=0.95;
sigmaa=0.02;
rhopsi=0.66;
sigmapsi=-0.05;
delta = 0.027;
sigma = 0.975;

model;
Y = A*(K^alpha)L^(1-alpha);
K(+1) = psi
(I+(1-delta)K);
Y = C+(1+(I/I(-1)-1)^2)I;
beta
((C(+1)-gamma
C)^(-1)-betagamma(C(+2)-gammaC(+1))^(-1))R(+1)=(C-gammaC(-1))^(-1)-betagamma*(C(+1)-gammaC)^(-1);
D = (Qi
Si-Ni)+(QnSn-Nn);
Z = alpha
A*(L/K)^(1-alpha);
Qi = 1+(I/I(-1)-1)^2+I/I(-1)2(I/I(-1)-1)-beta*((C(+1)-gammaC)^(-1)-betagamma*(C(+2)-gammaC(+1))^(-1))/((C-gammaC(-1))^(-1)-betagamma(C(+1)-gammaC)^(-1))(I(+1)/I)^22(I(+1)/I-1);
Si = I+(1-delta)piiK;
Sn = (1-delta)pinK;
(1-alpha)(Y/L)((C-gammaC(-1))^(-1)-betagamma*(C(+1)-gammaC)^(-1))=chiL^epsilon;
lambdai = (vs/Qi-vb)/(theta*(1-omega)- (vs/Qi-vb));
lambdan = (vs/Qn-vb)/(theta*(1-omega)- (vs/Qn-vb));
vb-v = (thetaomega(piilambdai+pinlambdan))/(1+piilambdai+pinlambdan);
vb = Rb(+1)(beta((C(+1)-gammaC)^(-1)-betagamma*(C(+2)-gammaC(+1))^(-1))/((C-gammaC(-1))^(-1)-betagamma(C(+1)-gammaC)^(-1)))(pii*((1-sigma)+sigma*(vb+lambdai*(vb-thetaomega)))+pin((1-sigma)+sigma*(vb+lambdan*(vb-thetaomega))));
v = R/Rb
vb;
vs = (beta*((C(+1)-gammaC)^(-1)-betagamma*(C(+2)-gammaC(+1))^(-1))/((C-gammaC(-1))^(-1)-betagamma(C(+1)-gammaC)^(-1)))(pii*((1-sigma)+sigma*(vb+lambdai*(vb-thetaomega)))+pin((1-sigma)+sigma*(vb+lambdan*(vb-thetaomega))))(Z(+1)+(1-delta)(piiQi+pinQn))psi(+1);
Qi
Si = ((vb-theta
omega)Ni-thetaomegapiiD/(1+piilambdai+pinlambdan))/(theta*(1-omega)-(vs/Qi-vb));
QnSn = ((vb-thetaomega)Nn-thetaomegapinD/(1+piilambdai+pinlambdan))/(theta*(1-omega)-(vs/Qn-vb));
Ni = pii*((Z+(1-delta)Qi)psi(sigma+xi)Si(-1)-sigmaRD(-1));
Nn = pin*((Z+(1-delta)Qn)psi(sigma+xi)Sn(-1)-sigmaRD(-1));
A = rhoaA(-1)+e1;
psi = rhopsi
psi(-1)+e2;
end;

initval;
K = 30;
C = 3;
I = 0.9;
A = 1;
psi = 1;
R = 0.01;
D = 27;
e1 = 0;
e2 = 0;
end;

steady;
check;

shocks;
var e1 = sigmaa^2;
var e2 = sigmapsi^2;
end;

stoch_simul;

The results.

??? Error using ==> print_info at 90
The steady state contains NaN or Inf

Error in ==> steady at 104
print_info(info,options_.noprint, options_);

Error in ==> GK1 at 305
steady;

Error in ==> dynare at 235
evalin(‘base’,fname) ;


#2

An obvious issue is that you either need to define the exogenous process in terms of log productivity or use exp(A) in the production function. Otherwise, the steady state for A is 0 and therefore also for output.


#3

Thanks for your kindness. I have corrected the mistakes as you pointed, but I still fail to reach a steady state. Results also shows that the steady state contains NaN or Inf.
Looking forward to your help.

GK.mod
var Y C L I K Z D Ni Nn Si Sn Qi Qn R Rb v vb vs lambdai lambdan A psi;
varexo e1 e2;
parameters alpha gamma beta pii pin chi epsilon theta omega xi rhoa rhopsi sigmaa sigmapsi delta sigma;
alpha = 0.33;
gamma = 0.5;
beta = 0.99;
pii = 0.25;
pin = 1-pii;
chi = 5.013;
epsilon = 0.1;
theta = 0.1288;
omega = 0.5;
xi = 0.0019;
rhoa=0.95;
sigmaa=0.02;
rhopsi=0.66;
sigmapsi=-0.05;
delta = 0.027;
sigma = 0.975;

model;
Y = A*(K^alpha)L^(1-alpha);
K(+1) = psi
(I+(1-delta)K);
Y = C+(1+(I/I(-1)-1)^2)I;
beta
((C(+1)-gamma
C)^(-1)-betagamma(C(+2)-gammaC(+1))^(-1))R(+1)=(C-gammaC(-1))^(-1)-betagamma*(C(+1)-gammaC)^(-1);
D = (Qi
Si-Ni)+(QnSn-Nn);
Z = alpha
A*(L/K)^(1-alpha);
Qi = 1+(I/I(-1)-1)^2+I/I(-1)2(I/I(-1)-1)-beta*((C(+1)-gammaC)^(-1)-betagamma*(C(+2)-gammaC(+1))^(-1))/((C-gammaC(-1))^(-1)-betagamma(C(+1)-gammaC)^(-1))(I(+1)/I)^22(I(+1)/I-1);
Si = I+(1-delta)piiK;
Sn = (1-delta)pinK;
(1-alpha)(Y/L)((C-gammaC(-1))^(-1)-betagamma*(C(+1)-gammaC)^(-1))=chiL^epsilon;
lambdai = (vs/Qi-vb)/(theta*(1-omega)- (vs/Qi-vb));
lambdan = (vs/Qn-vb)/(theta*(1-omega)- (vs/Qn-vb));
vb-v = (thetaomega(piilambdai+pinlambdan))/(1+piilambdai+pinlambdan);
vb = Rb(+1)(beta((C(+1)-gammaC)^(-1)-betagamma*(C(+2)-gammaC(+1))^(-1))/((C-gammaC(-1))^(-1)-betagamma(C(+1)-gammaC)^(-1)))(pii*((1-sigma)+sigma*(vb+lambdai*(vb-thetaomega)))+pin((1-sigma)+sigma*(vb+lambdan*(vb-thetaomega))));
v = R/Rb
vb;
vs = (beta*((C(+1)-gammaC)^(-1)-betagamma*(C(+2)-gammaC(+1))^(-1))/((C-gammaC(-1))^(-1)-betagamma(C(+1)-gammaC)^(-1)))(pii*((1-sigma)+sigma*(vb+lambdai*(vb-thetaomega)))+pin((1-sigma)+sigma*(vb+lambdan*(vb-thetaomega))))(Z(+1)+(1-delta)(piiQi+pinQn))psi(+1);
Qi
Si = ((vb-theta
omega)Ni-thetaomegapiiD/(1+piilambdai+pinlambdan))/(theta*(1-omega)-(vs/Qi-vb));
QnSn = ((vb-thetaomega)Nn-thetaomegapinD/(1+piilambdai+pinlambdan))/(theta*(1-omega)-(vs/Qn-vb));
Ni = pii*((Z+(1-delta)Qi)psi(sigma+xi)Si(-1)-sigmaRD(-1));
Nn = pin*((Z+(1-delta)Qn)psi(sigma+xi)Sn(-1)-sigmaRD(-1));
log(A) = rhoalog(A(-1))+e1;
log(psi) = rhopsi
log(psi(-1))+e2;
end;

initval;
K = 30;
C = 3;
I = 0.9;
A = 1;
psi = 1;
R = 0.01;
D = 27;
e1 = 0;
e2 = 0;
end;

steady;
check;

shocks;
var e1 = sigmaa^2;
var e2 = sigmapsi^2;
end;

stoch_simul;

And the results shows:
??? Error using ==> print_info at 90
The steady state contains NaN or Inf

Error in ==> steady at 104
print_info(info,options_.noprint, options_);

Error in ==> GK1 at 305
steady;

Error in ==> dynare at 235
evalin(‘base’,fname) ;


#4

Please upload the file or post the code as code markup. In the post above, for example all multiplications are lost.

Given the experience with the wrong equations you had before, you should check the correctness of all equations again.


#5

Many thanks for your reply and help! But I am a new user and can’t upload files, so could you please give me your personal E-mail that I can send you my code? Or you can touch me via 1344966742@qq.com.
Thank you very much.


#6

I changed the settings. You should be able to upload files now.


#7

GK1.mod (2.3 KB)
Thank you very much for your patience and fast replies. I have upload the file, please help me to point the mistakes. I really need your help.


#8

You need to initialize all variables that cannot be 0 in steady state. For example, you did not set L.


#9

Thanks a lot for your patience. I have corrected the mistakes you have pointed, and rerun the code, but still not succeed. It can not find the steady state. I wrote the formula to the file as described in the article. So, I don’t know the reason. Hope for your help.

The reult shows that:

??? Error using ==> print_info at 83
Impossible to find the steady state. Either the model
doesn’t have a steady state, there are an infinity of
steady states, or the guess values are too far from the
solution

Error in ==> steady at 104
print_info(info,options_.noprint, options_);

Error in ==> GK1 at 320
steady;

Error in ==> dynare at 235
evalin(‘base’,fname) ;


#10

Please provide the most recent file version


#13

Thanks a lot for your kindness. The most recent file version is upload. CGK.mod (2.7 KB)


#14

You should focus on the equations with the biggest residuals. In particular

Equation number 12 : -11.9177
Equation number 13 : -49.0846
Equation number 14 : 3.4949
Equation number 15 : 10.3468
Equation number 17 : 8.9858
Equation number 18 : 3.4376
Equation number 19 : -9.9871
Equation number 20 : -4.5444
Equation number 21 : -5

#15

CGK.mod (2.7 KB)
I find its steady state, but Blanchard Kahn conditions are still not satisfied.


#16

model_diagnostics returns:

MODEL_DIAGNOSTICS: The following endogenous variables aren't present at the current period in the model:
Rb