Residual analysis and regression diagnostics

There are many tools to closely inspect and diagnose results from regression and other estimation procedures, i.e. after you have performed a command like regress you can use, what Stata calls a command. Postestimation commands are found in two places: in the menu and .

Below you will find a few examples for the most common options; there are many more, including specific ones for different types of regression. For more details for the regress command check help regress postestimation, help logistic postestimation for logistic regression etc.

Residuals, predicted values and other result variables

The predict command lets you create a number of derived variables in a regression context, variables you can inspect and plot. [Click the paperclip to see the options: menu dialog]

Copies the residuals
predict pyCreates py with the predicted values
predict res1, residual
predict cd, cooksdCopies Cook's distance

Here's a list of derived variables you can copy.

<none> Predicted values (OLS), predicted probabilities for logistic regression, probit ....
xb linear prediction (same as no option for OLS),
residuals residuals
score score; equivalent to residuals
rstandard standardized residuals
rstudent Studentized (jackknifed) residuals
cooksd Cook's distance
leverage | hat leverage (diagonal elements of hat matrix)
ystar(a,b) E(y*), y* = max(a,min(y,b))
stdp standard error of the linear prediction
stdf standard error of the forecast
stdr standard error of the residual
welsch Welsch distance
covratio COVRATIO
dfits DFITS
dfbeta(varname) DFBETA for varname
Diagnostic plots and numerical diagnostic summaries

Here you see the diagnostic plots available from the menu.

Example: Produce a leverage plot, after a regression.

lvr2plot, mlabel(country)

Here's a list of the most common diagnostic commands (see the documentation for details)

dfbeta influence statistics
estat hettest test heteroskedasticity
estat vif variance inflation factors
acprplot
avplot added-variable plot
avplots all added-variable plots in one image
cprplot component-plus-residual plot
lvr2plot leverage-versus-squared-residual plot
rvfplot residual-versus-fitted plot
rvpplot residual-versus-predictor plot
Links

Detailed explanations can be found here UCLA Stata Webbook