Paul Ehling, Christian Heyerdahl-Larsen, and Zeshu XU
pip install -r requirements.txtpython3 main.py
To have a consistent coding style, use black to lint the code before commit
black main.py- param.py defines the parameters used in the simulations, and prepares matrix to store the results:
- additionally, param_mix.py defines the parameters used for the mix scenario;
- stats.py defines some base functions used repeatedly throughout the simulations, including:
- post_var(): calculate the posterior variance, correspond to eq(6);
- shocks(): calculate Zt and Yt from shocks dZt;
- tau_calculator(): calculate tau for the cohorts in the economy;
- solver.py defines some base solver functions used repeatedly throughout the simulations, including:
- bisection(): Bisection method to solve for any the solution in any equation;
- solve_theta(): combines with bisection(), contains RHS - LHS of the eq(22), used to iteratively solve market-clearing price of risk, ie. theta;
- find_the_rich(): finds the agents that make the top x% the richest population in the economy, and they can short;
- bisection_partial_constraint() and solve_theta_partial_constraint() are similar to 3.i and 3.ii, but takes more arguments;
- cohort_builder.py defines functions that build up an OLG economy:
- build_cohorts_SI(): mainly for the reentry scenario;
- build_cohorts_mix_type(): mainly for the mix scenario;
- cohort_simulator.py defines functions that simulate the OLG economy forward:
- simulate_cohorts_SI(): mainly for the reentry scenario;
- simulate_cohorts_mean_vola(): mainly for the reentry scenario, saves only time-series mean and variance; 3 simulate_cohorts_mix_type(): mainly for the mix scenario;
- simulate_mean_vola_mix_type(): mainly for the mix scenario, saves only time-series mean and variance;
- simulation.py defines functions that bundle 4 and 5 in one function (SI, mean_vola, SI_mix, mean_vola_mix);
- main_multiprocessing.py runs a large number of simulation and store data for figures 4, 8-10;
- tab3_multiprocessing.py runs a large number of rounds of simulation and store data for table3;
- main.py is the main file that:
- generates data for figures based on single paths;
- generate graphs based on data from main_multiprocessing.py
- generate tables based on data from tab3_multiprocessing.py