Analysis of residuals from regression

R offers many types of regression, the analysis of residuals and other derived variables is identical for all functions.

Several aspects are described in detail in the document on the resistant line. Make sure to read it first to understand that any regression produces an object containing the regression results that can be used by other commands for further analysis.

Regression functions return regression objects, from which many functions retrieve information. The model1 object created by model1=line(urb,infmor) or for example by model1=lm(infmor ~ urb + gnpserv+urb*gnpserv, data=world) can be used to diagnose the residuals:

Assume you have stored the results from a resistant line into model1

model1 = line(urb,infmor)
plot(model1$residuals) Residual (sequence plot)
plot(residuals(model1)) The same but using residuals() [resid() is a synonym]
plot(resid(model1),fitted(model1)) Plot residuals against fitted values
boxplot(resid(model1) A boxplot of residuals
stem(fitted.values(model1)) Stemplot of the fitted values

Some more advanced regression procedures return an object of class lm; the plot() function then automatically produces a series of residual plots. See Regression for details.

Liens