Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: xtmixed - standardized resuduals plot


From   Maarten buis <maartenbuis@yahoo.co.uk>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: xtmixed - standardized resuduals plot
Date   Fri, 3 Sep 2010 11:22:20 +0000 (GMT)

--- On Fri, 3/9/10, Hobst wrote:
> I have used xtreg to fit a 3-level hierarchical model. To
> test if the residuals on the different levels are in fact
> nomally distributed i would like to plot histograms of
> the standardized residuals for level-1 r(ijk), level-2
> r(jk) and level-3 r(k).

You can get the residuals using -predict-, see the example
below or -help xtmixed postestimation-. I used -hangroot-
as a more convenient way of comparing the histogram with
the theoretical normal distribution. To install it, type in 
Stata -ssc install hangroot-.

*------------ begin example ---------------------
webuse productivity, clear
xtmixed gsp private emp hwy water other unemp ///
        || region: || state:, mle

predict re, re
predict re*, reff

// these variables are used to make sure that each
// higher level unit (region or state) contributes
// only one observation when potting their level
// residuals
bys region (re1): gen byte regionmark = _n == 1
bys state (re2) : gen byte statemark  = _n == 1

hangroot re, ci 
hangroot re1 if regionmark, ci
hangroot re2 if statemark, ci
*---------------- end example --------------------
(For more on examples I sent to the Statalist see: 
http://www.maartenbuis.nl/example_faq )

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany

http://www.maartenbuis.nl
--------------------------


      

*
*   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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index