Difficulty with replicating Greenwood,Hercowitz and Krusell(2000)

Dear all,
Now I update my solution but was struck by the dynare codes. The questions I have now are about the process of the investment-specific technology shock, the q_t+1/q_t=/gammaq may be controversy from the given conditions. I used the derivated and estimated functions of q_t to get q_t+1/q_t but all of them can’t derivate the steady state original equation (3.1).
The attachments including the solution and codes(can’t run so far),
the error message is fowllowing:
line 112, col 9: syntax error, unexpected COMMA, expecting EQUAL
line 112 is : var ze,e,xi;
Any suggestions and advices are welcome.
Best regards,
EK.

I only have the time to quickly skim over it. A couple of remarks:

  1. In terms of strategy, you should either work on an abstract level where you keep functions like the adjustment costs generic and then compute the required derivatives of the function separately. Or you immediately plug in all functional forms. Currently, it is vary hard to keep track.
  2. The Lagrangian should be dated t, not t+1, but this is inconsequential.
  3. You need to be careful with the timing. k_{t+1} in your model is predetermined. It’s fine to use beginning of period stock notation, but you need to be consistent. In (2.4) and (2.5), you take the derivative w.r.t. t+1 variables, which is correct, but then you have a condition suddenly dated t.
  4. Do either use primes or superscripts for next period. Also be consistent with using super- or subscripts for time periods.
  5. (2.4/5) have stray brackets as does T_\lambda in (2.3) (or should it be T(\lambda)?). You also did not define T_\lambda.
  6. The use of lowercase a and uppercase A for the same thing is confusing

In any case, I would recommend starting to implement these conditions in Dynare and see how things turn out.

1 Like

Thank you so much.
1.The primes or superscripts also confused me because the original paper’s denotations are not clear. When I built the Lagrangian equation, I noticed the subscript used the prime terms so I solved the FOC with respect to those prime terms.
2.The use of lowercase a and uppercase A for the same thing is based on the original paper.
I’ll code and update my progress.
Thank you again for your help.

Be that as it may, but you should not repeat the problems of the paper. Try your best to stay consistent and correct.

1 Like

I built a wrong Lagrangian and derived wrongly.
Now I corrected the mistakes and the current problem is whether I should deflate them for the equilibrium.

If you do perfect foresight simulations, you do not necessarily need to remove the trend. For stochastic simulations, you need to do so.

However, the codes don’t run.

What is the error message?

var ze,e,xi;
ERROR: techi.mod: line 112, col 9: syntax error, unexpected COMMA, expecting EQUAL

Please provide the file

Parameters must be explicitly defined.

cs/ys =(theta/(1-theta))*(1-taul)*(1-alphae-alphas)*(1-ls)*(1/ls);

does not have a unique object on the left, but rather the division of two objects.

When I have a unique object on the left, and erase the same expressions

ls = 0.24;
qs=gammaq*exp(1/1-rho);
ys = bhomega /((1-tauk)*alphae*qs*(kesys*ys*gammaq)^(-1));
ls=(theta/(1-theta))*(1-taul)*(1-alphae-alphas)*(1-ls)*(ys/cs);
kssys= (1-tauk)*alphas/(g/beta-(1-deltas));
kss = issys*ys/(g-(1-deltas));
kesys = (1-tauk)*qs*alphae/(gammaq*g/beta-(1-bhomega));
kes = kesys*ys;
ies = iesys*ys;
iss = issys*ys;
cs = ys-ies-iss;
iesys = (gammaq/qs)*(kes/ys)*(gammaq*g-(1-bhomega));
ws = (1-alphas-alphae)*ys/ls;

but I still got warnings as:

ERROR: techi.mod: techi.mod: line 112, cols 1-6: syntax error, unexpected STDERR, expecting CORR or END or VAR

`

shocks;
var ze=1,xi=1;
stderr sigma;
end;

is not valid syntax.
I modified part of it:

%---------The RBC with investment-specific technology shock----------------
%-------------Greenwood,Hercowitz and Krusell(2000EER)---------------------
%-------------------------Enkai Zhang--------------------------------------
%--------------------------------------------------------------------------
%1. Definitions of variables
%--------------------------------------------------------------------------
var y,c,w,l,ie,is,re,rs,q,z,lb,ke,ks,h;
% ae and as are setted as zero in the balanced growth model.
% Each variables are the abbreviations of the elements except h(the utilization rate, y(the output)
% The static variables only enter FOCs at time t are: y c w l ie is re rs q z 
% The purely predetermined variables only enter FOCs at time t and t-1,t are: lb
% The predetermined and forward-looking variable only enter FOCs at time t-1,t, t+1 is: h

varexo ze,xi;
%ze represents zeta,is the total factor productivity(TFP)shock,
%e represents eta,is the specific investment-equipment productivity shock,

parameters beta,% the stochastic discount factor
theta, % the preference parameter
alphae,alphas,% alphae: the share of equipment capital in output
% alphas: the share of structure capital in output
deltas,% deltas: the depreciation rate of structures 
bhomega,b,omega,% bhomega=b*hs^omega;b and omega: the parameters affecting the utilization rate
gammaq,gammaz,% the gross growth rates of z and q
g,% g:the balanced growth rate for output,consumption,wage,structures capital and investments
tauk,taul, % tauk taul: the tax rates of capital and individual income
sigma,rho,% sigma rho: the parameter affecting the investment techonology shock 
iesy,issy,ys,ies,iss,kes,kss; %since they appear in model block, it is necessary to define SS as parameters

%--------------------------------------------------------------------------
% 2.Calibration
%--------------------------------------------------------------------------
beta = 0.97;
theta = 0.40;
alphae = 0.18;
alphas = 0.12;
deltas = 0.056;
bhomega= 0.2;  
omega = 1.59;% 1/(bhomega/omega)*bhomega=1.6129;
gammaq = 1.032;
gammaz = 1.0030; % Based gammaq,alphas and alphae.
g = 1.0124;
tauk = 0.53;
taul = 0.4;
sigma = 0.035;
rho =0.64;
iesys = 0.073;
issys = 0.041;
% The above data is based on the original paper----------------------------
%--------------------------------------------------------------------------
% 3.Steady state
%--------------------------------------------------------------------------
ls = 0.24;
qs=gammaq*exp(1/1-rho);
kesys = (1-tauk)*qs*alphae/(gammaq*g/beta-(1-bhomega));
ys = bhomega /((1-tauk)*alphae*qs*(kesys*ys*gammaq)^(-1));
kssys= (1-tauk)*alphas/(g/beta-(1-deltas));
kss = issys*ys/(g-(1-deltas));
kes = kesys*ys;
ies = iesys*ys;
iss = issys*ys;
cs = ys-ies-iss;
iesys = (gammaq/qs)*(kes/ys)*(gammaq*g-(1-bhomega));
ls=(theta/(1-theta))*(1-taul)*(1-alphae-alphas)*(1-ls)*(ys/cs);
ws = (1-alphas-alphae)*ys/ls;
%--------------------------------------------------------------------------
% 4.Model
%--------------------------------------------------------------------------
model;
theta/c=lb; % Consumption
w=(1-theta)/((1-taul)*(1-l)*lb); % Labor and wage
re= b*h^(omega-1)/(q*(1-tauk));% Equipment rate
lb(-1)=beta/g*lb*((1-tauk)*h*q(-1)*re+(1-b*h^(omega))*(q(-1)/q));
lb(-1)=beta/g*lb*((1-tauk)*rs+(1-deltas));
re=alphae*z*h*ke^(alphae-1)*ks^alphas*gammaq^(alphae-1)*g^(alphae+alphas-1)*l^(1-alphas-alphae);
rs=alphas*z*(h*ke)^(alphae)*ks^(alphas-1)*gammaq^(alphae)*g^(alphae+alphas-1)*l^(1-alphas-alphae);
w=(1-alphae-alphas)*z*(h*ke)^(alphae)*ks^alphas*gammaq^(alphae)*g^(alphae+alphas-1)*l^(-alphas-alphae);
y=z*(h*ke)^(alphae)*ks^(alphas)*gammaq^(alphae)*g^(alphae+alphas-1)*l^(1-alphas-alphae);
y=c+ie+is;
ke*gammaq*g=(1-b*h(-1)^(omega))*ke(-1)+ie*q*gammaq^(-1);
ks*g=(1-deltas)*ks(-1)+is;
log(z)=log(gammaz)+ze;
log(q)=log(gammaq)+xi/(1-rho);

end;

%--------------------------------------------------------------------------
% 4.Computation
%--------------------------------------------------------------------------
initval;
ze= 0;
y = log(ys);
c = log(cs);
ie = log(ies);
is = log(iss);
ke = log(kes);
ks = log(kss);
w = log(ws);
l = log(ls);
q = log(qs);
lb = 1;
rs = 0;
re = 0;
end;

steady;
check;
%--------------------------------------------------------------------------
%5. Shocks
%--------------------------------------------------------------------------
shocks;
var ze=1;
var xi=1;
end;
%--------------------------------------------------------------------------
%6.Lauch solving procedure
%--------------------------------------------------------------------------
stoch_simul(order=1,irf=20)
y,c,ie,is,ke,ks,l,g;

Now the problem is that

ys = bhomega /((1-tauk)*alphae*qs*(kesys*ys*gammaq)^(-1));

has ys on both sides.

Thank you so much for your efforts.
I typed this because there will be kes in this equation but kes =kesys*ys, which implies ys should appear earlier than it.
ys = bhomega /((1-tauk)*alphae*qs*(kes*gammaq)^(-1));
when I input this equation and got the
ERROR: techi.mod: line 113, cols 1-6: syntax error, unexpected STDERR, expecting CORR or END or VAR.
But I’ve set it much earlier as
sigma = 0.035;
I will rearrange the steady state equations and see what will happen.

I realized the biggest problem is the time setting, exp()stuff and the initval setting.

I’ve solved the time setting. The questions I have are about how to use the steady state block to get the initval and how to guess the initial values.
The problem I met in the steady state is
"ERROR: in the 'steady_state' block, variable 'ys' is undefined in the declaration of variable 'kes'"
However, the steady state model I had doesn’t have an independent equation of y_ast
or other variables, they are circulated. Any indications will be helpful. I think I missed some clues but no idea what they are.
I calculated the ratios but have no idea about the use of them. The other problem is about how to make the best use of them.
codes are here:
techi.mod (4.7 KB)

You are using ys in the definition of a variable before it is computed. Steady state files must provide the steady state explicitly, not implicitly. In standard models, the “big ratios” are easy to compute. The problem usually is to pin down labor in steady state.

Vielen Dank! I also thought of your solution, but the problem I have is: no matter which equation I put the first, ys must be put before any other equations. If I use ls to express ys, there will be a cs that is affected by ys.

        qs=gammaq*exp(1/1-rho);
        csys = 1-issys-iesys;
        cs = csys*ys
        ys= 1-(1-theta)*cs/(ls*theta*(1-taul)*(1-alpha));
        kesys = (1-tauk)*qs*alphae/(gammaq*g/beta-(1-us));
        kes = kesys*ys;
        ys = us/((1-tauk)*alphae*qs*(kes*gammaq)^(-1));
        iesys = (gammaq/qs)*(kesys)*(gammaq*g-(1-us));
        kss = ys*(1-tauk)*alphas/(g/beta-(1-deltas));
        iss = kss*(g-(1-deltas)) ;
        ies = ys-iss-cs;

Dynare of GHK2000.pdf (98.1 KB)

And if I don’t use the steady_state model, there is an error warning as the following:

Some element of Newton direction isn't finite. Jacobian maybe singular or there is a problem with initial values

     出错 solve1 (line 107)
        [x,f,fvec,check]=lnsrch1(xold,fold,g,p,stpmax,func,j1,j2,varargin{:});

    出错 dynare_solve (line 150)
            [x,info]=solve1(func,x,j1(r(i):r(i+1)-1),j2(r(i):r(i+1)-1),jacobian_flag, ...

    出错 evaluate_steady_state (line 66)
                [ys,check] = dynare_solve([M.fname '_static'],...

    出错 steady_ (line 54)
    [steady_state,params,info] = evaluate_steady_state(oo_.steady_state,M_,options_,oo_,~options_.steadystate.nocheck);

    出错 steady (line 81)
    [steady_state,M_.params,info] = steady_(M_,options_,oo_);

    出错 techi (line 211)
    steady; 
    出错 dynare (line 180)
    evalin('base',fname) ;

I checked the manual and did according to it and other posts but still got a lot of bugs.

You need to continue solving for the steady state. You get an equation for l that depends on the ratios. The goal must be to plug in until you get an equation in l only. That equation may be nonlinear, but one can use a numerical solver to solve it

Dank fur ihr Antwort.
Yes, you are right, the value of lss is given as lss=0.24 or can be represented by other parameters.
My current steady_state_model block looks like the following:

steady_state_model;
ieoy=0.073;
isoy=0.041;
qss=1;
zss=1;
coy=1-ieoy-isoy;
lss=1-coy*(1-theta)/theta*(1-taul)*(1-alpha);
isoks=g+deltas-1;
ksoy=isoy/isoks;
ieoke=(gammaq/qss)*(gammaq*g-(1-uss/omega));
keoy=ieoy/ieoke;
hss=(qss*(1-tauk)*alphae/keoy*gammaq)^(1/omega);
yss=(gammaq)^(alphae/(1-alpha))*g^(-1)*(hss*keoy)^(alphae/(1-alpha))*(ksoy)^(alphas/(1-alpha))*lss;
wss=(1-alpha)*yss*lss^(-1);
kess=keoy*yss;
ress=alphae*yss*(hss*kess)/gammaq;
ksss=ksoy*yss;
rsss=alphas*yss*(ksss*g)^(-1);
iess=ieoy*yss;
isss=isoy*yss;
css=coy*yss;
lbss=1/css;
end;
steady;

I read the manual of dynare, there is no statement telling you how to set the initval if you have a steady_state_model block.
However, I have the problem with the model part. In my model, the general one with adjustment costs and the steady state one without. What should I set the model?
The other is regarding the utilization rate,h, which appears in the detrended equilibrium model independently, when I set b=0.2, but it doesn’t work.
techi.mod (5.2 KB)
Solution for dynare.pdf (118.3 KB)
Cheers.