I have data that have right censoring. Is there a way to sample from the posterior predictive (or something equivalent) without having the right censoring using pymc’s built-in tools? I’ve thought about making these values parameters, but the data set is decently large so it really affects performance. (This isn’t a deal-breaker, obviously I can sample from the posterior predictive w/o censoring using other tools once I have samples from the posterior)
Posterior predictive can be done a new model. The only thing that matters is that the variables names and shapes match. In the case of censoring you can recreate the original model without the censoring (I assume that’s what you needed?) to perform posterior predictive:
import pymc as pm
data = [0.1, 0.2, 1, 1, 1, 0.3]
with pm.Model() as m:
x = pm.Normal("x")
raw_y = pm.Normal.dist(x, shape=(len(data),))
y = pm.Censored("y", dist=raw_y, lower=None, upper=1, observed=data)
posterior = pm.sample()
with pm.Model() as pred_m:
x = pm.Normal("x")
raw_y = pm.Normal("raw_y", x, shape=(len(data),))
pp = pm.sample_posterior_predictive(posterior, var_names=["raw_y"])
pp.posterior_predictive.raw_y
You mean pp.posterior_predictive.raw_y
rather than trace.posterior_predictive.raw_y
, correct?
2 Likes
Yes, fixed it.