Skip to content

Commit a7491ea

Browse files
committed
add RSV example
1 parent 1785ec1 commit a7491ea

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

pymc3/examples/rsv.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import pymc3 as pm
2+
import numpy as np
3+
4+
# 1-year-old children in Jordan
5+
kids = np.array([180489, 191817, 190830])
6+
# Proportion of population in Amman
7+
amman_prop = 0.35
8+
# infant RSV cases in Al Bashir hostpital
9+
rsv_cases = np.array([40, 59, 65])
10+
11+
with pm.Model() as model:
12+
13+
# Al Bashir hospital market share
14+
market_share = pm.Uniform('market_share', 0.5, 0.6)
15+
16+
# Number of 1 y.o. in Amman
17+
n_amman = pm.Binomial('n_amman', kids, amman_prop, shape=3)
18+
19+
# Prior probability
20+
prev_rsv = pm.Beta('prev_rsv', 1, 5, shape=3)
21+
22+
# RSV in Amman
23+
y_amman = pm.Binomial('y_amman', n_amman, prev_rsv, shape=3, testval=100)
24+
25+
# Likelihood for number with RSV in hospital (assumes Pr(hosp | RSV) = 1)
26+
y_hosp = pm.Binomial('y_hosp', y_amman, market_share, observed=rsv_cases)
27+
28+
29+
30+
31+
def run(n=1000):
32+
if n == "short":
33+
n = 50
34+
with model:
35+
trace = pm.sample(10000, step=[pm.NUTS(), pm.Metropolis()])
36+
37+
if __name__ == '__main__':
38+
run()
39+
40+

0 commit comments

Comments
 (0)