使用autoplot的相关和距离双标图?

时间:2018-05-16 16:31:34

标签: r ggplot2 pca ggfortify biplot

通过R(USArrests)提供的示例,我想问一下是否有人能告诉我自动映射中的缩放是什么?我熟悉Borcard等人所描述的距离和相关双标图。 (2011年)。自动绘图功能使双标图更好,但我无法找到你如何使用该函数简单地在距离和相关类型双标图之间去做。

# 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

我可以使用autoplot简单地绘制距离(比例= 1)吗?

1 个答案:

答案 0 :(得分:1)

是,

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

biplot(prcomp(USArrests, scale = TRUE), scale = s)

给出0< = s< = 1的类似结果。请参阅stats:::biplot.prcompggfortify:::autoplot.prcomp以说服自己。特别是,这两个函数都有(以下来自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), ...)

解释了scale的作用。另请参阅?ggbiplot?autoplot.prcomp

相关问题