Reputation:
I have some data
X = np.array([1.0, 2.0, 3.0, 4.0, 5.0])
y = np.array([0, 1, 0, 1, 1])
I fit a model
with pm.Model() as model:
X_shared = pm.Data("X_data", X)
beta_0 = pm.Normal("beta_0", mu=0, sigma=1)
beta_1 = pm.Normal("beta_1", mu=0, sigma=1)
mu = beta_0 + beta_1 * X_shared
p = pm.math.sigmoid(mu)
y_obs = pm.Bernoulli("y_obs", p=p, observed=y)
trace = pm.sample(100)
and now I want to re-sample the posterior based on a new data point
with model:
pm.set_data({"X_data": [1.69]})
y_new_simulated = pm.sample_posterior_predictive(trace).posterior_predictive.y_obs
y_new_obs_name = f"y_new_obs_1" # Create a unique name for the Bernoulli variable
y_new_obs = pm.Bernoulli(y_new_obs_name, p=pm.math.sigmoid(beta_0 + beta_1 * 1.69), observed=y_new.posterior_predictive.y_obs)
new_trace = pm.sample(100)
but I get a broadcasting error:
ValueError: Runtime broadcasting not allowed.
My goal is to try to figure out if the new data point X
(and pretending we don't observe y
and instead must simulate it) adds information by comparing the old trace and the new trace
Upvotes: 0
Views: 47