data(Animals2)
## Sensible Plot needs doubly logarithmic scale
plot(Animals2, log = "xy")
## Regression example plot:
plotbb <- function(bbdat) {
d.name <- deparse(substitute(bbdat))
plot(log(brain) ~ log(body), data = bbdat, main = d.name)
abline( lm(log(brain) ~ log(body), data = bbdat))
abline(MASS::rlm(log(brain) ~ log(body), data = bbdat), col = 2)
legend("bottomright", leg = c("lm", "rlm"), col=1:2, lwd=1, inset = 1/20)
}
plotbb(bbdat = Animals2)
## The `same' plot for Rousseeuw's subset:
data(Animals, package = "MASS")
brain <- Animals[c(1:24, 26:25, 27:28),]
plotbb(bbdat = brain)
lbrain <- log(brain)
plot(mahalanobis(lbrain, colMeans(lbrain), var(lbrain)),
main = "Classical Mahalanobis Distances")
mcd <- covMcd(lbrain)
plot(mahalanobis(lbrain,mcd$center,mcd$cov),
main = "Robust (MCD) Mahalanobis Distances")
Run the code above in your browser using DataLab