Draw expected lifespans at start of simulation for consistency #18
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In some recent experiments, we want to quantify life years saved as
mean_lifespan_implementation
-mean_lifespan_baseline
. Other than initial compliance rate, the baseline and implementation scenarios use the same parameters. For a given iteration, which uses the same seed, we want life expectancy to be exactly the same, but it’s not.This is due to the way we use the random number generator. We simulate each person one at a time, and we may need to draw a different number of random numbers for each person depending on the other parameters. So by the time we get to the next person’s life expectancy draw, the random number generator can be in a different state.
These random differences are fairly large, relative to the effect sizes of the initial compliance rate differences. This throws off the life years saved calculation.
This PR implements a fix by drawing expected lifespans at the start of the simulation.
In draft for now, because this still needs to be tested with an experiment.