Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# st: xtmelogit, empirical bayes residual, 3-step hierarchical model

 From Wouter Steenbeek <[email protected]> To "[email protected]" <[email protected]> Subject st: xtmelogit, empirical bayes residual, 3-step hierarchical model Date Fri, 23 Nov 2012 00:40:20 +0100

```I am trying to estimate the Empirical Bayes residual means for a logit model. I am trying to separate context from composition as much possible by following an approach outlined by Bingenheimer & Raudenbush (2004) Statistical and Substantive Inferences in Public Health: Issues in the Application of Multilevel Models. Annual Review Public Health 25:53-77. I'm referring to page 62.

Basically this follows three steps, which are written for a linear model:

1.  Fit a model holding slopes ﬁxed and group-mean centering individual-level covariates: Yij = B0j + B1j(Xij - Xj) + error. B0j is the random intercept, or gamma (=overall intercept) + u0j (residual). This generates, for each of the level-1 covariates, and estimate of the within-group partial association between the covariate and the outcome.

2. Create a new adjusted outcome, Y*: Y*=Yij - gamma - B1j*Xij.

3. Finally, estimate Y* = B0j + error. Then use the new residuals captured from this last model.

I am using the following Stata code for this:

(1) xtmixed Y X_withingroupdeviation || group:

(2) gen Ystar = Y - _b[_cons] - _b[X_withingroupdeviation]*X

(3) xtmixed Ystar || group:
predict u0, reffects
predict u0se, rese

Questions:

1. Does this approach make sense? I don't quite see why I would create Y* based on -B1j * Xij instead of on -B1j * (Xij - Xj)

2. Does my Stata code correctly model this approach?

3. Ideally I want to do this for a dichotomous dependent variable as well. Then I need to adjust to:
(1) xtmelogit Y X_withingroupdeviation || group:
(2) But then step 2 would result in a dichotomous Y minus logits, so Ystar would no longer be dichotomous. So by necessity step 3 then becomes xtmixed again instead of an xtmelogit. Does this make sense? Or should I do some kind of transformation here?

Thanks,
Wouter

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/
```