Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to OG-MYS Calibration #8

Merged
merged 35 commits into from
Jan 10, 2023
Merged

Conversation

jdebacker
Copy link
Collaborator

This PR updates demographics.py to fully utilize the UN population data.

@jdebacker
Copy link
Collaborator Author

Population distribution over the transition path (note that "2013" label should not be there (it's really 2021), there needs to be an update to this in OG-Core parameter plots):

PopDistPath

@jdebacker
Copy link
Collaborator Author

Getting SS to solve with new demographics, except for a small-ish resource constraint error:

Resource Constraint Difference: [3.55142995e-08]

This must be a result of the new MYS demographics. Will try to explore to see if can diagnose issue.

@jdebacker
Copy link
Collaborator Author

I got carried away in this PR and now update:

  • demographics.py: reads in UN data, creates population objects that are consistent over the transition path
  • income.py to rescale the earnings process to match the Gini coefficient for income in MYS
  • ogmys_default_parameters.json to income a two sector model where one sector is the the formal sector and the other the informal sector (calibrated to match the numbers reported in Issue Informal sector #9).

@rickecon This PR is ready for your review.

@jdebacker jdebacker changed the title [WIP] Updates to demographics.py Updates to OG-MYS Calibration Dec 5, 2022
@rickecon
Copy link
Collaborator

@jdebacker. Can you update this PR by merging previous updates into this branch. I get an error when I try to pull this branch to test it. Also, I want to give it a full test and make sure it works with the OG-Core updates.

@jdebacker
Copy link
Collaborator Author

@rickecon Where are your changes? I don't see an open PR in my branch and my local and remote calib branches are the same... There are also no changes from the main branch not in calib.

@rickecon
Copy link
Collaborator

rickecon commented Jan 10, 2023

@jdebacker. Your merge remote tracking branch did it. I have made two changes to environment.yml which I have submitted to your branch as a PR. I remove the mkl dependency and add and pin an openssl=1.1.1 dependency. This latter change allows the code to interact with the UN data portal, where it doesn't reliably otherwise. Below is the output from my run of run_og_mys.py.

Baseline steady-state equilibrium computation output

GE loop errors =  [2.0539125955565396e-15, 2.0747292772682613e-15, -2.4424906541753444e-13, 5.997424779025096e-13, 0.0, -2.490452288839151e-12, 7.2026828945581656e-12, 1.429412144204889e-15, 2.040034807748725e-15, 1.8943180357666733e-15, -2.7598548446583493e-12, -8.197498235773537e-12, 7.157868048279781e-13, -2.241540286718191e-13, 4.055783486833775e-15]
Iteration: 01  Distance:  7.655955216266368e-11
SS debt =  5.18848557232938 0.04060941134785257
IO:  (2, 2) , C:  (2,)
Foreign debt holdings =  1.349006248805639
Foreign capital holdings =  27.298845115933915
resource constraint:  [ 7.01105840e-13 -7.87814258e-13]
Checking constraints on capital, labor, and consumption.
	There were no violations of the constraints on labor  supply.
	There were no violations of the constraints on  consumption.
Maximum error in labor FOC =  1.3211653993039363e-13
Maximum error in savings FOC =  5.2735593669694936e-14
JUST SAVED SS output to  /Users/richardevans/Docs/Economics/OSE/OG-MYS/examples/OG-MYS-Example/OUTPUT_BASELINE/SS/SS_vars.pkl

Baseline transition path equilibrium computation output (19 min, 6 sec)

Maximum debt ratio:  1.0046222640141842
w diff:  7.443014149899341e-06 -1.9809410209958855e-06
r diff:  1.5532708820542585e-08 -6.952504288254557e-08
r_p diff:  1.5532708820542585e-08 -6.952504287560668e-08
p_m diff:  1.680367203160671e-07 -7.322191715175563e-07
BQ diff:  5.196930140949352e-07 -1.8916804596369463e-07
TR diff:  1.0424547481346913e-06 -2.4068869068916143e-06
Iteration: 23
	Distance: 7.265744980087213e-06
Max absolute value resource constraint error: 4.404882124386944e-06
Checking time path for violations of constraints.
Max Euler error, savings:  1.2142509220325337e-12
Max Euler error labor supply:  5.239142453206114e-13
Time path iteration complete.
It took 1145.6528902053833 seconds to get that part done.
run time =  1145.65407204628

Reform steady-state equilibrium computation output

GE loop errors =  [-2.1510571102112408e-16, -2.1510571102112408e-16, 2.7533531010703882e-14, 3.808064974464287e-14, 0.0, -2.4868995751603507e-14, 1.124100812432971e-15, 1.429412144204889e-15, 1.3739009929736312e-15, 8.187894806610529e-16, 9.853229343548264e-16, 1.3739009929736312e-15, 3.139849491518021e-16, -2.220446049250313e-15]
Iteration: 01  Distance:  2.2870594307278184e-14
SS debt =  5.092651334368707 0.03985933274855799
IO:  (2, 2) , C:  (2,)
Foreign debt holdings =  1.3240893469358639
Foreign capital holdings =  26.287237733607316
resource constraint:  [ 1.04916076e-14 -1.95843342e-13]
Checking constraints on capital, labor, and consumption.
	There were no violations of the constraints on labor  supply.
	There were no violations of the constraints on  consumption.
Maximum error in labor FOC =  1.354472090042691e-13
Maximum error in savings FOC =  5.839773109528323e-14
JUST SAVED SS output to  /Users/richardevans/Docs/Economics/OSE/OG-MYS/examples/OG-MYS-Example/OUTPUT_REFORM/SS/SS_vars.pkl

Reform transition path equilibrium computation output (19 min, 7 sec)

Maximum debt ratio:  1.000646523762102
w diff:  6.952585409614187e-06 -2.72079758989463e-06
r diff:  2.1454342094551215e-08 -6.59347372464203e-08
r_p diff:  2.1454342080673428e-08 -6.59347372464203e-08
p_m diff:  2.4113427643523977e-07 -7.340347901729771e-07
BQ diff:  4.993968372030144e-07 -1.9601732818841366e-07
TR diff:  1.0538954378636056e-06 -2.53021897583805e-06
Iteration: 23
	Distance: 7.070719269800366e-06
Max absolute value resource constraint error: 4.234165208227836e-06
Checking time path for violations of constraints.
Max Euler error, savings:  1.2809198146612744e-12
Max Euler error labor supply:  5.384581669432009e-13
Time path iteration complete.
It took 1147.4860548973083 seconds to get that part done.
run time =  1147.4871571063995
Percentage changes in aggregates: Year                    Variable  2021  2022  2023  2024  2025  ...  2027  2028  2029  2030  2021-2030    SS
0                    GDP ($Y_t$) -2.21 -2.16 -2.11 -2.07 -2.03  ... -1.97 -1.94 -1.92 -1.90      -2.03 -1.85
1            Consumption ($C_t$) -1.44 -1.42 -1.55 -1.62 -1.67  ... -1.74 -1.76 -1.79 -1.81      -1.65 -2.02
2          Capital Stock ($K_t$) -3.73 -3.68 -3.62 -3.58 -3.54  ... -3.47 -3.45 -3.43 -3.40      -3.54 -3.38
3                  Labor ($L_t$) -0.09 -0.03  0.02  0.06  0.09  ...  0.15  0.16  0.18  0.20       0.09  0.32
4     Real interest rate ($r_t$) -0.15 -0.15 -0.15 -0.15 -0.15  ... -0.16 -0.18 -0.18 -0.19      -0.16 -0.10
5                      Wage rate -2.12 -2.12 -2.12 -2.12 -2.12  ... -2.11 -2.10 -2.10 -2.09      -2.11 -2.16

[6 rows x 13 columns]

@rickecon
Copy link
Collaborator

@jdebacker. I am ready to merge this as soon as you merge my PR to your branch.

@jdebacker
Copy link
Collaborator Author

Thanks @rickecon - I just merged your PR to this branch.

@rickecon
Copy link
Collaborator

@jdebacker. Looks great. Thanks. Merging.

@rickecon rickecon merged commit f37eb00 into Revenue-Academy:main Jan 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants