# Error in GK Model

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;

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

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

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.

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.

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;

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

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

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.

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.

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

GK1.mod (2.3 KB)

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

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

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

Please provide the most recent file version

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

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
``````

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

`model_diagnostics` returns:

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