regstats - Regression diagnostics

Syntax

regstats(y,X,model)
stats = regstats(...)
stats = regstats(y,X,model,whichstats)

Description

regstats(y,X,model) performs a multilinear regression of the responses in y on the predictors in X. X is an n-by-p matrix of p predictors at each of n observations. y is an n-by-1 vector of observed responses.

The optional input model controls the regression model. By default, regstats uses a linear additive model with a constant term. model can be any one of the following strings:

To specify a polynomial model of arbitrary order, or a model without a constant term, use a matrix for model as described in x2fx.

With this syntax, the function displays a graphical user interface (GUI) with a list of diagnostic statistics, as shown in the following figure.

When you select check boxes corresponding to the statistics you want to compute and click OK, regstats returns the selected statistics to the MATLAB® workspace. The names of the workspace variables are displayed on the right-hand side of the interface. You can change the name of the workspace variable to any valid MATLAB variable name.

stats = regstats(...) creates the structure stats, whose fields contain all of the diagnostic statistics for the regression. This syntax does not open the GUI. The fields of stats are:

QQ from the QR decomposition of the design matrix
RR from the QR decomposition of the design matrix
betaRegression coefficients
covbCovariance of regression coefficients
yhatFitted values of the response data
rResiduals
mseMean squared error
rsquareR2 statistic
adjrsquareAdjusted R2 statistic
leverageLeverage
hatmatHat matrix
s2_iDelete-1 variance
beta_iDelete-1 coefficients
standresStandardized residuals
studresStudentized residuals
dfbetasScaled change in regression coefficients
dffitChange in fitted values
dffitsScaled change in fitted values
covratioChange in covariance
cookdCook's distance
tstatt statistics for coefficients
fstatF statistic

Note that the fields names of stats correspond to the names of the variables returned to the MATLAB workspace when you use the GUI. For example, stats.beta corresponds to the variable beta that is returned when you select Coefficients in the GUI and click OK.

stats = regstats(y,X,model,whichstats) returns only the statistics that you specify in whichstats. whichstats can be a single string such as 'leverage' or a cell array of strings such as {'leverage' 'standres' 'studres'}. Set whichstats to 'all' to return all of the statistics.

Example

Open the regstats GUI using data from hald.mat:

load hald
regstats(heat,ingredients,'linear');

Select Fitted Values and Residuals in the GUI:

Click OK to export the fitted values and residuals to the MATLAB workspace in variables named yhat and r, respectively.

You can create the same variables using the stats output, without opening the GUI:

whichstats = {'yhat','r'};
stats = regstats(heat,ingredients,'linear',whichstats);
yhat = stats.yhat;
r = stats.r;

Reference

[1] Belsley, D. A., E. Kuh, R. E. Welsch, Regression Diagnostics, Wiley, 1980.

[2] Chatterjee, S., A. S. Hadi, "Influential Observations, High Leverage Points, and Outliers in Linear Regression," Statistical Science, 1986, pp. 379-416.

[3] Cook, R. D., S. Weisberg, Residuals and Influence in Regression, Wiley, 1982.

[4] Goodall, C. R., "Computation using the QR decomposition," Handbook in Statistics, Volume 9, Elsevier/North-Holland, 1993.

See Also

x2fx, regress, stepwise, leverage

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS