Created
October 10, 2022 09:42
-
-
Save NunoSempere/715fd697ff3ebbb704e4a239e559d148 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
valueOfInterventionInPopulation(num_beneficiaries, population_age_distribution, benefitForPersonOfAge) = { | |
age_of_beneficiaries = sampleN(population_age_distribution, num_beneficiaries) | |
benefits_array = List.map(age_of_beneficiaries, {|a| benefitForPersonOfAge(a)}) | |
total_benefits = List.reduce(benefits_array, 0, {|acc, value| acc + value}) | |
total_benefits | |
} | |
valueWithUncertaintyAboutNumBeneficiaries(num_beneficiaries_dist, population_age_distribution, benefitForPersonOfAge) = { | |
referenceN = 1000 | |
referenceValue = valueOfInterventionInPopulation(referenceN, population_age_distribution, benefitForPersonOfAge) | |
numSamples = 1001 | |
num_beneficiaries_samples_list = sampleN(num_beneficiaries_dist, numSamples) | |
benefits_list = List.map(num_beneficiaries_samples_list, {|n| referenceValue*n/referenceN}) | |
result = mixture(benefits_list) | |
result | |
} | |
valueWithUncertaintyAboutPopulationShape(num_beneficiaries_dist, population_age_distribution_list, benefitForPersonOfAge) = { | |
benefits_list = List.map(population_age_distribution_list, {|population_age_distribution| valueWithUncertaintyAboutNumBeneficiaries(num_beneficiaries_dist, population_age_distribution, benefitForPersonOfAge)}) | |
result = mixture(benefits_list) | |
result | |
} | |
population_age_distribution_list = [to(1, 30),to(1, 40),to(1, 60), to(2, 30), to(2, 40), to(2, 60), to(3, 30), to(3, 40), to(3, 60), to(4, 50)] | |
num_beneficiaries_dist = 700 to 1500 | |
life_expectancy = 40 to 60 | |
benefitForPersonOfAge(age) = { | |
result = age > 5 ? mx(0) : { | |
counterfactual_child_mortality = SampleSet.fromDist(0.01 to 0.07) | |
// https://apps.who.int/gho/data/view.searo.61200?lang=en | |
child_mortality_after_intervention = counterfactual_child_mortality/2 | |
chance_live_before = (1-(counterfactual_child_mortality))^(5-age) | |
chance_live_after = (1-(child_mortality_after_intervention))^(5-age) | |
value = (chance_live_after - chance_live_before) * (life_expectancy - age) | |
value | |
} | |
result | |
} | |
valueWithUncertaintyAboutPopulationShape(num_beneficiaries_dist, population_age_distribution_list, benefitForPersonOfAge) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment