Reputation: 109
With an example provided by R (USArrests), I would like to ask if anyone can tell me what the scaling in the autoplot induces? I am familiar with a distance and correlation biplot as described in Borcard et al. (2011). The autoplot function makes the biplot nicer but I cannot find how you simply destinguish between distance and correlation type biplot using the function.
# Distance biplot (scaling = 1)
biplot(prcomp(USArrests, scale = TRUE), scale=0)
# correlation biplot (scaling =2)
biplot(prcomp(USArrests, scale = TRUE), pc.biplot=TRUE)
# using autoplot there are several options:
library(ggfortify)
ggplot2::autoplot(stats::prcomp(USArrests, scale=TRUE), pc.biplot=TRUE, label = TRUE, loadings.label = TRUE)
# I assume this is equal to the correlation biplot
ggplot2::autoplot(stats::prcomp(USArrests, scale=TRUE), scale=0, label = TRUE, loadings.label = TRUE)
ggplot2::autoplot(stats::prcomp(USArrests, scale=TRUE), scale=1, label = TRUE, loadings.label = TRUE)
ggplot2::autoplot(stats::prcomp(USArrests, scale=TRUE), scale=2, label = TRUE, loadings.label = TRUE)
Can I simply plot a distance (scaling = 1) using autoplot?
Upvotes: 2
Views: 534
Reputation: 48201
Yes,
ggplot2::autoplot(stats::prcomp(USArrests, scale = TRUE), scale = 0, label = TRUE, loadings.label = TRUE)
and
biplot(prcomp(USArrests, scale = TRUE), scale = s)
give analogous results for 0 <= s <= 1. See stats:::biplot.prcomp
and ggfortify:::autoplot.prcomp
to convince yourself. In particular, both functions have (the following is from stats:::biplot.prcomp
)
lam <- x$sdev[choices]
n <- NROW(scores)
lam <- lam * sqrt(n)
lam <- lam^scale
biplot.default(t(t(scores[, choices])/lam), t(t(x$rotation[,
choices]) * lam), ...)
which explains the role of scale
. Also see ?ggbiplot
and ?autoplot.prcomp
.
Upvotes: 2