This directory contains code for solving specification A8 of

	Computing Stochastic Dynamic Economic Models with 
	a Large Number of State Variables: A Description
	and Application of a Smolyak-Collocation Method

	by Ben Malin, Dirk Krueger, and Felix Kubler

Below we describe the Fortran files and how they should be compiled.

FORTRAN FILES  	        BRIEF DESCRIPTION
--------------         	--------------------
AccCheck1.f90		Performs Accuracy Test 1
AccCheck1Sub.f90	Subroutine called by AccCheck1.f90
AccCheck2.f90		Performs Accuracy Test 2
AccCheck3.f90 		Performs Accuracy Test 3
ChebPoly.f90		Constructs Chebyshev polynomial for a given state
ChebValue.f90		Returns value of policy function for a given state
DecRule.f90		Constructs Output for Policy Function Figures
DecRule2.f90		Constructs Output for Policy Function Figures (finer grid)
EulerEquation.f90	Specifies system of equilibrium equations
ExpectFOC.f90		Specifies integrand for intertemporal equil cond (used to solve model)
ExpectFOC_MCSimul.f90	Specifies integrand for ... (used in simulations - MC integration)
ExpectFOC_Simul.f90	Specifies integrand for ... (used in simulations - Mon integration)
GetIndex.f90		Constructs an index -- used by Regression.f90
Grid.f90		Initialize parameters, smolyak points, etc.
Interpolate.f90		Computes coefficients for Smolyak polynomials (w/ Regression)
Main.f90		Main Progam, calls all subroutines
MCIntegrate.f90		Monte-Carlo Integration
MonIntegrate.f90	Monomial Integration
OutCoeff.f90		Outputs coefficients of policy rules
Output.f90		Outputs results
Params.f90		Defines global variables
ParamUpdate.f90		Initializes some parameter values
Policy.f90		Solves for Policy Functions
PolicyInitial.f90	Constructs Initial Guess for policy functions
Regression.f90		Computes coefficients for Smolyak polynomials
StaticFOC.f90		Specifies static equilibrium conditions
WriteRowM.f90		Outputs numeric data
WriteRowT.f90		Outputs character data
WriteColM.f90		Outputs numeric data

INSTRUCTIONS FOR COMPILING THE CODE
---------------------------------------------------------------
Following is a list of each fortran file and the subroutine(s) it calls.
The list is ordered from the highest level (Main is the program file
and is not called by any other files.) to the lowest (Params defines
global variables and is referenced by all other files.).


Main -- AccCheck1, AccCheck2, AccCheck3, DecRule, DecRule2, Grid, OutCoeff, Output,
	ParamUpdate, Policy, PolicyInitial, Params
 AccCheck1 -- AccCheck1Sub, Params
  AccCheck1Sub -- ChebPoly, ChebValue, MCIntegrate, MonIntegrate, StaticFOC, Params
   ChebPoly -- Params
   ChebValue -- Params
   MCIntegrate -- ExpectFOC_MCSimul, Params
    ExpectFOC_MCSimul.f90 -- ChebValue, Params
   MonIntegrate -- ExpectFOC, ExpectFOC_Simul, Params
    ExpectFOC.f90 -- ChebValue, StaticFOC, Params
    ExpectFOC_Simul.f90 -- ChebValue, StaticFOC, Params
   StaticFOC -- Params
 AccCheck2 -- ChebPoly, ChebValue, MCIntegrate, MonIntegrate, StaticFOC, Params
 AccCheck3 -- ChebPoly, ChebValue, MCIntegrate, MonIntegrate, StaticFOC, Params
 DecRule -- ChebPoly, ChebValue, StaticFOC, Params
 DecRule2 -- ChebPoly, ChebValue, StaticFOC, Params
 Grid -- Params
 OutCoeff -- WriteRowM, WriteRowT, WriteColM
 Output -- WriteRowM, WriteRowT, Params
  WriteRowM -- Params
  WriteRowT -- Params
 ParamUpdate -- Params
 Policy -- ChebPoly, ChebValue, EulerEquation, Interpolate, Regression, Params
  EulerEquation -- ChebPoly, MonIntegrate, StaticFOC, Params
  Interpolate -- Regression, Params
   Regression -- GetIndex, Params
    GetIndex -- Params
 PolicyInitial -- Params
 Params

OTHER COMMENTS ON COMPILING THE CODE
--------------------------------------
1) The file 'makefile' provides code for compiling/linking the fortran files
on a unix machine.  Use the command 'make' at the unix prompt.  The file
may need to be altered to be compatible with your fortran compiler.

2) The program uses routines from the Fortran IMSL library for generating
random numbers, solving systems of nonlinear equations, and inverting 
matrices.

3) The code uses initial guesses generated by a (log-)linear solution to the
model.  The coefficients are stored in initguessN.csv, for N = 2,4,6.  The
InitialGuess folder contains MATLAB code that generates the linear solution.
