
Redadme.txt

This file explains how to run the Matlab codes for Kim, Kim and Kollmann (JEDC). 

<Simulation>
1. First, run KKK_simul.m .  This simulates the model economy for 10,000 periods with given individual and aggregate shocks (ind_switch.txt and agg_switch.txt). Initial distribution of capital for employed and unemployed agents are also given (empl.txt and unempl.txt). 
2. KKK_simul.m saves result files in STAT.mat (cross sectional statistics) and res.mat (time-series data).  It also saves selected time-series data in hL.mat.
3. All the files starting with Table.m generates each table required in the Problem B simulation. There are five such files, 8-1-1, 8-1-2-, 8-1-3-, 8-2, 8-3.  Moments are generated by moments.m file. 
4. Some codes that are used by KKK_simul.m
a. cross_RK.m: generates cross-sectional statistics with given capital distribution.
b. aggcapital_RK.m: generates next periods capital distribution based on nonstochastic simulation process proposed by Den Haan.
c. aggcapital_ALM.m: generates next periods capital distribution based on aggregate law of motion from the model solution. 

<Model solution>
1. KKK_simul.m uses gensys2.m for first order and second order perturbation solution. 
2. gensys2.m and other related files are all in the zip file including order2guts.m,  prodt.m, qzdiv.m, qzswitch.m. 
3. Two matlab codes are used to generates input matrices for gensys2. 
a. jedcB1f.m: define variables and first order conditions of the model.
b. pregen.m: generates first and second order derivatives using numerical method. It uses grad1.m and hessTWO.m. 
4. jedcB1_POLF_pos.m takes the output of gensys2 and generates policy function. It also implements nonzero capital constraint. 


