Differences between revisions 26 and 27
Revision 26 as of 2009-10-14 12:40:10
Size: 10921
Comment:
Revision 27 as of 2009-12-02 09:38:36
Size: 11063
Comment:
Deletions are marked like this. Additions are marked like this.
Line 76: Line 76:
 * {{{-r INTEGER}}}: seed for the random number generator used in tests 2 and 3 (Default: 0)
Line 78: Line 79:
 * {{{-u INTEGER}}}: number of points to be used in Test 1
 * {{{-v INTEGER}}}: number of simulations to be used in Test 2
 * {{{-w INTEGER}}}: number of simulations to be used in Test 3
 * {{{-u INTEGER}}}: number of points to be used in Test 1 (Default: 100)
 * {{{-v INTEGER}}}: number of simulations to be used in Test 2 (Default: 1000)
 * {{{-w INTEGER}}}: number of simulations to be used in Test 3 (Default: 10000)

Status of testing program

The program performs the following tests:

  1. Accuracy on a sphere in the state space
  2. Accuracy on a stochastic simulation
  3. Den Haan Marcet statistics

The following solutions are implemented:

  • Krueger, Kubler and Malin (KKM)
  • Kim, Kim and Kollman (KKK)
  • Pichler
  • Judd, Maliar and Maliar (JMM), clusters+RBF+Monomials (CRM) method
  • Judd, Maliar and Maliar (JMM), stochastic simulation algorith (SSA) method

Installation

The testing program is designed to run on the two following platforms: GNU/Linux and Windows/Cygwin.

You need the following software to run the program:

  • GNU C++ compiler (g++)
  • GNU Fortran 95 compiler (gfortran); under Cygwin, you have to manually install it: the package is downloadable here, and installation instructions are there

  • development files for the GNU Scientific Library (GSL), which should be in a package called libgsl0-dev

  • GNU make
  • subversion
  • MATLAB

Download the source of the testing program with:

svn checkout https://www.dynare.org/svn/jedctestsuite

Then go into the jedctestsuite/JedcTestSuiteTestsA directory, and configure the package.

Under GNU/Linux, type:

./configure --with-matlab=/usr/local/matlab76

(where you should give the right MATLAB installation directory)

Under Windows/Cygwin, type:

export FC=/usr/local/gfortran/bin/gfortran
export FCLIBS=/usr/local/gfortran/lib/gcc/i686-pc-cygwin/4.4.0/libgfortran.a
./configure --with-matlab=/cygdrive/c/Progra~1/MATLAB

(note that you shoud use "Progra~1" instead of "Program Files" when giving the path to MATLAB directory, since spaces in pathnames are not supported)

Finally, compile the testing program by typing:

make

This should have created a program called tester.

Running the program

The testing program is run with:

./tester

It is important to run it from the directory where it was built.

The program will perform the tests for each of the 30 specifications, and for each specification for each solution method. For accuracy tests 1 and 2, it displays relative error for every equation. For accuracy test 3, and for all Euler equations (first separately, then together), it computes the DHM statistics several times, and displays the fraction of times that the statistics was out of the bilateral 5% confidence interval.

The program accepts several options:

  • -a: use an alternative specification for the aggregate ressource constraint error, as suggested by Benjamin Malin (see below)

  • -A: use an alternative specification for the aggregate ressource constraint error, as suggested by Paul Pichler (see below)

  • -b INTEGER: start computations with a given specification (designated by an integer between 1 and 30); indices 1 to 5 are for A1 by increasing number of countries, indices 6 to 9 are for A2, ...

  • -d: for each model and each participant solution, create a CSV file containing simulated data for accuracy tests 1 and 2 (see below)

  • -g: always use product 4-point Gauss-Hermite for numerical integration (see below)

  • -m: always use monomial degree 5 rule for numerical integration (see below)

  • -q: always use quasi-Monte Carlo for numerical integration (see below)

  • -r INTEGER: seed for the random number generator used in tests 2 and 3 (Default: 0)

  • -s NAME: compute tests only for solution NAME. Possible values are kkm, kkk, pichler, jmm-crm and jmm-ssa

  • -t INTEGER: compute only the specified accuracy test. Possible values are 1, 2 or 3

  • -u INTEGER: number of points to be used in Test 1 (Default: 100)

  • -v INTEGER: number of simulations to be used in Test 2 (Default: 1000)

  • -w INTEGER: number of simulations to be used in Test 3 (Default: 10000)

CSV files

Test 1

The first $$n$$ columns (where $$n$$ is the number of countries) contain the state variable for capital stock (stock accumulated at end of previous period). The next $$5n+1$$ columns contain current endogenous variables as simulated by participant's solution (note that those include the state variable for TFP level). The last $$5n+1$$ columns are the residual of all equations.

Test 2

The first $$5n+1$$ columns contain current endogenous variables (note that capital has end-of-period stock timing convention). The next $$n+1$$ columns contains simulated shocks (the last one is the global shock). The last $$5n+1$$ columns are the residual of all equations. Note that the first line contains initial values, obtained after dropping 500 first simulated periods.

Numerical integration

Three methods of numerical integration are implemented in the testing program:

  • product 4-point Gauss-Hermite
  • monomial degree 5 rule, as described in Judd (1998) "Numerical Methods in Economics", p. 275, eq. 7.5.11
  • quasi-Monte Carlo using 1000 points; the sequence of points is drawn from a Niederreiter generator

Note that for $$N$$ countries, the dimension of the integration problem of Euler errors is $$N+1$$.

The default behaviour of the program is to use Gauss-Hermite up to dimension 6 (i.e. when $$N\leq 5$$), and monomial degree 5 rule above.

It is possible to alter this behaviour by forcing the program to use a given integration method (see options).

Aggregate resource constraint residual

There are three possible ways of computing the aggregate ressource constraint residual.

The default, suggested by Michel Juillard's May 2007 note, is:

$$\frac{Y-C-I+\delta K -CAC}{Y-CAC}$$

(where $$CAC$$ stands for capital adjustment cost).

An alternative, triggered by -a option, and suggested by Benjamin Malin, is:

$$\frac{Y-C-I+\delta K -CAC}{Y+K}$$

Another alternative, triggered by -A option, and suggested by Paul Pichler, is:

$$\frac{Y-C-I+\delta K -CAC}{Y}$$

Benjamin Malin's version obviously gives lower error approximations in absolute value, since it has the greatest denominator.

Code overview

The class ModelSpec implements the abstract representation of a given specification, and has 8 subclasses ModelSpecA1, ModelSpecA2, ... corresponding to the 8 models. An instance of such a class contains all the parameters of the model and the logic for computing the relative errors of all equations, given the values of the variables and the shocks.

Note that in class ModelSpec, the convention is to work with a vector of variables $$y_t$$ of length $$5n+1$$ (where $$n$$ is the number of countries). The vector $$y_t$$ contains consumption level $$c_t^j$$, labor $$l_t^j$$, investment $$i_t^j$$, capital (end of period stock)$$k_{t+1}^j$$, technology level $$a_t^j$$ and $$\lambda_t$$ (Lagrange multiplier of aggregate budget constraint) (see ModelSpec.hh for more details). Shocks are in a vector $$e_t$$ of size $$n+1$$ (idiosyncratic shocks + global shock).

Relative errors are computed using $$y_{t-1}$$, $$y_t$$, $$y_{t+1}$$ and $$e_t$$, following section 1.5 of Michel's May 2007 notes. The forward looking part of the Euler equation is separately computed by ModelSpec::forward_part(), so that it can be integrated over, and then fed back to ModelSpec::errors() (which computes the $$5n+1$$ errors).

Solution methods are implemented via a subclass of ModelSolution (see kkm/KKMSolution.cc and kkk/KKKSolution.cc). The purpose of these classes is to provide a uniformized wrapper around the participant's solutions. The main method of those classes is the policy function, which provides $$y_t$$ given $$y_{t-1}$$ and $$e_t$$.

The three tests are implemented in class SolutionTester.

The main function is in tester.cc: it constructs the abstract representations of the 30 model specifications, and then performs the tests for all solution methods.

KKM solution

Source for KKM solution is in kkm/ subdirectory. It consists of a non-linear solver (all the Fortran files in kkm/), which are combined in libhybrid.a by the Makefile.

Each of the TestA* subdirectory contains three Fortran 90 files, and a CSV file with Chebychev polynomial coefficients for each number of countries.

Since KKM's code makes uses of global variables, it was necessary to create a dynamically loadable object for each specification, and to load objects on the fly (see class KKMSolution).

Note that since KKM don't provide a value for $$\lambda_t$$, the testing program uses the value of $$\tau^1 u'_c(c^1_t, l^1_t)$$ (marginal utility of consumption of first country) as a replacement.

KKK solution

Data for KKK solution is in kkk/ subdirectory. There is one MAT-file for each specification.

Class KKKSolution reads the files, and computes the second-order approximation.

Note that the simulated time paths computed by the testing program do not use the technique of "pruning" the 3rd and higher order terms (as described in Kim, Kim, Schaumburg and Sims (2007)), while "pruning" was used in KKK's 2007 paper. This is simply due to the fact that the testing program uses a generic simulation routine, only based on the one-period ahead policy function provided by the participants; it does not exploit the pecularities of a given solution.

Pichler solution

Data for Pichler solution is in pichler/ subdirectory. There is one MAT-file for each specification.

Class PichlerSolution reads the MAT files, and computes the policy function, according to the Matlab files provided by Pichler.

JMM solutions

Data for the two solution provided by JMM are jmm/ subdirectory. The simulation code is the same for the two methods: only the data, provided in MAT files, differ.

Classes JMMCRMSolution and JMMSSASolution read the MAT files, and compute the policy function, according to the MATLAB files.

As KKM, this solution doesn't provide a value for $$\lambda_t$$: the value used here is the mean of weighted marginal utilities of consumption.

Test results

Here are preliminary test results for Test 1 for 2 countries test1.pdf

JedcTestsuiteWiki: TestBenchProblemA (last edited 2010-08-18 10:57:35 by SébastienVillemot)