The Mahalanobis distance is
outlier(x, plot = TRUE, bad = 5,na.rm = TRUE, xlab, ylab, ...)
A data matrix or data.frame
Plot the resulting QQ graph
Label the bad worst values
Should missing data be deleted
Label for x axis
Label for y axis
More graphic parameters, e.g., cex=.8
The D2 values for each case
Adapted from the mahalanobis function and help page from stats.
Yuan, Ke-Hai and Zhong, Xiaoling, (2008) Outliers, Leverage Observations, and Influential Cases in Factor Analysis: Using Robust Procedures to Minimize Their Effect, Sociological Methodology, 38, 329-368.
# NOT RUN {
#first, just find and graph the outliers
d2 <- outlier(sat.act)
#combine with the data frame and plot it with the outliers highlighted in blue
sat.d2 <- data.frame(sat.act,d2)
pairs.panels(sat.d2,bg=c("yellow","blue")[(d2 > 25)+1],pch=21)
# }
Run the code above in your browser using DataLab