------------------------------------------------------------------------------- help forrdplot-------------------------------------------------------------------------------

Plot residual distribution after model fit

rdplot[plottype] [,residualtyperscale(exp)by(varname)[at(numlist)|group(#)]graph_optionsplot(plot)]

Description

rdplotis for use afterregressand similar commands; see help on the command of interest.

rdplotgraphs residual distributions. The residuals are, by default, those calculated bypredict, residualsor (if the previous estimation command wasglm) bypredict, response.The graph by default is a single or multiple dotplot, as produced by

dotplot.Histograms or box plots may be selected by specifying either

histogramorhboxorboxasplottype.Oneway plots as implemented by

onewayplot, skewness plots as implemented byskewplot, or quantile plots as implemented byqplotmay be selected by specifyingonewayplotorskewplotorqplotasplottype.In the latter three cases,

onewayplotorskewplotorqplotmust be installed first. In the last case,qplotplottypes may be specified in full (e.g. asqplot line); by defaultqplotor an abbreviation of it meansqplot connected.

plottypemay be abbreviated unambiguously, i.e. down as far asd,hi,hb,b,oorsorq.

Options

residualtypespecifies a type of residual other than the default. The following types are currently supported:anscombe,deviance,likelihood,pearson,residuals,response,rstandard,rstudent,score,working.

rscale(exp)specifies a transformed scale on which to show the residuals using Stata syntax andXas a placeholder for the residual variable name. Thusrscale(X^2)specifies squaring, to show relative contribution to residual variance;rscale(abs(X))specifies absolute value, to set aside sign;rscale(sqrt(abs(X)))specifies root of absolute value, a useful scale on which to check for heteroscedasticity.

by(varname)specifies that plots should be given for groups ofvarname. Ifat()orgroup()is also specified, as below, groups are as specified by that option. Otherwise, groups are the distinct values ofvarname.

at(numlist)orgroup(#)specifies how groups of a classifying variable are to be determined. Ifby(varname)is specified, as above,at()orgroup()is applied to that variable. Otherwise, the first-named predictor or covariate used in the previous regression-type command is used.at()andgroup()are options ofegen, cut(): see help on egen. In brief,at()specifies lower limits of user-defined classes andgroup()specifies the number of quantile-based groups with (approximately) equal frequency to be used. (Withat(), supply one high value beyond the maximum of the data for best results.)

graph_optionsare any of the options allowed with whichever of dotplot, histogram, graph hbox, graph box, onewayplot or skewplot is selected asplottype.

plot(plot)provides a way to add other plots to the generated graph; see plot_option.plot()is allowed wheneverplottypepermits (and so not withdotplot,boxorhbox).

Examples

. reg width length. rdplot, g(3). foreach v in width length {. gen log`v' = log(`v'). }. reg logwidth loglength. rdplot, g(3). rdplot b, g(3). rdplot hb, g(3). rdplot hi, g(3)

. glm price weight, link(log). rdplot hi, anscombe yli(0) normal

AuthorNicholas J. Cox, University of Durham, U.K. n.j.cox@durham.ac.uk

Also see