|
| 1 | +''' |
| 2 | +This model estimates the population prevalence of respiratory syncytial virus (RSV) among children in Amman, Jordan, based on 3 years of admissions diagnosed with RSV to Al Bashir hospital. |
| 3 | +
|
| 4 | +To estimate this parameter from raw counts of diagnoses, we need to establish the population of 1-year-old children from which the diagnosed individuals were sampled. This involved correcting census data (national estimate of 1-year-olds) for the proportion of the population in the city, as well as for the market share of the hospital. The latter is based on expert esimate, and hence encoded as a prior. |
| 5 | +''' |
| 6 | + |
| 7 | +import pymc3 as pm |
| 8 | +import numpy as np |
| 9 | + |
| 10 | +# 1-year-old children in Jordan |
| 11 | +kids = np.array([180489, 191817, 190830]) |
| 12 | +# Proportion of population in Amman |
| 13 | +amman_prop = 0.35 |
| 14 | +# infant RSV cases in Al Bashir hostpital |
| 15 | +rsv_cases = np.array([40, 59, 65]) |
| 16 | + |
| 17 | +with pm.Model() as model: |
| 18 | + |
| 19 | + # Al Bashir hospital market share |
| 20 | + market_share = pm.Uniform('market_share', 0.5, 0.6) |
| 21 | + |
| 22 | + # Number of 1 y.o. in Amman |
| 23 | + n_amman = pm.Binomial('n_amman', kids, amman_prop, shape=3) |
| 24 | + |
| 25 | + # Prior probability |
| 26 | + prev_rsv = pm.Beta('prev_rsv', 1, 5, shape=3) |
| 27 | + |
| 28 | + # RSV in Amman |
| 29 | + y_amman = pm.Binomial('y_amman', n_amman, prev_rsv, shape=3, testval=100) |
| 30 | + |
| 31 | + # Likelihood for number with RSV in hospital (assumes Pr(hosp | RSV) = 1) |
| 32 | + y_hosp = pm.Binomial('y_hosp', y_amman, market_share, observed=rsv_cases) |
| 33 | + |
| 34 | + |
| 35 | + |
| 36 | + |
| 37 | +def run(n=1000): |
| 38 | + if n == "short": |
| 39 | + n = 50 |
| 40 | + with model: |
| 41 | + trace = pm.sample(10000, step=[pm.NUTS(), pm.Metropolis()]) |
| 42 | + |
| 43 | +if __name__ == '__main__': |
| 44 | + run() |
| 45 | + |
| 46 | + |
0 commit comments