See iPython notebook for full example
The below stochastic node y_pred
enables me to generate the posterior predictive distribution:
with pm.Model() as model:
alpha = pm.Gamma('alpha', alpha=.1, beta=.1)
mu = pm.Gamma('mu', alpha=.1, beta=.1)
y_pred = pm.NegativeBinomial('y_pred', mu=mu, alpha=alpha)
y_est = pm.NegativeBinomial('y_est', mu=mu, alpha=alpha, observed=messages['time_delay_seconds'].values)
start = pm.find_MAP()
step = pm.Metropolis(start=start)
trace = pm.sample(20000, step, start=start, progressbar=True)
And the posterior predictive distribution plot:
Solution #1: @inversion points out that the shape parameter must be provided.
Problem #2: The samples from the posterior predictive are not correct. They get stuck at 0 or 1. Any ideas how to resolve this? I have only been able to reproduce this issue with hierarchal models.
Metropolis(start=start)
works in the above code, and fails when I try to use it (unexpected kwd error).pm.__version__ = 3.0
$\endgroup$