------------------------------------------------------------------------------- help forrvfplot2-------------------------------------------------------------------------------

Plot residuals versus fitted values after model fit

rvfplot2[,residualtypequalifierrscale(exp)fscale(exp)lowess[(lowess_options)]scatter_optionsplot(plot)]

Description

rvfplot2graphs a residual-versus-fitted plot, a graph of the residuals versus the fitted values. The residuals are, by default, those calculated bypredict, residualsor (if the previous estimation command wasglm) bypredict, response. The fitted values are those produced bypredictby default after each estimation command.

rvfplot2is for use afterregressand similar commands; see help on the command of interest. It is a generalisation ofrvfplotin official Stata.

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.

qualifierspecifies one ofstandardized,studentized,modified,adjusted.

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.

fscale(exp)specifies a transformed scale on which to show the fitted values using Stata syntax andXas a placeholder for the fitted variable name. Thus for examplefscale(2 * ln(X))specifies twice the natural logarithm, which is the constant information scale for a generalised linear model with gamma error. Similarly, arguments of2* sqrt(X),2 * asin(sqrt(X)), and-2 / sqrt(X)specify the constant information scale for Poisson, binomial and inverse Gaussian errors respectively. See McCullagh and Nelder (1989, p.398) for background.

lowess[(lowess_options)] specifies that the residuals will be smoothed as a function of the fitted using twoway lowess (options may be specified).

scatter_optionsare options of twoway scatter.

plot(plot)provides a way to add other plots to the generated graph; see plot_option.

Examples

. gen forxmpg = foreign * mpg. regress price weight mpg forxmpg foreign. rvfplot2

. anova price rep foreign rep*foreign weight, cont(weight). rvfplot2, rscale(sqrt(abs(X)))

. glm price weight, link(log). rvfplot2, anscombe yli(0)

. glm price weight, link(log). rvfplot2, anscombe yli(0) lowess. rvfplot2, anscombe yli(0) lowess(bw(0.9))

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

AcknowledgementsPhil Ender provided very helpful comments on a previous version.

ReferencesMcCullagh, P. and Nelder, J.A. 1989.

Generalized linear models.London: Chapman and Hall.

Also see