Bookmark and Share

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

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

Re: st: Residual Plot help

From   Maarten buis <>
Subject   Re: st: Residual Plot help
Date   Tue, 28 Sep 2010 09:02:53 +0000 (GMT)

--- On Tue, 28/9/10, Hobst wrote:
> I run this regression
> xtmixed y x1 x2 x3 || brand: || _all: R.model || datevar:, mle
> then predict the residuals
> predict bd md qt, reffects
> then i somehow plotted this graph:
> but now i dont know anymore how i got this graph... very
> stupid, i unfortuately deleted the do-file.

One thing I would change about that graph is the sort order of your
brands: The aim of such a graph as a diagnostic tool is to spot 
patterns in the residual and your are much more likely to see such
patterns if you sort on the residual rather than on alphabetical 
order. You can do that using the egen function -axis()-. You can 
get that by typing in Stata: -ssc install egenmore-. After that you 
can create your graph, as in this example:

*-------------------- begin example -------------------------
webuse productivity, clear
// there are no value labels attached to this dataset,
// so I am only guessing...
label define region 1 "New England"        /// 
                    2 "Mid-Atlantic"       /// 
                    3 "East North Central" /// 
                    4 "West North Central" /// 
                    5 "South Atlantic"     ///
                    6 "East South Central" /// 
                    7 "West South Central" /// 
                    8 "Mountain"           /// 
                    9 "Pacific" 
label value region region

xtmixed gsp private emp hwy water other unemp /// 
            || region: || state:, mle
predict u*, reffects

bys region (u1) : gen byte mark = _n==1
egen axis = axis(u1), label(region)

twoway bar u1 axis if mark, horizontal ylab(1/9, valuel)
*--------------------- end example -----------------------

Hope this helps,

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


*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index