PCA Biplot - 箭头长度

时间:2017-06-05 15:51:09

标签: r pca

我使用PCA使用工具S-Plus从我的数据集here生成Biplot

运行我的数据的脚本是:

[master]

双标图结果是 here.

据我所知,我将双标图解释如下:

  1. 左和右底轴:PC1&的分数PC2

  2. 对&顶轴:PC1&的载荷值PC2

  3. 观察结果为黑色,并根据个人电脑的得分绘制

  4. 箭头向量表示哪些变量占大多数PC。

  5. 箭头名称的位置基于PC1和PC2的加载值的组合

  6. 箭头长度 - ???

  7. 但是,我不知道箭头的长度是多少。 我读了一些参考文献,箭头的长度是方差的比例。真的吗?我们如何根据双时图来计算它?

    你能帮助我吗?感谢

1 个答案:

答案 0 :(得分:0)

我查看了from skimage import io from skimage.filters.rank import entropy from skimage.morphology import disk img = io.imread('https://i.stack.imgur.com/Wv74a.png') R = 25 filtered = entropy(img, disk(R)) io.imshow(filtered) stats:::biplot.princomp
箭头的长度计算如下。

(1)指定了stats:::biplot.default的{​​{1}}选项。

scale = F

enter image description here

(2)指定了biplot的{​​{1}}选项。

# Data generating process
set.seed(12345)
library(MASS)
n <- 100
mu <- c(1,-2,-0.5)
Sigma <- diag(rep(1,3))
X <- mvrnorm(n, mu=mu, Sigma=Sigma)

pca <- princomp(X, cor=T, scores=T)
biplot(pca, choices = 1:2, scale = F)

# Calculates arrow lengths
lam <- 1
len <- t(t(pca$loadings[, 1:2]) * lam)*0.8

# Plot arrows in green and see if overlap the red ones
mapply(function(x,y) arrows(0, 0, x, y, col = "green", 
            length = .1), x=len[,1], y=len[,2])

enter image description here