Hi!
I’m fitting a linear model where I have pressure and depth measurements for 4 groups. I’m estimating a separate slope for each group as well group means.
In a heirarchical model, this would be akin to fitting a varying intercept and varying slope model, and if needed, allowing for the covariance between the two. This can be expressed in the form here https://stackoverflow.com/questions/39364919/pymc3-how-to-model-correlated-intercept-and-slope-in-multilevel-linear-regressi.
However, in this case, I’m actually not trying to model this in a heirarchical model. That is, I’m fitting a ‘no pooling’ model as Gelman, Hill et al refer to this in their 2007 book on multilevel model.
What I do want is to be able to still specify that the group means and slope are drawn from a multivariate normal distribution with some prior vector of means and a vector of prior standard deviations (not hyper priors).
For instance, in the radon example from Gelman and Hill, 2007, instead of fitting a heirarchical/partial pooling model, I instead wanted to fit a no pooling model, I’d do something like this
with pm.Model() as m1:
a = pm.Normal('a', mu=0, sd=1, shape=n_counties)
b = pm.Normal('b', mu=0, sd=1, shape=n_counties)
# Model error
eps = pm.HalfCauchy('eps', 5)
radon_est = a[county_idx] + b[county_idx] * data.floor.values
# Data likelihood
radon_like = pm.Normal('radon_like', mu=radon_est, sd=eps, observed=data.log_radon)
m1_trace = pm.sample(2000)
Instead now, I’d like for the parameters a
and b
to be drawn from a multivariate normal distribution, with a vector of means and vector of standard deviations along with the appropriate LKJ correlation matrix.
How can I incorporate that into the above model?
Thank you!