Suggestions for those struggling to find steady states.

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.

Suggestions for those struggling to find steady states.

Postby cfp » Mon May 31, 2010 9:51 am

Just posting a few things that worked for me. They may or may not help you.

  • Smooth any discontinuities in your model. I recommend the functional form max = ( sqrt( ( maximand1 - maximand2 )^2 + eps^2 ) + ( maximand1 + maximand2 ) ) / 2 for any maxes (where eps controls the maximum deviation from the true max). By differentiating this functional form once you can get a smooth step function, and differentiating it a second time gives a smooth delta function.
  • Create a duplicate of your model file in which you remove any lags, leads or expectation operators, as well as any shocks. This ensures there are no auxiliary variables being solved for, thus minimising the dimensionality of the problem.
  • Once you've done this, you will find that many equations are purely definitional, and can be replaced with dynare # definitions, further reducing dimensionality.
  • Use a global solver, rather than the local ones Dynare includes. I particularly recommend CMA-ES http://www.lri.fr/~hansen/cmaesintro.html which is available for both C and Matlab, and seems remarkably powerful.
  • If solver running times are too high, consider solving in C. You can take one of the CMA-ES example programmes and the automatically generated C residual code from Dynare, meaning this requires absolutely minimal coding. The speed-up for me was around 100x (no exaggeration).
  • Impose constraints in the objective function. I had a reasonably strong belief on the relative magnitudes of various variables in steady state, and encoded these beliefs into the objective function by adding a large number onto any steady state that violated them. This greatly helped avoiding local minima.
  • Use homotopy. Having solved a special case using CMA-ES (after multiple runs with a bit of manual tweaking of starting values), I then modified my C code to slowly adjust the free parameter until it was the value I wanted.

Hope this is of some use to someone.

T
cfp
 
Posts: 60
Joined: Mon Mar 15, 2010 9:18 pm

Re: Suggestions for those struggling to find steady states.

Postby olayenidynare » Tue Mar 22, 2011 4:31 pm

Maybe I happen to be one of the target audience. Please be more plain. If possible you may include a couple of examples. This may help a great many researchers in Dynare community. I tell you, the fear of steady state is the beginning of trouble for the modellers using dynare. I also think this approach could worked on to be included in later version of Dynare.

I appreciate this piece of info.

Thanks.
olayenidynare
 
Posts: 22
Joined: Sat Feb 21, 2009 3:17 pm

Re: Suggestions for those struggling to find steady states.

Postby cfp » Tue Mar 22, 2011 4:35 pm

Which bit isn't clear?
cfp
 
Posts: 60
Joined: Mon Mar 15, 2010 9:18 pm

Re: Suggestions for those struggling to find steady states.

Postby olayenidynare » Tue Mar 22, 2011 5:35 pm

Thanks for the prompt response.
Forgive my bombsells, though I'm not new to Dynare. You particularly recommend using cmaes.m. I just downloaded this file.

The following are my questions.
What does solving in C mean? I'm aware of the residual code generated by Dynare. Is this the same as C code you mean? Again are we solving outside Dynare? Where does homotopy come in? Lastly how do you achieve slowly adjust the free parameter?

Thanks
olayenidynare
 
Posts: 22
Joined: Sat Feb 21, 2009 3:17 pm

Re: Suggestions for those struggling to find steady states.

Postby cfp » Tue Mar 22, 2011 5:43 pm

I would start by using the Matlab version of CMAES. Dynare will have generated a "..._static.m" file which gives your objective function. You just need to pass it zeros for the x argument then your parameter vector.

C is a programming language. Dynare can generate a C version of your model which you can then use with the C version of CMAES. But I wouldn't attempt this until you've tried everything else.
cfp
 
Posts: 60
Joined: Mon Mar 15, 2010 9:18 pm

Re: Suggestions for those struggling to find steady states.

Postby olayenidynare » Tue Mar 22, 2011 8:02 pm

I believe randomly generating the initial values for means and sigma required by CMAES isn't the best. Purely for example pls.
After inputing the code that looks like the one below and typing the calling m file
paramv = [bla;bla;bla];
iniy = randn(20,1);
sigy = abs(randn(20,1));
inix = [0;0;0];
xmin = cmaes('nlrecap_SS',iniy,sigy,[],inix,paramv);

I got an error message something about the dimensionality of vector. I think it has to do with cmaes.m:

??? In an assignment A(:) = B, the number of elements in A and B
must be the same.

Error in ==> cmaes at 620
fitness.hist(1)=feval(fitfun, xmean, varargin{:});

Error in ==> findysteadyvalues at 55
xmin = cmaes('nlrecap_SS',iniy,sigy,[],inix,paramv);

I reckon that the residual is an n element vector whereas fitness.hist(1) is being taken as a scalar. What can I do at this time? I'm really interested in getting to know this at once.
olayenidynare
 
Posts: 22
Joined: Sat Feb 21, 2009 3:17 pm

Re: Suggestions for those struggling to find steady states.

Postby cfp » Tue Mar 22, 2011 10:28 pm

Look at the CMAES examples and check the function you're calling has exactly the same structure. I expect it's something like a row vector / column vector incompatibility. It's a while since I used CMAES so I can't be much more use really.
cfp
 
Posts: 60
Joined: Mon Mar 15, 2010 9:18 pm

MJDGGES returns the following error code: 62

Postby olayenidynare » Thu Apr 21, 2011 7:09 pm

Please does anybody know what the following mean:

??? Error using ==> print_info at 36
MJDGGES returns the following error code: 62

Error in ==> stoch_simul at 71
print_info(info, options_.noprint);

Error in ==> phdfile2 at 1462
info = stoch_simul(var_list_);

Error in ==> dynare at 132
evalin('base',fname) ;

Please help me
olayenidynare
 
Posts: 22
Joined: Sat Feb 21, 2009 3:17 pm

Re: Suggestions for those struggling to find steady states.

Postby cfp » Thu Apr 21, 2011 7:18 pm

Put a breakpoint in stoch_simul before the print_info command. You have to remember to run dynare with the noclearall option else the breakpoint will be removed. This doesn't look like it has anything to do with CMAES.
cfp
 
Posts: 60
Joined: Mon Mar 15, 2010 9:18 pm

Re: Suggestions for those struggling to find steady states.

Postby pguerron » Wed Jun 01, 2011 5:30 pm

The best suggestion is to compute the steady state by paper and pencil. This is doable for a very large class of models. Of course, it is time consuming but is a good checks on your model.
pguerron
 
Posts: 6
Joined: Fri Oct 01, 2010 2:06 pm

Re: Suggestions for those struggling to find steady states.

Postby cfp » Wed Jun 01, 2011 5:34 pm

Yes of course that's the first thing to attempt. (Or better still, get Maple to do it for you since that reduces the chance of errors.) But many models don't have analytic steady states.
cfp
 
Posts: 60
Joined: Mon Mar 15, 2010 9:18 pm

Re: Suggestions for those struggling to find steady states.

Postby msh855 » Sun Jul 21, 2013 2:08 pm

An example might really help indeed. I am among those that are struggling to find a Steady State and I have only basic numerical and programming skills. The consideration for "paper and pencil" is simply not working all the time, since there are non-linear equations that can not be handled.

I suggest, if someone really want to give a good example, is to use an OLG model with DEBT and non-zero deficits (ref: De La Croix and Michel, "Theory of Economic Growth: Dynamics and Policy in Overlapping Generations Model). Actually, this is what i am trying to do myself. I believe that this could be a good example for the following reasons. First, multiple steady states usually is the rule. Second, only under very restrictive conditions a steady state can be stable, third debt can be negative in such set up. The last one, I believe is really helpful since if someone does not know how to handle this, it might give negative values for capital and positive for debt, while is stochastic set up you might very easily say "bye bye" to a steady state :)
msh855
 
Posts: 39
Joined: Thu Feb 23, 2012 8:32 pm

Re: Suggestions for those struggling to find steady states.

Postby parantap » Wed Oct 02, 2013 12:20 am

Hi,

I am also in the same boat and I have been strggling to find the steady state. I know that the steady state exists and I have computed this seprately using fsolve nonlinear solver in matlab. I give the solution as guess values to dynare but does not work.

In the dynare manual section 4.10, it is suggested that if the solution is analytically known then put this in a steady-steady_state_model block. Create a seprate matlab file with dynare filename_steadystate. It then creates a corresponding steady state file with the same name attaching a 2 at the end. The manual suggests to look at the example fs2000_steadystate.m. I am not a matlab expert and I am basically trying to implement this in my problem by trying copy/paste but I am getting an error message that my function nesting is wrong. I think i am almost there. I am attaching the mod and the steady state files. Can anybdy help?

Parantap Basu
quant_banking_exo.mod
mod file
(2.01 KiB) Downloaded 185 times
quant_banking_exo_steadystate.m
matlab steady state file
(852 Bytes) Downloaded 190 times
parantap
 
Posts: 31
Joined: Tue Oct 01, 2013 11:58 pm


Return to Dynare contributions and examples

Who is online

Users browsing this forum: No registered users and 5 guests