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;
- stats.py defines some small functions used throughout the simulations, including:
- post_var(): calculate the posterior variance, correspond to eq(2);
- shocks(): calculate Zt and Yt from shocks dZt;
- tau_calculator(): calculate tau for the cohorts in the economy;
- good_times(): information indicator;
- solver.py defines some small solver functions, including:
- bisection(): Bisection method to solve for any the solution in any equation;
- solve_theta(): combines with bisection(), contains RHS - LHS of the eq(24), used to iteratively solve market-clearing price of risk, ie. theta;
- find_the_rich(): finds the agents that make the top 5% 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 a function that builds up an OLG economy;
- cohort_simulator.py defines a function that simulates the OLG economy forward;
- simulation.py defines a function that wraps 4 and 5 in one function;
- V_hat_experiment.py changes V_hat, or initial variance, and generates graphs to illustrate the simulation results;
- main.py is the main loop that simulates the economy, and generates graphs to illustrate the simulation results.