help for rvfplot2

Plot residuals versus fitted values after model fit

rvfplot2 [, residualtype qualifier rscale(exp) fscale(exp) lowess[(lowess_options)] scatter_options plot(plot) ]


rvfplot2 graphs a residual-versus-fitted plot, a graph of the residuals versus the fitted values. The residuals are, by default, those calculated by predict, residuals or (if the previous estimation command was glm) by predict, response. The fitted values are those produced by predict by default after each estimation command.

rvfplot2 is for use after regress and similar commands; see help on the command of interest. It is a generalisation of rvfplot in official Stata.


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.

qualifier specifies one of standardized, studentized, modified, adjusted.

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.

fscale(exp) specifies a transformed scale on which to show the fitted values using Stata syntax and X as a placeholder for the fitted variable name. Thus for example fscale(2 * ln(X)) specifies twice the natural logarithm, which is the constant information scale for a generalised linear model with gamma error. Similarly, arguments of 2 * 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_options are options of twoway scatter.

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


. 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))


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


Phil Ender provided very helpful comments on a previous version.


McCullagh, P. and Nelder, J.A. 1989. Generalized linear models. London: Chapman and Hall.

Also see