The folder "NewKeynesianModel" contains MATLAB software that solves 
a new Keynesian model using an epsilon distinguishable set algorithm (EDS) 
and cluster grid algorithm (CGA); it accompanies the article "Merging 
simulation and projection approaches to solve high-dimensional problems 
with an application to a new Keynesian model" by Lilia Maliar and Serguei 
Maliar (2015), Quantitative Economics 6/1, pages 1–47 (henceforth, MM, 2015). 

This software is written to illustrate a general methodology proposed in 
MM (2015) and replicate the results in that paper. The running time was
not the priority. The following modifications will speed up the code (the
optimized code can be as fast as 5 seconds at only moderate accuracy loss):

1. Use shorted simulation length, for example, T = 10,000 and do not remove 
the low density points. 
2. Use the simulated series produced by perturbation method for constructing
the EDS / CGA grid and do not update the grid along iterations. 
3. Choose the number of grid points to be slightly larger than the number of 
the polynomial coefficients, for example, use 50 grid points for 2nd degree 
polynomial approximation with 45 coefficients. Do not iterate on "epsilon" 
by using a bisection but use some prior experimentation to find the value 
of "epsilon" that leads to target number of grid points. 
4. Increase damping parameters "damp" from [0.1 0.1 0.1] to larger vales that 
still leads to convergence (such values depend on a specific model).

This software is based on that of Lilia  Maliar and Serguei Maliar for 
solving models using the generalized stochastic simulation algorithm (GSSA) 
method, as described in the paper "Numerically Stable and Accurate Stochastic
Simulation Approaches for Solving Dynamic Economic Models" by Kenneth L. 
Judd, Lilia Maliar and Serguei Maliar, (2011), Quantitative Economics 2/2, 
173–210 (henceforth, JMM, 2011). The modifications made are concerned with 
the construction of the grid.

This version: March 19, 2015. First version: June 27, 2011.

 
1. "Main_NK_Degree2.m"          is a main file for computing the EDS and 
                                CGA solutions to a new Keynesian model;
                                it produces a polynomial approximation of 
                                degree 2; it uses a Dynare routine  
                                "NK_Dynare.mod" to find a perturbation
                                solution
2. "NK_Degree3.m"               produces a polynomial approximation of 
                                degree 3 using the polynomial approximation 
                                of degree 2 generated by "Main_NK_Degree2.m" 
3. "NK_Dynare.mod"              is a Dynare routine that produces perturbation
                                solutions to be used as an initial guess 
4. "NK_Simulation.m"            simulates a time series solution to the new 
                                Keynesian model for a given sequence of 
                                exogenous shocks
5. "NK_Accuracy.m"              computes residuals of the equilibrium
                                conditions of the new Keynesian model on a   
                                given set of points in the state space
6. "Density.m"                  estimates the density function from a 
                                given set of points 
7. "Clusters.m"                 constructs clusters from simulated series 
                                and computes clusters' centers (to be used 
                                as a grid) 
8. "EDS"                        constructs an epsilon distinguishable set 
                                for a given set of data (to be used as a 
                                grid)
9. "Ord_Polynomial_N.m"         constructs the sets of basis functions for 
                                ordinary polynomials of the degrees from 
                                one to five; borrowed from JMM (2011)
10. "Monomials_1.m"             constructs integration nodes and weights for 
                                an N-dimensional monomial (non-product) 
                                integration rule with 2N nodes; borrowed from 
                                JMM (2011) 
11. "Monomials_2.m"             constructs integration nodes and weights for 
                                an N-dimensional monomial (non-product) 
                                integration rule with 2N^2+1 nodes; borrowed 
                                from JMM (2011)
12. "GH_Quadrature.m"           constructs integration nodes and weights for  
                                the Gauss-Hermite rules with the number of  
                                nodes in each dimension ranging from one to  
                                ten; borrowed from JMM (2011)                     
13. "NK_shocks_100000.mat"      contains the series of the exogenous shocks 
                                of length 100,000 for the solution procedure 
                                and the series of the exogeneous shocks of 
                                length 10,200 for the test 

    To solve the model, execute "Main_NK_Degree2.m".

For updates and other related software, please, check the authors' web 
pages. For additional information, please, contact the corresponding 
author: Lilia Maliar, Department of Economics,  Stanford University, 
Stanford, CA 94305-6072, USA, maliarl@stanford.edu.

-------------------------------------------------------------------------
Copyright © 2015 by Lilia Maliar and Serguei Maliar. All rights reserved. 
The code may be used, modified and redistributed under the terms provided 
in the file "License_Agreement.txt".
-------------------------------------------------------------------------
