Extensions to the basic Neoclassical Model

This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location where you will have to reset your password.
Forum rules
This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location (https://forum.dynare.org) where you will have to reset your password.

Extensions to the basic Neoclassical Model

Postby erikignasi » Sun Dec 11, 2016 2:44 pm

Hello everyone,

I’m currently adding extensions to the basic Neoclassical Business Cycle Model (say RBC model with annual data) with labour augmented technology introduced in the production function.
These model extensions are based on Eric Sims’ lecture notes available here under “RBC Extensions”: http://www3.nd.edu/~esims1/grad_macro_16.html
In particular, I’m taking the extensions on indivisibility of labour (pages 1-5) and Habit formation (pages 11-13).
Also, one “extension” on the “hidden” calibration of labour supply available under “RBC Model (quantitative)” in the same link from above (pages 9-11).
I managed to solve the standard case without any extension successfully for the country of Spain and the UK. Then I’ve tried to adapt these 3 extensions to my standard case.

The way I proceeded is as follows:
1. Take the Dynare script from the standard case and add the new parameters or variables resulting from the model extension. So I just included the new variables/parameters and its corresponding calibrated value in the preamble block.
2. Adapt the characteristic equations (from the standard case) to the model extension. Hence, the new set of characteristic equations contains the new parameters and variables.
3. Adapt the external Steady State solver Matlab function (from the standard case) to the model extension. These extensions usually affect the characteristic equations such that I needed to resolve the model with the new functional specifications (i.e. new labour supply equation or new Euler consumption).

In my opinion this is the logical way to proceed. However, once I do run the extended models on Dynare (with the changed scripts and Matlab functions) I do get different errors and I don’t understand why they appear. I’ve revised the characteristic equations and the corresponding resolved model, so its steady state solution, and I didn’t spot anything wrong so far.

I’m not sure whether Dynare cannot solve the model because of the changes I’ve undertaken in the characteristic equations in the script or rather because of the changes in the Matlab function with the new Steady State solution. I’d say the main root of the problem is this latter reason because when I undertake model extensions where the steady state solution isn’t affected (for instance adding other shocks different to the standard technology/TFP shock), Dynare solves the model correctly and I get an output.

This is the case for example of adding a preference shock (pages 29 -32 from the same document). Here I do get an output from Dynare (maybe because of the reason just exposed: I don’t change the Matlab SS function here because in the SS there are no shocks).

Going back to the 3 extensions where I have problems, I’m attaching the Dynare script for the extension of indivisibility of labour and habit formation and its corresponding Matlab functions. Plus I attach the Dynare file (with the SS solution already integrated in the SteadyState model block) for the preference shock (where Dynare did give me an output, and the SS solution is the same as in the standard case), so it is easier to track down the differences between extensions and spot possible errors. Note that all the files are for the specific case of Spain.

Also, here are the errors I get from Dynare when running the extended models:
1. “Hidden” Labour supply calibration

Configuring Dynare ...
[mex] Generalized QZ.
[mex] Sylvester equation solution.
[mex] Kronecker products.
[mex] Sparse kronecker products.
[mex] Local state space iteration (second order).
[mex] Bytecode evaluation.
[mex] k-order perturbation solver.
[mex] k-order solution simulation.
[mex] Quasi Monte-Carlo sequence (Sobol).
[mex] Markov Switching SBVAR.

Starting Dynare (version 4.4.3).
Starting preprocessing of the model file ...
Found 13 equation(s).
Evaluating expressions...done
Computing static model derivatives:
- order 1
Computing dynamic model derivatives:
- order 1
Processing outputs ...done
Preprocessing completed.
Starting MATLAB/Octave computing.

Residuals of the static equations:

Equation number 1 : 0
Equation number 2 : -1.4462
Equation number 3 : 0
Equation number 4 : 0
Equation number 5 : 0
Equation number 6 : 0
Equation number 7 : 0
Equation number 8 : 0
Equation number 9 : 0
Equation number 10 : 0
Equation number 11 : 0
Equation number 12 : 0
Equation number 13 : 0


Error using print_info (line 72)
The steadystate file did not compute the steady state

Error in resid (line 112)
print_info(info,options_.noprint, options_)

Error in steady (line 90)
resid;

Error in Neoclassical_Model_SP_Hidden_Chi_1 (line 155)
steady;

Error in dynare (line 180)
evalin('base',fname) ;

2. Indivisibility of Labour

Configuring Dynare ...
[mex] Generalized QZ.
[mex] Sylvester equation solution.
[mex] Kronecker products.
[mex] Sparse kronecker products.
[mex] Local state space iteration (second order).
[mex] Bytecode evaluation.
[mex] k-order perturbation solver.
[mex] k-order solution simulation.
[mex] Quasi Monte-Carlo sequence (Sobol).
[mex] Markov Switching SBVAR.

Starting Dynare (version 4.4.3).
Starting preprocessing of the model file ...
Found 13 equation(s).
Evaluating expressions...done
Computing static model derivatives:
- order 1
Computing dynamic model derivatives:
- order 1
Processing outputs ...done
Preprocessing completed.
Starting MATLAB/Octave computing.


Residuals of the static equations:

Equation number 1 : 0
Equation number 2 : -89.4122
Equation number 3 : 0
Equation number 4 : 0
Equation number 5 : 0
Equation number 6 : 0
Equation number 7 : 0
Equation number 8 : 0
Equation number 9 : 0
Equation number 10 : 0
Equation number 11 : 0
Equation number 12 : 0
Equation number 13 : 0


Error using print_info (line 72)
The steadystate file did not compute the steady state

Error in resid (line 112)
print_info(info,options_.noprint, options_)

Error in steady (line 90)
resid;

Error in Neoclassical_Model_SP_Indivisible (line 150)
steady;

Error in dynare (line 180)
evalin('base',fname) ;

3. Habit Formation

Configuring Dynare ...
[mex] Generalized QZ.
[mex] Sylvester equation solution.
[mex] Kronecker products.
[mex] Sparse kronecker products.
[mex] Local state space iteration (second order).
[mex] Bytecode evaluation.
[mex] k-order perturbation solver.
[mex] k-order solution simulation.
[mex] Quasi Monte-Carlo sequence (Sobol).
[mex] Markov Switching SBVAR.

Starting Dynare (version 4.4.3).
Starting preprocessing of the model file ...
ERROR: Neoclassical_Model_SP_HabitNEW.mod: line 20, cols 1-6: syntax error, unexpected NAME

Error using dynare (line 174)
DYNARE: preprocessing failed


I would be really thankful for any advice or help on this. Any insight counts for me and I’m glad that this forum does work so well, given I’ve always got a reply to my queries.

PD: I apologise if some of my questions are a bit naïve in some aspects, however I’m very new to Dynare (since I’ve started my Bachelorthesis in Septmeber) and hence I appreciate your comprehension.
Attachments
Neoclassical_Model_SP_PreferenceShock.mod
The Steady State solution (reflected in the external Matlab function in the other files) is already integrated in the script for this particular case. This solution is the same as the one in the standard case with no extensions, given in the Steady State there are no shock such that the model solution is not affected.
(1.83 KiB) Downloaded 78 times
Neoclassical_Model_SP_HabitNEW_steadystate.m
(1.78 KiB) Downloaded 77 times
Neoclassical_Model_SP_HabitNEW.mod
(923 Bytes) Downloaded 81 times
Neoclassical_Model_SP_Indivisible_steadystate.m
(1.69 KiB) Downloaded 73 times
Neoclassical_Model_SP_Indivisible.mod
(823 Bytes) Downloaded 68 times
erikignasi
 
Posts: 10
Joined: Sun Oct 02, 2016 4:49 pm
Location: Barcelona

Re: Extensions to the basic Neoclassical Model

Postby jpfeifer » Wed Dec 14, 2016 9:36 pm

1. For the habit one you are missing a semicolon at the end of the first equation (line 19).
2. For the indivisible labor one your steady state computation seems wrong. Check your computations. https://github.com/JohannesPfeifer/DSGE_mod/blob/master/Hansen_1985/Hansen_1985.mod might also be helpful.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Extensions to the basic Neoclassical Model

Postby erikignasi » Tue Dec 20, 2016 9:38 am

Thanks for your answer Dr. Pfeifer.

However, with respect to your points and referring to my previous post, when I run the "Hidden calibration" Dynare script (basically I just change the functional specification of labour) I still get the same type of error: the residuals of the static equations are non-zero and Dynare fails to solve the model accordingly.

I've revised with my tutor the Steady State solution of this "Hidden calibration" extension to the standard model as well as contrasted the solution with lecture notes from the University of Oxford (refer to page 21 and 22)http://www.nuff.ox.ac.uk/users/bilbiie/teaching_files/notes_oxford_06.pdf.

In other words, I'm pretty sure the Steady State solution I do specify in the external matlab function is correct, as well as the order with which I specify the Steady State equations shouldn't be the problem.

Hence, if the Characteristic equations in the Dynare Script + the corresponding Steady State equations in the Matlab function are correct, what is wrong and why can't Dynare solve the model? I did also revise the way I'm putting the equations into "plain text" in the Dynare script, and it seems allright:

Code: Select all
 // Dynare Script:

// 1) Definition of variables
 
var y c k invest l y_l z log_y log_c log_invest log_l log_k log_y_l;
varexo e;
parameters alppha betta delta psii chii rho sigma;
 
// 2) Calibration
 
alppha = 0.36657;
betta = 0.95563;
delta = 0.03852;
psii = 8.41149695;
chii = 0.5;
rho = 0.961879;
sigma = 0.017812;
 
// 3) Model
 
model;
(1/c) = betta*(1/c(+1))*(1+alppha*(k^(alppha-1))*(exp(z(+1))*l(+1))^(1-alppha)-delta);
psii*c*(l^chii) = (1-alppha)*(k(-1)^alppha)*(exp(z)^(1-alppha))*(l^(-alppha));
c+invest = y;
y = (k(-1)^alppha)*(exp(z)*l)^(1-alppha);
invest = k-(1-delta)*k(-1);
y_l = y/l;
z = rho*z(-1)+e;
log_y=log(y);
log_invest=log(invest);
log_c=log(c);
log_l=log(l);
log_k=log(k);
log_y_l=log(y_l);
end;
 
// 4) Computation

shocks;
var e = sigma^2;
end;

steady;
check;

stoch_simul(order=1,hp_filter=100);


% Matlab Steady State function:

function [ ys,check ] = Neoclassical_Model_SP_Hidden_Chi_0_5_steadystate( ys,exo )
% function [ ys,check ] =Neoclassical_Model_SP_Hidden_Chi_0_5_steadystate( ys,exo )
% computes the steady state for the Neoclassical_Model_SP_Hidden_Chi_0_5.mod and uses a numerical
% solver to do so
% Inputs:
% - ys [vector] vector of initial values for the steady state of the
% endogenous vaiables
% - exo [vector] vector of values for the exogenous variables
%
% Output:
% - ys  [vector] vector of steady state values for the endogenous variables
% - check  [scalar] set to 0 if steady state computation worked and to 1 if
% not (allows to impose restriction on parameters)

global M_

% read out parameters to access them with their name
NumberOfParameters = M_.param_nbr;
for ii = 1:NumberOfParameters
    paramname = deblank(M_.param_names(ii,:));
    eval([paramname ' = M_.params(' int2str(ii) ');']);
end
% initialize indicator
check = 0;


%% Enter model equations here
%Alternative Steady State solver through numerical methods
%syms c k l

%F1 = psii*c*(l^chii) - (1-alppha)*(k^alppha)*(l^(-alppha));
%F2 = 1/betta - (1 + alppha*(k^(alppha-1))*l^(1-alppha) - delta);
%F3 = c - (k^alppha)*(l^(1-alppha)) + delta*k;

%X = vpasolve(F1, F2, F3);

%c = double(X.c);
%k = double(X.k);
%l = double(X.l);

% Set of Steady State Equations (pinned down by hand - deterministic SS)
l = (((1 - alppha)/psii)*(((1/betta) - 1 + delta)/((1/betta) - 1 + delta - alppha*delta)))^(1/1+chii);
k = (((1/betta - 1 + delta)/alppha)^(1/(alppha -1)))*l;
y = (k^alppha)*(l^(1-alppha));
invest = delta*k;
c = y - invest;
y_l = y/l;
z = 0;
log_y=log(y);
log_invest=log(invest);
log_c=log(c);
log_l=log(l);
log_k=log(k);
log_y_l=log(y_l);

%% end own model equations

for iter = 1:length(M_.params) %update parameters set in the file
    eval([ 'M_.params(' num2str(iter) ') = ' M_.param_names(iter,:) ';'])
end

NumberOfEndogenousVariables = M_.orig_endo_nbr; %auxiliary variables are set automatically
for ii = 1:NumberOfEndogenousVariables
    varname = deblank(M_.endo_names(ii,:));
    eval (['ys(' int2str(ii) ') = ' varname ';']);
end


end




Summing up, what other explanation could be causing this problem (any trivial error regarding some issue with the names of the files?)

I'd appreciate any further advise on this, because this is very puzzling for me and I'm not able to spot any evident error.

Best.
Attachments
Neoclassical_Model_SP_Hidden_Chi_0_5.mod
(855 Bytes) Downloaded 62 times
Neoclassical_Model_SP_Hidden_Chi_0_5_steadystate.m
(2.14 KiB) Downloaded 68 times
erikignasi
 
Posts: 10
Joined: Sun Oct 02, 2016 4:49 pm
Location: Barcelona

Re: Extensions to the basic Neoclassical Model

Postby jpfeifer » Tue Dec 20, 2016 4:49 pm

Sorry, but I don't understand what you are doing. What do you mean with "hidden calibration"? The GHH preferences? If yes, there should not be a consumption c on the LHS of the labor FOC. If the labor FOC is actually correct, then I don't see how you can so easily solve for labor when you have to substitute out consumption using the budget constraint.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Extensions to the basic Neoclassical Model

Postby erikignasi » Tue Dec 20, 2016 8:19 pm

Dear Dr. Pfeifer,

I apologise for any unclear explanation that may have caused confusion. I'm following Eric Sims' lecture notes, and there he uses the terminology of "hidden calibration" in order to emphasize the calibration of the Frisch elasticity in labour supply: http://www3.nd.edu/~esims1/grad_macro_16.html (Page 9 in RBC model quantitative.pdf).

In the same document you'll see the type of preferences I'm using in my model (page 10), I do also specify it as a comment in the .mod file I'm attaching you below. Hence, the labour FOC is correct as you can also see in Eric Sims' notes.

I’m not sure I follow your last comment regarding the solution of labour: the expression I’m getting as SS solution of labour can be followed from http://www.nuff.ox.ac.uk/users/bilbiie/ ... ord_06.pdf (page 21 and 22).
In particular, the equation is 2.16, and if I express this equation in the same way as where it says “ Substituting both in the intratemporal optimality condition:” and adapt the parameters to my model (instead of chi -> psi and instead of phi -> chi), I get the expression for labour of my SS Matlab function.

However, I’ve also tried out to solve for labour in a different way and in line with Eric Sims. For this I created the mod file attached. There, I’ve included another way of pinning down labour and left the previous solution of labour as a comment for comparisons sake.

To see from where I get the new SS solution of labour please refer to the document specified above on Eric Sims lectures notes: for this new SS solution of labour I just take the consumption to labour ratio expressed in equation 27 (page 5) and plug it into the equation previous to equation 37 (page 10) in order to get equation 37. Then I just isolate labour from the equation and substitute capital to labour ratio expressed in equation 25 (page 5). This is the final expression I have in this new Matlab function for labour (after having adapted/renamed the parameters on my model).

Once again, I do get an error regarding the static residuals when running this new file, leading to the same questions and problems stated in last post.

Code: Select all
>> dynare Neoclassical_Model_SP_Hidden_Chi_NEW

Configuring Dynare ...
[mex] Generalized QZ.
[mex] Sylvester equation solution.
[mex] Kronecker products.
[mex] Sparse kronecker products.
[mex] Local state space iteration (second order).
[mex] Bytecode evaluation.
[mex] k-order perturbation solver.
[mex] k-order solution simulation.
[mex] Quasi Monte-Carlo sequence (Sobol).
[mex] Markov Switching SBVAR.

Starting Dynare (version 4.4.3).
Starting preprocessing of the model file ...
Found 13 equation(s).
Evaluating expressions...done
Computing static model derivatives:
 - order 1
Computing dynamic model derivatives:
 - order 1
Processing outputs ...done
Preprocessing completed.
Starting MATLAB/Octave computing.





Residuals of the static equations:

Equation number 1 : 0
Equation number 2 : 13.2031
Equation number 3 : 0
Equation number 4 : 0
Equation number 5 : 0
Equation number 6 : 0
Equation number 7 : 0
Equation number 8 : 0
Equation number 9 : 0
Equation number 10 : 0
Equation number 11 : 0
Equation number 12 : 0
Equation number 13 : 0


Error using print_info (line 72)
The steadystate file did not compute the steady state

Error in resid (line 112)
    print_info(info,options_.noprint, options_)

Error in steady (line 90)
        resid;

Error in Neoclassical_Model_SP_Hidden_Chi_NEW (line 155)
steady;

Error in dynare (line 180)
evalin('base',fname) ;


I hope I could clarify your doubts, and I’m looking forward to further help.

Thanks in advance.
Attachments
Neoclassical_Model_SP_Hidden_Chi_NEW_steadystate.m
(2.51 KiB) Downloaded 73 times
Neoclassical_Model_SP_Hidden_Chi_NEW.mod
(911 Bytes) Downloaded 62 times
erikignasi
 
Posts: 10
Joined: Sun Oct 02, 2016 4:49 pm
Location: Barcelona

Re: Extensions to the basic Neoclassical Model

Postby jpfeifer » Wed Dec 21, 2016 10:15 am

You have various mistakes in your steady state computation for labor. It should be
Code: Select all
l = (1/psii*(1-alppha)*...
    ((1/betta-(1-delta))/alppha)^(alppha/(alppha-1))/ ... K^alpha
    (((1/betta-(1-delta))/alppha)^(1/(alppha-1))*((1/betta-(1-delta))/alppha-delta))... %C
    )^(1/(1+chii))
Attachments
RBC_Hidden_Calibration_steadystate.m
(1.91 KiB) Downloaded 72 times
RBC_Hidden_Calibration.mod
(911 Bytes) Downloaded 72 times
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Extensions to the basic Neoclassical Model

Postby erikignasi » Wed Dec 21, 2016 8:08 pm

Dear Dr. Pfeifer,

Once again, thanks for your unconditional help. I've understood the problem now and the model is working. I'll proceed with the rest of the extensions in the same way and in case I have a problem with solving the extended model on Dynare I'll post it here.

Just one quick comment to make sure I understood the changes you did:

When you specify K^alpha and C as a comment such that I can follow what you are doing, shouldn't it be actually (K/L)^alpha and C/L in line with the expressions you write down for capital and consumption?

Hence:

Code: Select all
%% Enter model equations here

% Set of Steady State Equations (pinned down by hand - deterministic SS)
l = (1/psii*(1-alppha)*...
    ((1/betta-(1-delta))/alppha)^(alppha/(alppha-1))/ ... %(k/l)^alpha
    (((1/betta-(1-delta))/alppha)^(1/(alppha-1))*((1/betta-(1-delta))/alppha-delta))... %(c/l)
    )^(1/(1+chii));
k = ((1/betta-(1-delta))/alppha)^(1/(alppha-1))*l;
y = (k^alppha)*(l^(1-alppha));
invest = delta*k;
c=((1/betta-(1-delta))/alppha)^(1/(alppha-1))*((1/betta-(1-delta))/alppha-delta)*l;
% c = y - invest;
y_l = y/l;
z = 0;
log_y=log(y);
log_invest=log(invest);
log_c=log(c);
log_l=log(l);
log_k=log(k);
log_y_l=log(y_l);

%% end own model equations
erikignasi
 
Posts: 10
Joined: Sun Oct 02, 2016 4:49 pm
Location: Barcelona

Re: Extensions to the basic Neoclassical Model

Postby jpfeifer » Thu Dec 22, 2016 8:03 am

No, because you solve for l. Both capital and consumption are a function of l, which is brought to the left hand side and solved for. I just put the comment there to show where the expressions come from.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Extensions to the basic Neoclassical Model

Postby erikignasi » Thu Dec 22, 2016 7:53 pm

I see! Thanks for the clarification!

Best wishes.
erikignasi
 
Posts: 10
Joined: Sun Oct 02, 2016 4:49 pm
Location: Barcelona


Return to Dynare help

Who is online

Users browsing this forum: No registered users and 10 guests