DSGE Models |
DSGE stands for Dynamic Stochastic General Equilibrium. The DSGE instruction takes a set of formulas and solves them (either exactly or approximately) to create a state-space model. Input to it are the formulas (in the form of a MODEL), and list of endogenous variables. Output from it are the system matrices for the state-space representation: \(\bf{A}\), \(\bf{F}\) and \(\bf{Z}\). The algorithm used is the QZ method from Sims (2002). However, internally RATS uses a “real” Schur decomposition, rather than the complex Schur decomposition described in that paper.
We’ll start with a simple example which has no expectation terms.
\begin{equation} \begin{array}{l} x_t = \rho x_{t - 1} + \varepsilon _{xt} \\ c_t = c_{t - 1} + \mu _c + x_{t - 1} + \varepsilon _{ct} \\ \end{array} \end{equation}
The equations are input using a set of FRML’s which are GROUP'ed into a model. We need to define the variables X and C as series so they will be recognized as such in analyzing the model. We also will need to provide actual values for the parameters \(\rho\) and \(\mu_c\). DSGE can’t do symbolic analysis in terms of the deep parameters—it can only solve for the representation given a specific set of values. The initial setup is:
dec series x c
dec real rho mu_y
frml f1 x = rho*x{1}
frml f2 c = c{1} + mu_y + x{1}
group BansalYaron f1 f2
Not all FRML’s in a model will have a specific dependent variable. If you have an implicit relationship, write it as an expression in the form \(f( \ldots ) = 0\) if the IDENTITY option is used, or \(f( \ldots ) = \varepsilon _t \) if it has a shock.
To solve for a specific set of parameter settings, we can do something like:
compute rho=.98,mu_c=.005
dsge(model=BansalYaron,a=a,f=f,z=z) x c
The series listed on the DSGE instruction line are the endogenous variables in the model. The number of these must match the number of equations. Because the model has two non-identities, there are two shocks. The first two states will be \(x_t\) and \(c_t\): the endogenous variables in the order listed. DSGE will examine the formulas, looking for occurrences of the endogenous variables. These will be slotted into the form:
\begin{equation} \left[ {\begin{array}{*{20}c} 1 & 0 \\ 0 & 1 \\ \end{array}} \right]\left[ {\begin{array}{*{20}c} {x_t } \\ {c_t } \\ \end{array}} \right] = \left[ {\begin{array}{*{20}c} \rho & 0 \\ 1 & 1 \\ \end{array}} \right]\left[ {\begin{array}{*{20}c} {x_{t - 1} } \\ {c_{t - 1} } \\ \end{array}} \right] + \left[ {\begin{array}{*{20}c} 0 \\ {\mu _c } \\ \end{array}} \right] + \left[ {\begin{array}{*{20}c} 1 & 0 \\ 0 & 1 \\ \end{array}} \right]\left[ {\begin{array}{*{20}c} {\varepsilon _{xt} } \\ {\varepsilon _{ct} } \\ \end{array}} \right] \end{equation}
where, while we’ve written them symbolically, these will all have numeric values. In this case, the \(\bf{A}\), \(\bf{F}\) and \(\bf{Z}\) can be simply read off.
Let’s look at a more complicated example. The first order conditions for the problem:
\begin{equation} \max {\mkern 1mu} E_0 \sum {\beta ^t \left( {u_1 - u_2 c_t } \right)^2 } {\mkern 1mu} \,{\textrm{subject to }}y_t = fk_{t - 1} + \varepsilon _t ,k_t + c_t = y_t \label{eq:dsge_consumptionproblem} \end{equation}
can be written:
\begin{equation} \begin{array}{c} E_t \beta f \times \left( {u_1 - u_2 c_{t + 1} } \right) = \left( {u_1 - u_2 c_t } \right) \\ k_t + c_t = fk_{t - 1} + \varepsilon _t \\ \end{array} \end{equation}
In the formula, you write the expectation of \(c_{t+1}\) given \(t\) using the standard series lead notation C{-1}. The first equation is an identity. We rearrange that to make the model:
dec real beta f u1 u2
dec series c k
frml(identity) f1 = beta*f*(u1-u2*c{-1})-(u1-u2*c)
frml f2 = k+c-f*k{1}
An example setting up and solving this is:
compute beta =.99
compute f =1.02
compute u1 =1.0
compute u2 =0.5
group bliss f1 f2
dsge(model=bliss,a=a,f=f,z=z) c k
This generates the intermediate representation:
\begin{equation} \left[ {\begin{array}{*{20}c} {u_2 } & 0 & { - \beta fu_2 } \\ 1 & 1 & 0 \\ 0 & 0 & 1 \\ \end{array}} \right]\left[ {\begin{array}{*{20}c} {c_t } \\ {k_t } \\ {E_t c_{t + 1} } \\ \end{array}} \right] = \left[ {\begin{array}{*{20}c} 0 & 0 & 0 \\ 0 & f & 0 \\ 0 & 0 & 0 \\ \end{array}} \right]\left[ {\begin{array}{*{20}c} {c_{t - 1} } \\ {k_{t - 1} } \\ {E_{t - 1} c_t } \\ \end{array}} \right] + \left[ {\begin{array}{*{20}c} {\beta fu_1 - u_1 } \\ 0 \\ 0 \\ \end{array}} \right] + \left[ {\begin{array}{*{20}c} 0 \\ 0 \\ 1 \\ \end{array}} \right]\eta _t + \left[ {\begin{array}{*{20}c} 0 \\ 1 \\ 0 \\ \end{array}} \right]\varepsilon _t \end{equation}
where \(\eta_t\) is a process satisfying \(E_t \eta _{t + 1} = 0\). Sims’ method does a decomposition of the system which, as part of the solution, eliminates the \(\eta_t\) term, leaving only a backwards-looking state-space model in the three state variables: the two endogenous variables plus \(E_t c_{t + 1} \).
Now this problem is simple enough that it can be solved exactly (and symbolically) by, for instance, the method of undetermined coefficients. DSGE produces the equivalent representation (for any given setting of the parameters), but it ends up with the redundant state \(E_t c_{t + 1} \), which (in the solved version) just passively reacts to the other two states. You should look at DSGE as being something of a “black box”, which produces a solution to the problem, just not necessarily in the most obvious form. However, because the first block of states are always the dependent variables in the order you specify, you can easily determine the dynamics for the series of interest—you do the calculations with the full state-space model, and then extract out that top block.
While DSGE operates numerically on the parameters, it works symbolically with the series. In order to do this, it needs to be able to recognize when a series is used and what (specific) lag or lead is needed. Series have to be referenced by individual names. You can’t use elements of a VECT[SERIES]. The lag or lead has to be a hard number, not a variable: that is, C{N} isn’t permitted.
The model has to be a “general equilibrium” model—any series used in the equations of the model have to be dependent variables for the model. The only “exogenous” processes are the shocks which are implicit (in the FRML’s input as non-identities).
All expectations use information through \(t\). These are represented as leads, so C{-1} is \(E_t c_{t + 1} \) and C{-2} is \(E_t c_{t + 2} \). Expectations through other information sets (such as \(t-1\)) can be handled by adding states, as we’ll see below.
Convert the original equation into an identity by adding a new series which represents the shock, and add a new (non-identity) describing the AR for the shock. For instance:
frml(identity) eqn8 yhat = (1-tau*ky-gy)*chat+tau*ky*ihat+gy*epsg
frml eqnepsg espg = rho_g*epsg{1}
Note that you now need to include EPSG among the target series, since the model’s solution must include it. You might find it easier to handle all shocks this way, even if they aren’t autocorrelated.
Date Convention for Capital Stock
In the example above, the capital stock is “time-stamped” so that \(k_t\) is determined at time \(t\) (by the decision regarding \(c_t\)). In many descriptions of this type of model, the capital stock is instead dated so \(k_t\) is what is used in production at \(t\). The resource constraint with this type of date scheme will usually be written:
\begin{equation} k_{t + 1} + c_t = y_t + \left( {1 - \delta } \right)k_t \end{equation}
(\(\delta\) is the depreciation rate). You can keep that date scheme as long as you re-date that specific equation (shifting everything back a period). If included as written, the \(k_{t+1}\) will be interpreted as an expected value rather than a realized number. Instead, you want to use this in the form:
\begin{equation} k_t + c_{t - 1} = y_{t - 1} + \left( {1 - \delta } \right)k_{t - 1} \end{equation}
With this convention (recommended by Uhlig and Sims), \(k_{t-1}\) is what is used in the time \(t\) production and \(k_t\) is determined by other decisions (such as production and consumption) at time \(t\).
Expectations based upon information sets other than dated time \(t\) can be handled as described in Sims (2002). Consider
\begin{equation} m_{t} = p_t + y_t - \alpha \left( {E_{t - 1} p_{t + 1} - E_{t - 1} p_t } \right) \label{eq:dsge_nonstandarddate} \end{equation}
Define \(e_{1t} = E_t p_{t + 1} ,e_{2t} = E_t p_{t + 2} \). Then \eqref{eq:dsge_nonstandarddate} can be represented using the combination of three formulas:
frml(identity) md = m-p-y+alpha*(e2{1}-e1{1})
frml(identity) e1f e1 = p{-1}
frml(identity) e2f e2 = e1{-1}
The optimization \eqref{eq:dsge_consumptionproblem} produces a set of linear equations only because it uses a quadratic utility function and a linear production function. With a log utility function and production function \(y_t = fk_{t - 1}^\alpha \theta _t \), the first order conditions become:
\begin{equation} \begin{array}{c} E_t \beta R_{t + 1} c_t /c_{t + 1} = 1 \\ R_t = \alpha fk_{t - 1}^{\alpha - 1} \theta _t \\ y_t = fk_{t - 1}^\alpha \theta _t \\ k_t + c_t = y_t \\ \log \theta _t = \varepsilon _t \\ \end{array} \label{eq:dsge_fullnonlinear} \end{equation}
where \(R_t\) is the gross rate of return on capital and \(\theta _t\) is a productivity shock. It’s possible to substitute out for \(R\) and \(y\), but at a substantial loss in clarity. Those types of substitutions are often necessary if you’re trying to simplify the model to a small enough set of states to solve analytically. However, if DSGE is doing the hard work, you’re better off writing the model in short, easy-to-read formulas with extra variables.
Because the equations aren’t linear, the Sims solution method can’t apply directly. Instead, we can get an approximate solution by linearizing the model. The standard way of handling this in the literature is to log-linearize around the steady state. However, DSGE offers the possibility of doing a simple linearization. You need to include either EXPAND=LOGLINEAR or EXPAND=LINEAR to get one of the expansions.
In order to log-linearize, all series need to be strictly positive. With this in mind, the technology shock in \eqref{eq:dsge_fullnonlinear} is multiplicative rather than additive. Log-linearization involves writing each series in the form \(x_t = \bar x\exp \left( {\tilde x_t } \right)\), where \(\bar x\) is the expansion point. We end up with a linearized system written in terms of \(\tilde x_t\).
The log-linearization is quite straightforward once you have the expansion point. RATS has a symbolic differentiation routine which can handle almost any of its (scalar) functions, including probability functions like %CDF. You can, however, run into problems calculating the steady state. By default, DSGE starts with guess values of 1.0 for each variable and uses a log-linear version of Newton’s method to solve the system of non-linear equations. That generally works acceptably if the variables aren’t bounded above. There are, however, models where, for instance, labor is parameterized in terms of fraction of available time, with labor + leisure = 1. Under those circumstances, the initial guess values aren’t even valid. There are two ways to feed in alternative guess values. The simplest usually is to use << on an individual series to override the default value of 1. For instance:
dsge(model=growth,a=a,f=f,z=zc,expand=loglinear,trace) $
c k y lab<<.5 xi
uses values of 1 for C, K, Y and XI, but .5 for LAB. You can use the TRACE option on DSGE to see how the iterations are going. That will sometimes help you isolate any series which are causing problems.
You can also use the INITIAL option to input the full vector (one per series). That will mainly be used in situations where we need to repeatedly solve a system with changes in the parameters, when, for instance, we’re estimating them. Once you’ve solved the system once, you can fetch the steady state values for that with the option STEADY=VECTOR for steady state estimates. You can then feed that back into future DSGE instructions using the INITIAL option. Since the steady state generally won’t change much with small changes to the parameters, you’ll reduce the amount of time required to locate the new expansion point.
If you want to set the expansion point rather than have it estimated, you can use either the << or INITIAL option to put in the guess values, then include the option ITERS=0.
Unit roots aren’t a problem for the DLM instruction once you have the model solved out to state space form—it can handle a mixture of unit and stationary roots using the PRESAMPLE=ERGODIC option. They do, however, pose several problems for solving a model into state-space form.
First, the solution procedure is to solve “unstable” roots forwards and “stable” roots backwards. For the purpose of solution, a unit root is considered to be stable—only roots greater than 1 are solved forwards. In the world of computer arithmetic, however, a test like \(\lambda \le 1\) can be dangerous. Due to roundoff error, it’s possible for a value which should be exactly 1 to come out slightly larger (or smaller, though that won’t be a problem). DSGE has a CUTOFF option which determines the boundary between the blocks of roots. The default value for that is 1.0, but it actually is 1.0 + a small positive number (\(10^{-7}\)). This gives a cutoff which is close enough to 1.0 that it’s highly unlikely for a model to have a root that is, in fact, unstable, but less than that value, but is still far enough from 1 that true unit roots will generally have a computed value lower than it. It’s possible (though unlikely) that you’ll have a model where the “fuzziness” added by DSGE isn’t enough. If your model doesn’t solve correctly, you can put in something like CUTOFF=1.001 to give a much higher tolerance for detection of a unit root.
A more significant problem occurs in expanding a non-linear model. A model with unit roots has no single steady state. For instance, if you have a persistent technology shock such as:
\begin{equation} \log \theta _t = \rho \log \theta _{t - 1} + \varepsilon _t \end{equation}
in computing the steady state, when \(\rho=1\), we get 0=0—the model does nothing to tack down a value for \(\bar \theta \). Instead of having one steady state, the model has a different solution for the other variables for each value of \(\bar \theta \). To get an expansion point, you’ll have to do one of two things:
1.Input the entire expansion point.
2.Provide values for the series which produce the unit root(s), and add the option SOLVEBY=SVD to DSGE.
SOLVEBY controls the way Newton’s method solves the system of equations at each iteration. With the unit root(s), the system of equations is singular. SOLVEBY=SVD lets this solve a partial system which is non-singular, while leaving unchanged the part that’s singular. If you try to solve a non-linear system with a unit root without using SOLVEBY=SVD, you’ll get a message like:
## FO16. Newton's method had singularity. If model is non-stationary, use option SOLVEBY=SVD. Error was in FRML F7
On iteration 1 of solution for steady state
This suggests the fix and points out the equation that produced the singularity.
DSGE: Applications
Given an input model, DSGE solves it into a state-space model representation. So what can we do with this? Many models aren’t designed to be estimated with actual data. In order to take a state-space model to data, the model needs at least as many shocks as there are observable series. Almost all the models we’ve seen have (many) fewer shocks than endogenous variables, even if we don’t count series like capital that really aren’t easily observed. Instead, most solved models are used to generate simulated economies and study the serial correlation patterns implied by the model. Simulations can be done easily using DLM; the calculation of responses and serial correlation require some additional procedures. There are many examples of this in the Novales, Fernandez and Ruiz(2009) textbook replications.
In order to solve the model in the first place, you need to provide values for the deep parameters of the model. One thing that you did not need before, but will need now, are the variances of the shocks. If you have more than one exogenous shock, they will be ordered based upon the listing on the GROUP instruction which created the model. The first formula in that list that isn’t an identity defines the first shock, the second defines the second shock, etc. The shock is signed to give a positive shift to the function as written. If you write a formula:
frml f2 = (k+c)-f*k{1}
the interpretation will be \(k_t + c_t - fk_{t - 1} = \varepsilon _t \), which means that it’s a positive shock to output. The same formula written in the opposite order:
frml f2 = f*k{1}-(k+c)
would produce a shock that’s actually negative to output. It’s a good idea to “endogenize” any shock that occurs in more complicated formulas so you can make sure it has the sign that you want. For instance,
frml(identity) f2 = (k+c)-(f*k{1}+e)
frml f3 = e
Simulations
DLM with the option TYPE=SIMULATE can create a simulated path for the complete state vector. Now as we’ve seen above, the full state vector can include quite a few states which are of no direct interest, having been added to the model solely to allow a solution in the proper form. However, since the original endogenous variables are in a known position in the state vector, we can extract them from the SERIES[VECT] that DLM produces.
One thing you must keep in mind is that if you log-linearize the model, the states generated must be interpreted as simulated values for \(\log \left( {{{x_t } \mathord{\left/{\vphantom {{x_t } {\bar x}}} \right.} {\bar x}}} \right)\). If you’re interested in simulated series for the data itself, you’ll have to save the steady state (using the STEADY option on DSGE) and transform back.
Impulse Responses
You can compute and graph impulse response functions for a state-space model using the procedure @DLMIRF. This takes as input the \(\bf{A}\) and \(\bf{F}\) matrices from the state-space model. (The state shifts \(\bf{Z}\) don’t affect the results). It then computes and graphs the responses to the variables of the system to the shocks. Note that it uses a unit size for each shock which might give responses that are unnaturally large. For instance, a unit shock to \(\varepsilon _t \) in \(\log \theta _t = \rho \log \theta _{t - 1} + \varepsilon _t \) will increase \(\theta\) by a factor of \(e\), with correspondingly enormous changes to the variables. You can change the scale of the shocks by multiplying F by a small number. If you have just one shock, or would like the same scaling to apply to all, you can just use the option F=.01*FDLM, for instance. If you want different scales to apply to each shock, you can do F=FDLM*%DIAG(scale factors). The scale factors here should be standard errors, not variances.
There are several options for controlling the organization of the graphs. Aside from standard HEADER and FOOTER options, the PAGE option allows you to arrange pages BYSHOCK (one shock per page, all variables), BYVARIABLE (one variable per page, all shocks), ALL (everything on one page) and ONE (one combination of shock and variable per page). There’s also a COLUMNS option which allows you to better arrange the graphs on a single page. The shocks are given labels using the SHOCKS option and the endogenous variables are labeled using the VARIABLES option. Because the state vector usually includes augmenting variables (and often endogenized shocks), you generally don’t want to include the entire state vector in the graphs. If you just restrict the VARIABLES option to list a subset of the states, only those will be shown. Since you have freedom to list the variables in any order on the DSGE instruction, you can arrange the variables there so the ones of interest come first.
Examples
There are quite a few example programs for solving out DSGE's given the deep parameters. Most of these end with computing the impulse responses using @DLMIRF.
Small linear model with no expectational terms. Uses DLM to examine paths back to steady-state from below and above. |
|
Small non-linear model with expectational terms. |
|
Small non-linear model with expectational terms. Uses DLM to do simulations of data. |
|
Very small linear and non-linear models with expectational terms. |
|
Larger (14 equation) non-linear model with expectational terms. From Erceg, Henderson & Levin(2000). |
Copyright © 2025 Thomas A. Doan