Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions posterior_database/models/info/earn_height.info.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
"stan": {
"model_code": "models/stan/earn_height.stan",
"stan_version": ">=2.26.0"
},
"pymc": {
"model_code": "models/pymc/earn_height.py",
"pymc_version": ">=5.16.2"
}
},
"references": "gelman2006data",
Expand Down
23 changes: 23 additions & 0 deletions posterior_database/models/pymc/earn_height.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import numpy as np
import pymc as pm

def model(data):

# Define PyMC Model
coords = {
'obs_idx': np.arange(data["N"]),
'feature': ['intercept', 'height']
}

with pm.Model(coords=coords) as earn_height:
N = pm.Data("N", data["N"])
earn = pm.Data('earn', data['earn'], dims=['obs_idx'])
height = pm.Data('height', data['height'], dims=['obs_idx'])

beta = pm.Flat('beta', dims=['feature'])
mu = beta[0] + beta[1] * height

sigma = pm.HalfFlat('sigma')
earn_hat = pm.Normal('earn_hat', mu=mu, sigma=sigma, observed=earn, dims=['obs_idx'])

return earn_height