-------------------------------------------------------------------------------
help for rdplot
-------------------------------------------------------------------------------

Plot residual distribution after model fit

rdplot [plottype] [, residualtype rscale(exp) by(varname) [at(numlist) | group(#)] graph_options plot(plot) ]

Description

rdplot is for use after regress and similar commands; see help on the command of interest.

rdplot graphs residual distributions. The residuals are, by default, those calculated by predict, residuals or (if the previous estimation command was glm) by predict, 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 histogram or hbox or box as plottype.

Oneway plots as implemented by onewayplot, skewness plots as implemented by skewplot, or quantile plots as implemented by qplot may be selected by specifying onewayplot or skewplot or qplot as plottype.

In the latter three cases, onewayplot or skewplot or qplot must be installed first. In the last case, qplot plottypes may be specified in full (e.g. as qplot line); by default qplot or an abbreviation of it means qplot connected.

plottype may be abbreviated unambiguously, i.e. down as far as d, hi, hb, b, o or s or q.

Options

residualtype specifies 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 and X as a placeholder for the residual variable name. Thus rscale(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 of varname. If at() or group() is also specified, as below, groups are as specified by that option. Otherwise, groups are the distinct values of varname.

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

graph_options are any of the options allowed with whichever of dotplot, histogram, graph hbox, graph box, onewayplot or skewplot is selected as plottype.

plot(plot) provides a way to add other plots to the generated graph; see plot_option. plot() is allowed whenever plottype permits (and so not with dotplot, box or hbox).

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

Author

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

Also see