Page 1 of 1

Dynare cannot find steadystate for RBC with search frictions

PostPosted: Fri Nov 13, 2015 11:53 am
by Eco-Kermit
Dear all,

I am trying to run a very simple RBC model with search frictions in the labor market, but Dynare is not able to find the steady-state solution. I guess I made a mistake in the model part - specifically a mistake in modeling the JCC or Euler equation (and the related stochastic discount factor). Could someone please check this section? The entire model is defined in levels and is not linearized, respectively. Is this maybe causing difficulties?

Code: Select all
%----------------------------------------------------------------
% 1. Preamble
%----------------------------------------------------------------
var y cbeta c a w m theta q n u v;      // (11 variables)
//y         output
//cbeta     discount factor
//c         consumption
//a         technology
//w         wage
//m         matches
//theta     labor market tightness
//q         vacancy filling rate
//n         employment
//u         searching workers
//v         posted vacancies

varexo ea;
//ea        shock parameter

parameters ceta cgamma crho csigma r h s z;
//ceta      elasticity of the matching function
//cgamma    workers' relative bargaining power
//crho      persistency of technology shocks
//csigma    relative risk aversion
//r         real interest rate
//h         costs of holding a vacancy open
//s         exogenous job separations rate
//z         unemployment benefits

ceta =      0.5000;
cgamma =    0.7200;
crho =      0.9000;
csigma =    2.0000;
r =         0.1000;
h =         0.1324;
s =         0.1000;
z =         0.7088;

%----------------------------------------------------------------
% 2. Model
%----------------------------------------------------------------
model;                  //(11 equations)
%------RBC-Part------%
//Output
y = a * n;

//Consumption Euler equation:
c^(-csigma) = cbeta*c(+1)^(-csigma)*(1+r(+1)); 

//Stochastic discount factor:
cbeta = c^(csigma)/c(+1)^(csigma);

//Technology:
a = crho * a(-1) + ea;

%------Search-Frictions-Part------%
//Matching function
m = a*u^(ceta)*v^(1-ceta);

//Labor market tightness
theta = v/u;

//Probability of filling a vacancy
q = m/v;

//Definition of employment:
n = (n(-1)+m(-1)) * (1-s);

//Definition of unemployment:
u = 1-n;

//Job creation condition;
h/q = cbeta * (1-s) * (c(+1)^(-csigma)/c^(-csigma))*(y(+1)-w(+1)+h/(q(+1)));

//Wage:
w = (1-cgamma)*z+cgamma*(y+h*theta);

end;
%----------------------------------------------------------------
% 3. Steady-state & inital value section
%----------------------------------------------------------------
initval;            //(11 variables)
y =         0.7505;
cbeta =     0.9900;
c =         1.0000;
a =         1.0000;
w =         1.0808;
m =         0.0811;
theta =     0.4286;
q =         0.7000;
n =         0.7500;
u =         0.2703;
v =         0.1158;
   
end;

steady;
check;
%----------------------------------------------------------------
% 4. Shocks
%----------------------------------------------------------------
shocks;
var ea;
stderr 0.0049;

end;
%----------------------------------------------------------------
% 5. Computation
%----------------------------------------------------------------
stoch_simul(order=1,irf=40);


I am working on this for days and cannot find the mistake. I started many time to write down my model from scratch with pencil and paper, but cannot figure out what is going wrong. If I did any obvious mistake, I apologize! But I am feeling that I am running against a wall.

Please find also attached the mod-file.

Re: Dynare cannot find steadystate for RBC with search frict

PostPosted: Fri Nov 13, 2015 12:16 pm
by jpfeifer
In your SDF definition
Code: Select all
cbeta = c^(csigma)/c(+1)^(csigma);

there is the discount factor 1/(1+rbar) missing.
At the same time, your Euler equation has the SDF twice. It should be
Code: Select all
1= cbeta*(1+r(+1)); 

Re: Dynare cannot find steadystate for RBC with search frict

PostPosted: Fri Nov 13, 2015 4:27 pm
by Eco-Kermit
Thank you for your quick response, Johannes! I modified the equation for the SDF and the Euler equation as you told me, but now I am running into another problem which I am not able to solve. It must be related to the initial values of my endogenous variables. The error message I get is:

An infinite element was encountered when trying to solve equation(s) 4
with respect to the variable(s): v.
The values of the endogenous variables when the problem was encountered were:
y 0.88
cbeta 0.9091
c 0.88
a 1
w 0.886
m 0.0978
theta 1.164
q 0.7
n 0.88
u 0.12
v 0.1397

Error using lnsrch1 (line 71)
Some element of Newton direction isn't finite. Jacobian maybe singular or there is a problem with
initial values

The values I have used are based on examples which I have found here. They are:
Code: Select all
y =         0.8800;
cbeta =     0.9900;
c =         0.8800;
a =         1.0000;
w =         0.8860;
m =         0.0978;
theta =     1.1640;
q =         0.7000;
n =         0.8800;
u =         0.1200;
v =         0.1397;

I also tried other initial values without success. Which values should I try? On Youtube (https://www.youtube.com/watch?v=ZH-BRQaAaBU, 27:50) someone said that this part of Dynare is more like an art than a science, which is why I am skeptical about the used values. Or do I have to use an external matlab function like fsolve to find my initial values?

BTW: I find it promising that the reported values above pass a first plausibility check!

Re: Dynare cannot find steadystate for RBC with search frict

PostPosted: Fri Nov 13, 2015 5:15 pm
by jpfeifer
Please provide the updated mod-file.

Re: Dynare cannot find steadystate for RBC with search frict

PostPosted: Fri Nov 13, 2015 5:34 pm
by Eco-Kermit
Here it is.

Re: Dynare cannot find steadystate for RBC with search frict

PostPosted: Fri Nov 13, 2015 6:14 pm
by jpfeifer
Dynare uses something like fsolve by default. But this requires your equations to be correct, which they currently still aren't. If
Code: Select all
a = crho * a(-1) + ea;

then its steady state is 0. With a=0,
Code: Select all
y = a * n;

will also be 0. I guess you need to have
Code: Select all
y = exp(a) * n;

here and potentially in other places.

Re: Dynare cannot find steadystate for RBC with search frict

PostPosted: Fri Nov 13, 2015 6:24 pm
by Eco-Kermit
Ok, thanks again for your quick reply. I will check this out and work on it.

Re: Dynare cannot find steadystate for RBC with search frict

PostPosted: Fri Nov 13, 2015 6:30 pm
by jpfeifer
Also, think about what determines consumption in your model in steady state. It seems to always enter only in the SDF as a ration, so that it will drop out in steady state.
Similarly, looking at
Code: Select all
//Job creation condition;
h/q = cbeta * (1-s) * (c(+1)^(-csigma)/c^(-csigma))*(y(+1)-w(+1)+h/(q(+1)));

I wonder if
Code: Select all
 (c(+1)^(-csigma)/c^(-csigma))

should really be in there with the SDF cbeta already present.

Re: Dynare cannot find steadystate for RBC with search frict

PostPosted: Thu Dec 10, 2015 2:20 pm
by Eco-Kermit
It took me some time, but I finally managed to run a basic RBC with frictions in the labor market. Since I faced many problems with my previous model, I rebuilt my entire code. I decided to log-linearize my model in order to obtain the dynamics of the endogenous variables in percentage deviations. Another issue which kept me from running my program was the wrong timing of the stock variables. In this post http://www.dynare.org/phpBB3/viewtopic.php?f=1&t=173 MichelJuillard commented that the wrong timing of stock variables is a frequent problem, which turned out to be also a problem in my code.

I endogenized the real interest rate r by allowing for bonds in the budget constraint of the household. But to keep things simple, I also assumed that these bonds are in zero net supply in order to avoid non-stationarity of the debt process. This feature would be present without a debt elastic interest rate or any other mechanism which would ensure stationarity (compare to chapter 4.10 of Martin Uribe and Stephanie Schmitt-Grohe's book "Open Economy Macroeconomics"). Incorporating such a mechanism would be add odds with the goal of building a baseline version.

Thank you very much for help! I really appreciate your help and the existence of this forum. Your "Guide to Specifying Observation Equations for the Estimation of DSGE Models" was also very useful for writing the Dynare code. In case it might be someone interested, please find attached the mod-file.

/Edit: Note that I have assumed a negative productivity shock. To obtain a positive one, simply write "a = crho*a(-1) + e;" instead of "a = crho*a(-1) - e;"

Re: Dynare cannot find steadystate for RBC with search frict

PostPosted: Mon Feb 22, 2016 10:17 am
by Eco-Kermit
Sorry that I have to bring this post up once again but I am still struggling to set up a RBC model with a frictional labor market and capital. The model I have previously uploaded contains errors and is not correct (for example, I have mixed up the variables for consumption and vacancy posting costs at some occasions). I have searched almost through the entire web for an example mod file, but have not found anything that helped me to solve the problem.

To keep things simple, I startet once more from scratch, and now, want to built a model in levels. The RBC part is working perfectly. Its IRFs have their expected behavior, luckily(!). But after incorporating the search-friction part, I am not able to produce a running model. I checked so many things for so many times but without success. The timing of the variables seems to be correct, the SDF appears only once, and I applied exp(..) for the TFP process.

What is wrong with the model? The model should be so simple, which is why I start to become really desperate :-/ Please find attached the mod-file and a description of the model setup.