首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用autoplot的相关性和距离双线图?

使用autoplot的相关性和距离双线图?
EN

Stack Overflow用户
提问于 2018-05-17 00:31:34
回答 1查看 284关注 0票数 2

用R (USArrests)提供的一个例子,我想问一下,有没有人能告诉我自动绘图中的缩放导致了什么?我熟悉Borcard等人所描述的距离和相关性双线图。(2011)。autoplot函数使biplot变得更好,但我找不到如何使用该函数简单地区分距离和相关类型的biplot。

代码语言:javascript
复制
# Distance biplot (scaling = 1)
biplot(prcomp(USArrests, scale = TRUE), scale=0)

代码语言:javascript
复制
# correlation biplot (scaling =2)
biplot(prcomp(USArrests, scale = TRUE), pc.biplot=TRUE)

代码语言:javascript
复制
# using autoplot there are several options: 
library(ggfortify)
ggplot2::autoplot(stats::prcomp(USArrests, scale=TRUE), pc.biplot=TRUE, label = TRUE, loadings.label = TRUE)

代码语言:javascript
复制
# I assume this is equal to the correlation biplot
ggplot2::autoplot(stats::prcomp(USArrests, scale=TRUE), scale=0, label = TRUE, loadings.label = TRUE)

代码语言:javascript
复制
ggplot2::autoplot(stats::prcomp(USArrests, scale=TRUE), scale=1, label = TRUE, loadings.label = TRUE)

代码语言:javascript
复制
ggplot2::autoplot(stats::prcomp(USArrests, scale=TRUE), scale=2, label = TRUE, loadings.label = TRUE)

我可以使用autoplot简单地绘制一个距离(缩放= 1)吗?

EN

回答 1

Stack Overflow用户

发布于 2018-05-17 01:51:40

是,

代码语言:javascript
复制
ggplot2::autoplot(stats::prcomp(USArrests, scale = TRUE), scale = 0, label = TRUE, loadings.label = TRUE)

代码语言:javascript
复制
biplot(prcomp(USArrests, scale = TRUE), scale = s)

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

代码语言:javascript
复制
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

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50375904

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档