Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: -predict , reffects- after -xtmelogit-
From
Jeph Herrin <[email protected]>
To
[email protected]
Subject
Re: st: -predict , reffects- after -xtmelogit-
Date
Wed, 22 Dec 2010 08:36:22 -0500
Thanks much for the thorough explanation. Very helpful.
cheers!
Jeph
On 12/21/2010 3:49 PM, Roberto G. Gutierrez, StataCorp wrote:
Jeph Herrin<[email protected]> asks about obtaining MLE estimates of random
effects after estimation with -xtmelogit-:
Thanks, the typo was that I had -yrwe- and -ywre- and mixed them up. But
this still doesn't tell me how to get the mle random effects, if that is
possible.
The posterior modes obtained from
. predict r, reffects
after -xtmelogit- are actually MLE's in and of themselves, because a mode is
the point where the distribution peaks and thus represents the maximum of the
posterior distribution of the random effects. These posterior MLE's condition
on three things:
1. The regression coefficients are as estimated
2. The random effects are normally distributed
3. The standard deviation of the random effects is as estimated
My guess is that Jeph would like estimates that only condition on 1. and not
on 2. and 3., as is discussed in Section 2.9.1 of Rabe-Hesketh and Skrondal
(2008). That discussion uses -xtmixed- and linear models, and thus the MLEs
can be obtained post-estimation by linear regression of the partial residuals
on dummy variables identifying the clusters.
Such an approach is not generalizable to -xtmelogit- because of the
non-linearity of the model. However, you can achieve the same effect by using
-logit- with a linear offset calculated from the regression coefficients as
obtained from -xtmelogit-. To illustrate,
. webuse bangladesh, clear
. xtmelogit c_use age || district: // age introduced to make
// things interesting
. predict r_mode, reffects // Posterior modes
. predict xbeta, xb // Obtain linear predictor
. forvalues i = 1/61 { // Generate dummy variables
. gen dd`i' = district == `i'
. }
Note above that -district- has 60 unique values, but is coded as 1 through
61 with 54 missing. We next obtain the MLEs of the random effects using
-logit- with dummy variables and an offset
. logit c_use dd*, nocons offset(xbeta) // MLEs of random effects
Some dummies are omitted because of perfect prediction, but such is life with
binary data sometimes.
The key here is that by including -xbeta- as an offset we are conditioning on
the regression coefficients as estimated by -xtmelogit-. Not conditioning on
these would be akin to unrestricted logistic regression with covariates and
dummy variables for clusters, in other words, fixed-effects logistic
regression.
The only remaining task is to take these logit coefficients and place them in
the data according to the values of -district-. One way is
. gen r_mle = .
. forvalues i = 1/61 {
. replace r_mle = _b[dd`i'] if district == `i'
. }
. replace r_mle = . if r_mle == 0
The last line is necessary because cases coefficients on dropped variables are
stored as 0 in e(b) rather than missing.
We can now compare with the standard random-effects predictions
. bysort district: gen tolist = _n==1
. list district r_mode r_mle if tolist
Finally, if you compare the standard deviation of the MLEs of the random
effects to that obtained as sd(_cons) from -xtmelogit-
. xtmelogit c_use age || district:
. sum r_mle if tolist
you will still not get matching numbers. The main reason for this is that by
estimating random-effects directly, you are no longer imposing that they are
normally distributed but instead allowing them to "be everything they can be".
I'm not sure how you would estimate individual random effects while at the
same time imposing normality.
--Bobby
[email protected]
Reference:
Rabe-Hesketh, S. and A. Skrondal. 2008. Multilevel and Longitudinal Modeling
Using Stata. College Station, TX: Stata Press.
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/