Next: resvsindex() Up: Regression Macros Help File Previous: removevar()   Contents


resid() or resid(Model)

Keywords: glm, residuals, anova, regression
resid(), with no argument, computes a REAL matrix of various quantities
useful in the analysis of residuals.  It uses side effect variables
RESIDUALS, HII, etc. produced by the most recent GLM (generalized linear
or linear model) command such as regress(), anova(), or poisson().

It is an error if any of the needed side effect variables do not exist.

resid(Model) first executes manova(Model, silent:T) to compute the
required side effect variables before computing the residual-related
quantities.  Model should be a CHARACTER variable or string specifying a
linear ANOVA or MANOVA model.  Any factors in the model will be treated
as factors.  If you want them treated as variates, use resid(Model,T).

Each row of the result corresponds to a case.  When the dependent
variable Y is univariate, there are 5 columns, as follows:
   Col. 1   Y = observed response
   Col. 2   Studentized residuals = RESIDUALS/SE(RESIDUALS)
   Col. 3   HII = leverage
   Col. 4   Cook's distance
   Col. 5   t-statistics = externally studentized residuals =
            RESIDUALS/SE*(RESIDUALS), where SE* for each case is
            a standard error based on the model fit excluding that case.

When Y is multivariate of dimension p, there are 4*p + 1 columns -- the
p values for Y, the p standardized residuals, HII, the p Cook's
distances, and the p externally studentized residuals.

If a case has missing values, most entries for that case will be MISSING
and there are no useful numbers.

After non-linear GLM commands such as poisson() and logistic(), the
results are based on the last stage of the iteratively reweighted least
squares algorithm used to fit the model.  Residuals are standardized by
the error mean square in the linear scale.  They should still be valid
for diagnosing departures from the model.

The output of resid() is modeled on what is printed by the resid()
command in program Multreg.

resid() is implemented as a pre-defined macro.

See also topics 'glm', yhat(), resvsindex(), resvsrankits(),

Gary Oehlert 2003-01-15