**DSGE**^{n}

^{n}

### Some questions about DSGE

### What is DSGE^{n}?

DSGE^{n} is a Mathematica package for the automatic
generation of Fortran 90 code that characterizes the solution of a
broad class of DSGE models approximated to arbitrary order by
perturbation methods.

### Why is DSGE^{n}
useful?

Perturbation methods have been shown
to provide fast and accurate
solutions to many models. These properties have lead to perturbation
solutions being embedded within likelihood-based estimation routines,
for which solution speed is vital. In addition, part or all of these
routines will typically benefit from implementation in a compiled
language, suited to numeric computation. Unfortunately, these concerns
imply that obtaining and
solving the systems that characterize the perturbation solution
is algebraically and computationally demanding. DSGE^{n}
is designed to simplify this process by requiring the user to
provide a brief definition of the structure of the model of interest
and then generating Fortran 90 code that defines
and solves the systems (up to parameterization) that characterize the
model's
solution to a desired order of approximation.

### How does DSGE^{n}
work?

- The user defines the properties of the model:
- Variables (jumps and states)
- Model parameters
- Expressions for the variables' non-stochastic steady states (NSS)
- Equilibrium conditions

- Given the model details, DSGE
^{n}generates and executes Mathematica commands based on code made available by Aruoba, Fernandez-Villaverde and Rubio-Ramirez. These commands take derivatives (up to the desired order) of the equilibrium conditions. These derivatives are considered at the model's NSS and imply a set of related systems of equations. The unknowns in these systems are the derivatives of the functions relating the model's endogenous variables to the economic state, again considered at the NSS. The system obtained from first order differentiation is quadratic. Beyond first order, however, the systems obtained are linear, once the solutions from lower orders have been imposed. - Once the above systems have been obtained DSGE
^{n}generates code that (when passed parameter values) solves the model and makes use of the solution:- Solving the model
- Defines the NSS (F90)
- Defines the Jacobian and Hessian of the equiblibrium conditions (F90 and Matlab)
- Provides an interface to Paul Klein's solab, for first order analysis (F90)
- Defines and solves the A's and b's of the recursively related linear systems, for higher order analysis (F90)

- Using the solution
- Evaluates the Taylor polynomials that approximate the true equilibrium functions, for a given value of the state (F90)
- Advances the model state from its current to next period value (F90)
- Assigns the NSS to the polynomials in terms of deviations from NSS so the policy functions are now in terms of levels (F90)

- Solving the model
- DSGE
^{n}also generates various support routines and diagnostic files providing information about the solution - such as the dimensions of the Fortran arrays that will be required by the user.

### What do I need to
use DSGE^{n}?

In order to run DSGE^{n} it is sufficient
simply to have Mathematica
7.0 (we have not checked backwards
compatibility with previous versions of Mathematica). DSGE^{n}
can be deployed on Windows or Linux systems and, if it has access to
multi-core architecture, can operate in parallel. This is
important
since the problem of generating code for a model of reasonable size is
one that benefits significantly from parallelization. In fact, in our
own work, we typically use DSGE^{n} on
the NYU
High Performance Computing cluster.

In order to use the code generated by DSGE^{n}
the user must have access to:

- Paul Klein's solab
- Intel MKL (with one minor exception this is simply used for its implementation of LAPACK subroutines)
- UMFPACK (if the user wishes to use UMFPACK as the sparse linear system solver)
- MUMPS (if the user wishes to use MUMPS as the sparse linear system solver)
- A Fortran Compiler (we have used Intel's compiler and have not tested with others)
- We have found the makefile generator MKMF
to be useful in compiling the code generated by DSGE
^{n}

### What are the
alternatives to DSGE^{n}?

There are several alternatives to DSGE^{n}
if one wishes to use perturbation methods to solve DSGE models. A
(probably incomplete) list of such software is:

- Dynare
- Dynare++
- PerturbationAIM
- Aruoba, Fernandez-Villaverde and Rubio-Ramirez's code
- Schmitt-Grohe and Uribe's code

We do not attempt a full classification of the relative merits of the
above software, particularly with regard to DSGE^{n}.
We simply assert some strengths and weaknesses of DSGE^{n} that
will help the user to decide whether or not it is suitable for their
particular project:

- Strengths:
- Generated code solves the model very rapidly when passed a given parameterization
- Can be deployed on Linux or Windows machines
- Parallelized
- Simple user interface
- Auxiliary code allows easy incorporation of the solution within broader projects
- Generates code for standard dense and (freely available) sparse linear solvers

- Weaknesses:
- Code generation for medium scale models at 3
^{rd}order or above can take several hours (but this is a fixed cost and ameliorated by parallelization) - Memory requirements for large models at 3
^{rd}order are substantial (on the NYU cluster we use nodes with extra memory) - Although DSGE
^{n}theoretically allows for arbirtrary order perturbation, memory and compiler constraints mean that for medium scale models, perturbation beyond third order is essentially infeasible

- Code generation for medium scale models at 3

### Why is it called
DSGE^{n}?

DSGE relates to the sort of models to be
solved (Dynamic Stochastic General Equilibrium). GE^{n}
reflects the fact that it **gen**erates
code. The ^{n} exponent alludes to the order of
approximation.

### Who is responsible for
DSGE^{n}?

DSGE^{n} was developed by Rhys
Bidder and Matt
Smith, while Economics PhD students at NYU.