Skip to content

Commit 666c698

Browse files
authored
Merge pull request #269 from jessegrabowski/earn-height-pymc
Implement earnings-height model in pymc
2 parents d1819ff + 4889455 commit 666c698

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

posterior_database/models/info/earn_height.info.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
"stan": {
1212
"model_code": "models/stan/earn_height.stan",
1313
"stan_version": ">=2.26.0"
14+
},
15+
"pymc": {
16+
"model_code": "models/pymc/earn_height.py",
17+
"pymc_version": ">=5.16.2"
1418
}
1519
},
1620
"references": "gelman2006data",
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import numpy as np
2+
import pymc as pm
3+
4+
def model(data):
5+
6+
# Define PyMC Model
7+
coords = {
8+
'obs_idx': np.arange(data["N"]),
9+
'feature': ['intercept', 'height']
10+
}
11+
12+
with pm.Model(coords=coords) as earn_height:
13+
N = pm.Data("N", data["N"])
14+
earn = pm.Data('earn', data['earn'], dims=['obs_idx'])
15+
height = pm.Data('height', data['height'], dims=['obs_idx'])
16+
17+
beta = pm.Flat('beta', dims=['feature'])
18+
mu = beta[0] + beta[1] * height
19+
20+
sigma = pm.HalfFlat('sigma')
21+
earn_hat = pm.Normal('earn_hat', mu=mu, sigma=sigma, observed=earn, dims=['obs_idx'])
22+
23+
return earn_height

0 commit comments

Comments
 (0)