| diag.plot {NCStats} | R Documentation |
Used to constructs plots of diagnostic measures for linear models. Also used to identify “extreme” values of diagnostic measures for a linear model.
diag.plot(mdl)
mdl |
an lm object (i.e., returned from fitting a model with lm). |
This function produces a graphic that consists of at most six separate plots – Enumerate{
Each separate graph may have various individuals marked with their observation number. Observation numbers in red are the most extreme value that exceeds the cutoff value for the diagnostic measure plotted on that particular graph. Observation numbers in blue are observations that exceeded a cutoff value for at least one of the diagnostic measures NOT plotted on that particular graph. Thus, observations marked in red are “unusual” observations for the diagnostic measure shown on the plot whereas observations marked in blue are “unusual” observations for some other diagnostic measure but not for the diagnostic measure shown on the plot. The fitted line plot has all “unusual” observations marked with separate colors and the fitted line with that observation removed shown in the same color.
If more than one observation has the same extreme value for one of the diagnostics then only the first individual with the value is returned.
If the linear model object is other than a simple linear regression then only the first four plots are constructed.
Diagnostic statistic values are computed with the rstudent and influence.measaures functions.
In addition to the graphic described in the details, a vector containing the row numbers of observations that were flagged as unusual by one of the diagnostic statistics. This vector can be assigned to an object and used to modify plots or easily remove the individuals from the data frame.
Derek H. Ogle, dogle@northland.edu
fit.plot, residual.plot, highlight, influence.measures, and outlier.test and influence.plot in car.
data(Mirex) Mirex$year <- factor(Mirex$year) attach(Mirex) lm1 <- lm(mirex~weight*year*species) lm4 <- lm(mirex~weight) diag.plot(lm1) pts <- diag.plot(lm4) # saves flagged observations fit.plot(lm4,cex.main=0.8) # constructs a fitted line plot highlight(mirex~weight,pts=pts) # highlights flagged observations on plot detach(Mirex) ## Example showing outlier detection x <- c(runif(100)) y <- c(runif(100)) y[1] <- 7 lma <- lm(y~x) diag.plot(lma)