Subgroup analysis as multilevel model

Hi all,

I am looking to adapt the subgroup analysis from p.292 of the Gelman and Hill ARM text and just want to be sure I have specified the model correctly. In the example:

y = log earnings
z = mean-centered height
J = 4 ethnic groups
K = 3 age categories

model is:
yi ~ N(a[j,k] + B[j,k]z, sigma2)

I am between two specifications of this, neither of which I’m entirely confident is right:

stan_lm(y ~ -1 + z + (1 + z | J:K))

Which I interpret as no fixed intercept, and a varying slope + intercept for every age category in every ethnic group. The reason I think this might not be right is because I think it implies that K is nested in J. The only other formulation I’ve come up with is:

stan_lm(y ~ -1 + z + (1 + z | J) + (1 + z|K))

Which seems more in line with what I know about specifying crossed effects in lmer, but then I’m not sure how I get at the interaction of coefficients for age groups by ethnicity.


Table 2 of

describes the lme4 syntax, which rstanarm builds on. In this case,

stan_lmer(y ~ -1 + z + (1 + z | J/K))

implies nesting.