-
Notifications
You must be signed in to change notification settings - Fork 5
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
Permanent income levels are not randomized #271
Comments
@alanlujan91 I'm not sure what's going on with the population seed. It seems to be trying to something here: https://github.com/sbenthall/SHARKFin/blob/master/simulate/run_any_simulation.py#L187-L189 |
hmm maybe changing the seed is not resetting the RNG? |
which notebook has this output? |
Visualize Sim, when the output from the run_any_simulation.py is opened in it. https://github.com/sbenthall/SHARKFin/blob/master/simulate/Visualize%20Sim.ipynb The missing part of the workflow to reproduce is to load the data into that notebook after each execution. |
not really sure how to debug this one.. I tried resetting the seed but that wasn't it |
Ok, I've written a new automated test which exposes the (increasingly weird) issue: This test current fails at line 62: What this test is doing is creating two different SharkfinPopulations with different random seeds, and simulating forward, then comparing the pLvls (a) between agents within the same population, and (b) between agents across the two populations (but with the same index). The findings are quite strange to me. With a long T_sim, there are differences between the pLvl processes between agents and populations. [Side note: couldn't figure out how to get it to simulate fewer than 1000 periods -- setting T_sim in the parameters dict didn't seem to work]. BUT for all the agents, whichever population, they have identical permanent income processes for the first 28 simulated periods. I have no idea why this is the case. But recall that we've been running experiments with rather few 'quarters' or periods (4). So if we are getting identical processes for all agents, then that is effectively entirely correlated incomes across and within each simulation. |
I've been able to reduce this to a bug in HARK: |
Fixing this in HARK probably helped econ-ark/HARK#1380 BUT the tests are still failing. For some reason the SharkfinPopulation agents all have the same seeds for their income distributions. Likely this means that they are not getting new random seeds passed to the AgentTypes. |
Better test isolating the issue: https://github.com/sbenthall/SHARKFin/blob/master/sharkfin/tests/test_population_seed_issue.py |
https://github.com/sbenthall/SHARKFin/blob/master/sharkfin/population.py#L110-L126 Looks like the income distributions are being copied over with 'deepcopy'. Initializing new agents might have been a better choice here. I'll see what sort of fix I can get in. |
This is now fixed! We are now getting uncorrelated income shocks, so the mean log income is very close to the log DPHM. It took some extra lines in SharkPopulation |
No, stlll not working right... |
Ok, fixed this at last I think. |
Gets me this plot of the mean permanent income levels:
Changing the seed:
Gets me this:
Which is the same!
The permanent income levels are stochastic, but they seem to be using the same random seed even though the SHARKFin random seed is different.
The mean log income is listed as '5' because it's factoring in the DPHM, which is 148 = e^5
The text was updated successfully, but these errors were encountered: