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). I know a way , using gllapred after gllamm and then plot the histogram, but is there something similar to gllapred to use after xtmixed?
Thank you in advance for yur support |
--- 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/ |
Thank you very much Maarten, thats exactly what i was looking for!
Could you maybe, if you have time, have a very quick look at another of my questions: "-xtmixed- Crossed effets & hierarchy" I dont know anybody else to ask, and i cant find any more theory about my problem. This would be really nice. This is the link: http://statalist.1588530.n2.nabble.com/xtmixed-Crossed-effets-hierarchy-td5491619.html#a5491619 regards, Toby Tobias Friedli Bachelor Student at the University of Zurich On 03.09.2010, at 13:22, Maarten buis wrote: > --- 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/ * * 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/ |
This post has NOT been accepted by the mailing list yet.
In reply to this post by Maarten buis
Hi Maarten,
I found this link while I was looking for STATA code to predict the level-1 and level-2 residuals after xtmixed. I figured out that in xtmixed, the two examples that you gave (predict re, re / predict re*, reff ) do not provide the level-1 and level-2 residauls. See below: -- re is the residual option in xtmixed and it provides you w/ an overall residual of the model, it includes both the fixed and the random piece, so far I have not found the corresponding prediction in gllapred -- reff is the reffects option in xtmixed and it provides you w/ the BLUPs. In gllapred you obtain the same thing if you use the option "u" -- you can get level-1 residuals in xtmixed if you type "rstandard" and you can get the same level-1 residuals in gllapred if you type "pearson" -- however, in xtmixed I have not found way to get just the level 2 residuals BUT in gllapred you can type "ustd" and you will get them Best, Flori |
Powered by Nabble | Edit this page |