Endogenous Growth Model Example

Hi,

I am fairly new to dynare. I see a ton of examples on how to solve DSGE models here, but haven’t really found one that solves/simulates something akin to an endogenous growth model. Are there any examples of simple models being solved in dynare?

I apologize if the question is vague, I haven’t finished building my model yet, but I am wondering if its worth looking into Dynare for it

It depends on the context. Most of growth modeling is done in continuous time, which Dynare does not do. If you are considering discrete time models, there is the issue that Dynare mostly does perturbation techniques, which are done around a well-defined steady state (which is typically the balanced growth path). That solution technique may not be useful for endogenous growth models due to the solution becoming arbitrarily inaccurate as time progresses.
Thus, there is no general answer on whether Dynare can solve the particular model you have in mind.

I see. Thanks for the reply.

The kind of model I had in mind was the Aghion & Howitt models of technical change in discrete time. (Ref: https://www.brown.edu/Departments/Economics/Faculty/Peter_Howitt/publication/ahhandbook.pdf).

I am a bit lost on this since I do not have much experience with the coding/simulation side of things. Largely I want to look at the model’s transition dynamics between different parameter values. If not in dynare, then could you recommend other places where I could look to to start?

Thanks

If I see it correctly, the model features a steady state in growth rates. Thus, its transition dynamics can be studied similar to https://github.com/JohannesPfeifer/DSGE_mod/blob/master/Solow_model

Is the first time I try to model an (exogenous) growth model with dynare. I tried to follow the code you offered in the link above. Here is my code:

UBI_aspirations.mod (1.9 KB)
I get an error that I don’t know how to solve. Could anyone give me a tip? Thank you.

Error using check_input_arguments
PERFECT_FORESIGHT_SOLVER: ‘oo_.endo_simul’ has wrong size. Did you run ‘perfect_foresight_setup’ ?

Error in perfect_foresight_solver (line 34)
check_input_arguments(options_, M_, oo_);

Error in UBI_aspirations.driver (line 220)
perfect_foresight_solver;

Error in dynare (line 281)
evalin(‘base’,[fname ‘.driver’]);

The model I’m trying to introduce in dynare is the one in the following pdf, but assuming gamma_h and g = 0.
UBI-draft-forum.pdf (53.6 KB)

As the message says, you forgot the

perfect_foresight_setup;

command.

Sorry for that… Of course, this was the problem.
I get a new error indicating variable k (capital) does not appear at current period. In the equations, it appears as k and k(-1). I tried forwarding the feasibility constraint one period ahead so k(+1), decided at t, appears. But I still get the same error.
Why is this?

PERFECT_FORESIGHT_SETUP: error in model specification : the variable(s)
k don’t appear as current period variables.

This is the full code:

@#define simulation_periods=100

//Define variables:

var l, w, s, k, L, cy, co, r;

predetermined_variables k;

varexo A {A} (long_name=‘Labor augmenting technology’)
;

parameters rho, phi, alp, n, gA, gam;

rho = .5; //rho subjective discount factor (for future C)
phi = 3.05; //phi preference for leisure
alp = .5; //alpha (alp in the code) Cobb-doublas production function parameter
n = 1; //population size
gA= .99; //gA exogenous technological growth
gam =.75; //gam aspirations term

model;

wl-s=cy; //young p. budget constraint
(1+r(+1))s=co(+1); //old p. budget constraint
co(+1)/(cy-gam
cy(-1))=rho
(1+r(+1)); //s f.o.c. households
w/(cy-gamcy(-1))=phi/(1-l); //l f.o.c. households
(alp
(k(-1)/(AL))^(alp-1))=(1+r); //K f.o.c. firms
((k(-1)/(A
L))alp)+(alp(k(-1)/(AL))^(alp-1))(-k(-1)/(AL))=w; //(AL) f.o.c. firms
n
l=L; //labour market clearing
//ns=k; //financial market clearing
((k(-1)^alp)
(AL)^(1-alp))-k-ncy=nco;//feasibility constraint or national identity
//A=gA
A(-1); //exogenous growth process

        //f10=(rho*(w*l-gam*cy(-1)))/(1+rho)-s;     //"definition" (9) from comparative statics section
        //f11=(w+phi*(s+gam*cy(-1)))/((1+phi)*w)-l; //"definition" (10) from comparative statics section
        //f12=(1+r)*s(-1)-co;   //old p. budget constraint at t-1
        //f13=n*s(-1)-k(-1);

end;

initval;

w = .2;
s = 1;
k = 1;
L = .33;
l = 33;
cy = .25;
co = .25;
r = 3;
A = 0.01;
end;

shock_vals_A=cumprod((1+gA)*ones(@{simulation_periods},1))

shocks;

var A;
periods 1:@{simulation_periods};
values (shock_vals_A);
end;

//endval;
//???
//end;

perfect_foresight_setup(periods=@{simulation_periods});
perfect_foresight_solver;

rplot k;
rplot cy;
rplot s;
rplot w;

Given that you are already using the standard Dynare stock at the end of period timing, do not use

Oh, I see. Thank you so much… Now I get the following problem:

Iter: 50, err. = 3.27697e+36, time = 0
Warning: Matrix is singular to working precision.

In sim1>lin_solve (line 194)
In sim1 (line 127)
In perfect_foresight_solver_core (line 102)
In perfect_foresight_solver (line 63)
In UBI_aspirations.driver (line 212)
In dynare (line 281)

Total time of simulation: 0.537.
Maximum number of iterations is reached (modify option maxit).

Simulation of the perfect foresight model failed!
Switching to a homotopy method…
Iter. | Lambda | status | Max. residual
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 | 0.50000 | failed | 1.099959e+36
2 | 0.25000 | failed | 3.409060e+35
3 | 0.12500 | failed | 7.357349e+34
4 | 0.06250 | failed | 4.566655e+33
5 | 0.03125 | failed | 7.424933e+32
6 | 0.01562 | failed | 1.957527e+33
7 | 0.00781 | failed | 1.349953e+33
8 | 0.00391 | failed | 7.593108e+32
9 | 0.00195 | failed | 4.143680e+32
10 | 0.00098 | failed | 2.250387e+32
11 | 0.00049 | failed | 1.219793e+32
12 | 0.00024 | failed | 6.600476e+31
13 | 0.00012 | failed | 4.688065e+31
14 | 0.00006 | failed | 4.766130e+31
15 | 0.00003 | failed | 4.804827e+31
16 | 0.00002 | failed | 4.823514e+31
++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Failed to solve perfect foresight model

Total computing time : 0h00m07s
Note: warning(s) encountered in MATLAB/Octave code

Where may I look to solve it? I tried increasing the interation number up to 500 and the problem persists.
Again, thank you…

You need to provide the updated version. Does the model satisfy the Blanchard-Kahn conditions?

This is the version I’m using now. I substituted the two budget constraints (for young and old) by the life-time budget constraint so I could use, then, both the feasibility c. and the market clearings.
How can I verify if the Blanchard-Kahn c. are satisfied for a growth model without steady state?

@#define simulation_periods=100

//Define variables:

var l, w, s, k, L, cy, co, r;

//predetermined_variables k;

varexo A {A} (long_name=‘Labor augmenting technology’)
;

parameters rho, phi, alp, n, gA, gam;

rho = .5; //rho subjective discount factor (for future C)
phi = 3.05; //phi preference for leisure
alp = .5; //alpha (alp in the code) Cobb-doublas production function parameter
n = 1; //population size
gA= .99; //gA exogenous technological growth
gam =.75; //gam aspirations term

model;

    //w*l-s=cy;                                   //young p. budget constraint
    //(1+r(+1))*s=co(+1);                         //old p. budget constraint 

cy+co(+1)/(1+r(+1))=wl; //life-time budget constraint
co(+1)/(cy-gam
cy(-1))=rho*(1+r(+1)); //s f.o.c. households
w/(cy-gamcy(-1))=phi/(1-l); //l f.o.c. households
(alp
(k(-1)/(AL))^(alp-1))=(1+r); //K f.o.c. firms
((k(-1)/(A
L))alp)+(alp(k(-1)/(AL))^(alp-1))(-k(-1)/(AL))=w; //(AL) f.o.c. firms
n
l=L; //labour market clearing
ns=k; //financial market clearing
((k(-1)^alp)
(AL)^(1-alp))-k-ncy=nco;//feasibility constraint or national identity
//A=gA
A(-1); //exogenous growth process

        //f10=(rho*(w*l-gam*cy(-1)))/(1+rho)-s;     //"definition" (9) from comparative statics section
        //f11=(w+phi*(s+gam*cy(-1)))/((1+phi)*w)-l; //"definition" (10) from comparative statics section
        //f12=(1+r)*s(-1)-co;   //old p. budget constraint at t-1
        //f13=n*s(-1)-k(-1);

end;

initval;

w = .2;
s = 1;
k = 1;
L = .33;
l = 33;
cy = .25;
co = .25;
r = 3;
A = 0.01;
end;

shock_vals_A=cumprod((1+gA)*ones(@{simulation_periods},1))

shocks;

var A;
periods 1:@{simulation_periods};
values (shock_vals_A);
end;

//endval;
//???
//end;

maxit_=100;
perfect_foresight_setup(periods=@{simulation_periods});
perfect_foresight_solver(maxit=500);

rplot k;
rplot cy;
rplot s;
rplot w;

I used a simpler version of the model (without aspirations) in Matlab and it works fine. It simulates the first 100 periods. I attach it here for reference
main1reduced.m (2.2 KB)
UBI1reduced.m (691 Bytes)
Adding aspirations incorporate richer interactions and I’d really like to use dynare. For the moment, I still get the same error. So I’m back to the version already uploaded in this forum:
UBI_aspirations.mod (2.1 KB)

You did not attempt to stationarize the model and did not provide a terminal steady state. That cannot work.

Thank you so much, Johannes.
I thought I could explore x initial periods of the economy without doing it.
I tried to stationarize the model using NB Toolbox to use the outcome equations in dynare.
However, it tells me “No balanced growth path exist”.
Should I suppose that the model is not properly defined by the equations I’m using?

Yes, that is probably the case. Automatic detrending, like numerical steady, finding often does not work due to user errors.
Also note that Dynare allows to specify nonstationary models by using trend_var. See e.g.