Last updated on 2017-08-22. For He, Z., & Krishnamurthy, A. (2014). A macroeconomic framework for quantifying systemic risk.

Before running any file, change to the directory of “readme.txt” first.

1. Main Solution: 
main_baseline.m is the main file for the baseline case. main_baseline.m solves the system of ODEs, simulates the model, and then output key results to simulationresult_KeyResults_temp.csv, and table4 results to table4_result.csv

Solution for other cases are in files  main_sigma=0.04, main_maversion=1.8, main_maversion=2.4,  main_lambda=0.772.m

For case phi=0, because the equation system is different, all files are in the separate subfolder “phi=0”.

2. FIGURES
Figure 2 and 3: run recoveringdZ.m, and then copy the matrix output in Figure3_Simulation.csv into SimulationResults.xlsx, tab “Figure3”, where both figure 2 and figure 3 are generated.  

Figure 4-6: run OutputFigures.m. 

Figure 9: myear_crisisprob_startingec.m provides the probability of a crisis within the next 2 years for a number
of different six-quarter scenarios. 

3. Tables
Table 4: For each case, results for Table 4 are in csv files starting with “table4…”.

Table 6: Codes in recoveringdZ_stresstest.m, to generate probability of crisis under different scenarios. 

Three cases: recoveringdZ.m generates results for three cases, lambda=0.75, lambda=0.772, and hidden leverage. 

4. Others
Probability of systemic risks in section 7.2 is calculated by myear_crisisprob_startingec_trueleverage.m.  myear_crisisprob_startingec.m calculates the probability of crisis starting from different e, which is output as Figure 8.  Note that myear_crisisprob_startingec.m must be run to generate a new file simulation_Baseline_ProbCrisis.mat, in order to simulate other smaller crisis.

Then the hidden leverage case is calculated by myear_crisisprob_startingec_hiddenleverage.m.

Simulating smaller crisis: recoveringdZ_updated_otherrecessions.m, plot the time series of crisis probability based on observed equity series. Before running recoveringdZ_updated_otherrecessions.m, we have to first run myear_crisisprob_startingec.m to get needed variables saved in simulation_Baseline_ProbCrisis.mat. 

Appendix: use Appendix_DifferentEc.m for different definitions of distress.





