Thanks both @ricardoV94 @jessegrabowski, pytensor
got me a long way. The item I am stuck with now is
1). getting samples of a particular variable from trace,
2). getting samples of a particular variable from prior/posterior predictive.
For example, the code below produces errors on the last two lines. What am I doing wrong? Here is a link to Colab with the same code for reproducibility.
import pymc as pm
n = 250
with pm.Model() as model:
alpha = pm.Gamma('alpha', alpha=4, beta=0.5)
beta = pm.Gamma('beta', alpha=4, beta=0.5)
x1 = pm.Beta('x1', alpha, beta)
x2 = pm.Beta('x2', alpha, beta)
k1 = pm.Binomial('k1', n=n, p=x1, observed=140)
k2 = pm.Binomial('k2', n=n, p=x2, observed=110)
with model:
trace_prior = pm.sample_prior_predictive(500)
with model:
trace_sample = pm.sample(500)
trace_prior['alpha']
trace_sample['alpha']