You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As discussed with @ricardoV94, currently, we can change observations with the do operator only for a model that has no observations, i.e only free or deterministic variables:
Before
# define modelwithpm.Model() asm:
x=pm.MutableData("x", np.linspace(-5, 5, 50))
b0=pm.Normal("b0")
b1=pm.Normal("b1")
noise=pm.HalfNormal("noise")
y=pm.Normal("y", pm.math.sigmoid(b0+b1*x), sigma=noise, observed=np.random.randn(50))
# generate new observations, e.g for parameter-recovery studywithpm.do(m, {noise: 1.0}) asprior_m:
prior_pred=pm.sample_prior_predictive(1).isel(chain=0, draw=0)
# run inference with these new observationswithpm.observe(m, {y: prior_pred.prior_predictive["y"]}) asobserved_m:
posterior=pm.sample()
# this raisesValueError: Atleastonevarisnotafreevariableordeterministicinthemodel