Skip to content

Commit 0fe01bf

Browse files
authored
Merge pull request #264 from fonnesbeck/eight_schools_nc_pymc
Eight schools noncentered model in PyMC
2 parents 666c698 + 7a1fbc1 commit 0fe01bf

3 files changed

Lines changed: 21 additions & 20 deletions

File tree

posterior_database/models/info/eight_schools_noncentered.info.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@
1313
"model_code": "models/stan/eight_schools_noncentered.stan",
1414
"stan_version": ">=2.26.0"
1515
},
16-
"pymc3": {
17-
"model_code": "models/pymc3/eight_schools_noncentered.py"
16+
"pymc": {
17+
"model_code": "models/pymc/eight_schools_noncentered.py",
18+
"pymc_version": ">=5.16.2"
1819
}
1920
},
2021
"added_by": "Mans Magnusson",
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import numpy as np
2+
import pymc as pm
3+
4+
5+
def model(data):
6+
y_obs = np.array(data["y"]) # estimated treatment
7+
sigma = np.array(data["sigma"]) # std of estimated effect
8+
coords = {"school": np.arange(data["J"])}
9+
with pm.Model(coords=coords) as pymc_model:
10+
11+
mu = pm.Normal(
12+
"mu", mu=0, sigma=5
13+
) # hyper-parameter of mean, non-informative prior
14+
tau = pm.HalfCauchy("tau", beta=5) # hyper-parameter of sigma
15+
theta_trans = pm.Normal("theta_trans", mu=0, sigma=1, dims="school")
16+
theta = mu + tau * theta_trans
17+
y = pm.Normal("y", mu=theta, sigma=sigma, observed=y_obs)
18+
return pymc_model

posterior_database/models/pymc3/eight_schools_noncentered.py

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)