I have a model as shown below that regresses previous data for a unit/context in a hierarchical model to newer data. I’m using the alpha0 coefficient fit from historical data (N_0, c_0), and then centering it and feeding it into a regression. My question - will mu0 and a0 get unintentionally partially fit on the new data (N_, c_) as well as the old data? Is there a way to avoid this and only fit mu0 and a0 on the historical data (N_0, c_0)?
with pm.Model() as m1:
# Model historical data
mu0 = pm.Normal("mu0", -1.85, 0.5, shape=2)
a0 = hierarchical_normal("a0", (n_units,2), mu0)
p0 = pm.math.invlogit(a0)
conv_pre = pm.Binomial("conv_pre", N_0, p0[i_, v_], observed=c_0)
# Model new data
theta = pm.HalfNormal("theta", 1)
mu_a = pm.Normal("mu", -1.85, 0.5, shape=2)
a = hierarchical_normal("a", (n_units,2), mu_a)
## Center historical data
centeredX = pm.Deterministic("centeredX", (a0[i_] - a0[i_].mean() ))
## Regress new data onto historical data
p = pm.math.invlogit(a[i_, v_] + centeredX*theta)
conv = pm.Binomial("conv", N_, p, observed=c_)
trace = pm.sample(target_accept=0.95, tune=2000, return_inferencedata=True)
Side question, could someone sanity check the centering (mean-zeroing) on this model? For hierarchical models should I subtract the global mean from each context or the context mean from each context?