H.F.S C.
H.F.S C.

Reputation: 109

Correlation and Distance biplot using autoplot?

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)

enter image description here

# correlation biplot (scaling =2)
biplot(prcomp(USArrests, scale = TRUE), pc.biplot=TRUE)

enter image description here

# using autoplot there are several options: 
library(ggfortify)
ggplot2::autoplot(stats::prcomp(USArrests, scale=TRUE), pc.biplot=TRUE, label = TRUE, loadings.label = TRUE)

enter image description here

# I assume this is equal to the correlation biplot
ggplot2::autoplot(stats::prcomp(USArrests, scale=TRUE), scale=0, label = TRUE, loadings.label = TRUE)

enter image description here

ggplot2::autoplot(stats::prcomp(USArrests, scale=TRUE), scale=1, label = TRUE, loadings.label = TRUE)

enter image description here

ggplot2::autoplot(stats::prcomp(USArrests, scale=TRUE), scale=2, label = TRUE, loadings.label = TRUE)

enter image description here

Can I simply plot a distance (scaling = 1) using autoplot?

Upvotes: 2

Views: 534

Answers (1)

Julius Vainora
Julius Vainora

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

Related Questions