Four Methods to Compute the Steady State of a DSGE Model in Dynare
In this tutorial we will discuss four different ways to compute the steady-state of a DSGE model in Dynare.
We will cover (1) the steady_state_model block if your steady-state is available in closed-form, (2) the steady_state_model block with a helper function if some variables are not available in closed-form, (3) writing a steadystate MATLAB function, and (4) the initval block. As our example model we use a variant of the RBC model with leisure
with a CES or log utility function. That is, when we consider the log-utility case, the steady state is given analytically, whereas in the CES utility case we cannot solve for labor in closed-form.
Video
Method 1: steady_state_model
Let’s consider the log-utility case, i.e. we have a recipe to compute the steady state in closed-form analytically. This can be easily written down in a steady_state_model block in your mod file:
This is the preferred method to specify your steady state in your mod file, but it takes much time, effort, and practice to derive the closed-form solutions.
Method 2: steady_state_model with helper function
Often you can derive closed-form expressions for some variables in steady state, but not for a few others. An example of this is the RBC model with CES utility, where we cannot solve for labor analytically, but once we have a value for labor, all other variables can be computed in closed-form. Such cases can be coped with by using a helper function in your steady_state_model block. Consider the following mod file first:
Note that in the steady_state_model block we are calling the helper function rbc_ces1_steadystate_helper.m, which uses MATLAB to compute L given a start value L0 and previously computed steady state values. You need to create this file (and call it whatever you want it to be called) in the same folder as your mod file, but use the .m extension. I called it rbc_ces1_steadystate_helper.m:
Note that I use fsolve to compute the labor value in steady state and set up some options using optimset. You can and should, of course, use other optimizers that work better in your model. Also, note that I catch the special case of log-utility as there is a closed-form solution.
Method 3: steadystate file
If you want full control of the steady state computations, you need to create your own YOURMODFILENAME_steadystate.m. So let’s create another mod file
Note that there is no steady_state_model or initval block, but the sole command steady which instructs Dynare to compute the steady state. Now let’s create another MATLAB file, called rbc_ces2_steadystate.m, which actually computes the steady state:
Some remarks are in order:
We usually do not recommend to write you own file to compute the steady state as this is error-prone. But a definite advantage is that you have full control of the computations.
Your _steadystate.m file needs to have the same first part of the name as your mod file.
Step 1 and Step 4 are always the same and very important to include in your steadystate file.
Note that previous to Dynare 4.6 M_ and options_ were called globally, but not anymore. Thus, we need to use these variables as inputs. This is a new feature as previously people used the global variables in a wrong fashion, e.g. falsely updated them in an estimation exercise. So if you have older mod files, you need to adapt this accordingly.
Before I actually call the numerical optimizer, I included examples on how to check parameter and variable restrictions. If they are not fulfilled, the function returns a flag that the steady state could not be computed. This is good practice as the numerical solver could be time-consuming or would lead unfeasible results.
Lastly, you need to specify values for all your declared variables and output both parameters and variables. Dynare then updates the auxiliary variables internally.
Method 4: initval
If you have no clue at all on how to compute the steady state of your model, you can always rely on numerical methods. Dynare has several in-built optimization algorithms you can choose and fine-tune (see the manual
on all available options). You need to specify an initval block with the initial values for the endogenous variables:
Note that if you don’t specify a variable explicitly, Dynare uses 0 as initial value. Typically, you would take initial values from a simpler model and use these in a more elaborate model. In this case, we take the log-utility values for our ces-utility model. This concept is closely related to a more elaborate way on finding the steady state called “homotopy” (a divide-and-conquer technique to solve for the steady state), which I will cover in another tutorial.