-
Notifications
You must be signed in to change notification settings - Fork 10
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
Update demographics.py and other files #14
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made some comments and suggestions to the population, fertility, mortality, and immigration functions.
@rickecon To help understand the South African population profiles, here are the detailed profiles prepared by UN Population: https://population.un.org/wpp/Graphs/DemographicProfiles/Line/710 |
@rickecon I looked at the population trends for South Africa and the data is correct. South Africa experienced a big change in fertility and mortality due to a few causes. My quick search of the literature give some clues (preferences, risk aversion by women, HIV epidemic and mortality, etc). When we analyze the results, we will need to keep these factors in mind as the population structure has been affected by the large changes in the 2000s. |
@SeaCelo. I fixed the issue with the transition path equilibrium not satisfying the resource constraint in the first period. For the transition path, we have to compute the population distribution in the period before the initial period. Things like the total capital stock and total bequests in the first period depend on the population distribution in the period before that. So The baseline steady-state solution output is the following:
The baseline transition path solution output is the following;
The reform steady-state solution output is the following:
And the reform transition path solution output is the following:
|
@SeaCelo and @sarvonz. I incorporated @sarvonz changes from his PR to my branch into this PR. However, I did it differently. For this reason, I closed his PR to my branch as well as closed his original infant mortality PR to the main repository. I decided to create a new function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
@rickecon I can't checkout this branch.
Gives me an error:
I had to reset the merge with |
I was able to successful run the model. |
@sarvonz Add your review when you have a chance please |
@SeaCelo and @sarvonz. This PR should have been ready to merge, but it is not. My reform steady state did not solve. This is a very rare occurrence, but I should not be surprised given the test that we ran. The steady state solution can be pretty sensitive to starting values. As such, I need to take the robustness algorithm that I built into OG-Core in PR #836 and add it to the reform steady state. My failed results from this run are below. Baseline steady state equilibrium computation output
Baseline transition path equilibrium computation output (20 min, 12 sec)
Reform steady state equilibrium computation output
|
@rickecon This is unusual. Were you running the If so, I think I see the issue. It is that with the reform parameters object, the values are set to the default from OG-Core. The code reads: p2 = Specifications(
baseline=False,
num_workers=num_workers,
baseline_dir=base_dir,
output_base=reform_dir,
)
# additional parameters to change
updated_params_ref = {
"cit_rate": [[0.26]],
"debt_ratio_ss": 1.2,
}
p2.update_specifications(updated_params_ref) But I think what you want is: p2 = Specifications(
baseline=False,
num_workers=num_workers,
baseline_dir=base_dir,
output_base=reform_dir,
)
p2.update_specifications(
json.load(
open(
os.path.join(
CUR_DIR, "..", "ogzaf", "ogzaf_default_parameters.json"
)
)
)
)
# Update parameters from calibrate.py Calibration class
c2 = Calibration(p2)
updated_params = c2.get_dict()
p2.update_specifications(updated_params)
# additional parameters to change
updated_params_ref = {
"cit_rate": [[0.26]],
"debt_ratio_ss": 1.2,
}
p2.update_specifications(updated_params_ref) Or (for fewer lines of code): p2 = copy.deepcopy(p)
p2.baseline = False
p2.output_base = reform_dir
# additional parameters to change
updated_params_ref = {
"cit_rate": [[0.26]],
"debt_ratio_ss": 1.2,
}
p2.update_specifications(updated_params_ref) With this, the differences in parameterization between the baseline and reform will be much less and therefore the baseline solution will represent good starting values for the reform. What is currently run is just too different because you switch from ZAF demographics, policy, etc. to the OG-Core default values for those (which as more or less the USA values). |
OK. @jdebacker's suggestion fixed it. I updated Reform steady state equilibrium computation output
Reform transition path equilibrium computation output (21 min, 25 sec)
|
@rickecon In my test it didn't find a SS solution with the default value |
@SeaCelo. Make sure you updated your
Now run If this doesn't work, let's set up a video call for sometime today for me to look at what you have. You and I have the same hardware setup. This should be working. |
Re-installing OG-CORE solved the issue and I have identical results. Merging this PR |
This PR:
demographics.py
to use the UN population data portal data for South Africa. This only uses the population, fertility, and mortality data through 2021, which solves Issue Source demographic data from UN Population API #4 . But we could use the forecast data as well, as recommended in Issue Use UN Population forecasts in demographics.py #8. However, when I experimented with the forecast data, it looked very different from the past data.demographics.py
for the fertility rate data. The new functions are ?.gitignore
run_og_zaf.py
script to include the new South Africa data indemographics.py
calibrate.py
file to include the new South Africa data indemographics.py
.csv
files so the function does not have to download themmacro_params.py
file to comment out things we don't use and change things we don't have data for. This file still has a bunch of India calibration data. We will do a lot of work here in the next month to update the South Africa calibration.Another note is that when I run the
run_og_zaf.py
script, the model stops after the first (baseline) steady-state computation because the resource constraint (the equation left out of the solution by Walra's Law) is only solved to 0.0006 precision. That is pretty precise, but it should really be arbitrarily small, like 1e-8. I need to go through the theory and why the resource constraint is not solving precisely. My hypothesis is that there is some inconsistency with how the demographics are handled between the fertility rates, mortality rates, and immigration rates versus the steady-state population distribution. I'll do more work on this. I will leave this PR as a draft (i.e., cannot be merged) until I fix this problem.closes #4
cc: @SeaCelo