我试图重现列(“变量”中FactoMineR::PCA,“种”在vegan::rda)从贡献率,以轴线FactoMineR包vegan。贡献编码为FactoMiner::PCA对象:
library(FactoMineR)
library(vegan)
data(dune)
fm <- FactoMineR::PCA(dune, scale.unit = FALSE, graph = FALSE)
head(round(sort(fm$var$contrib[,1], decreasing = TRUE), 3))
# Lolipere Agrostol Eleopalu Planlanc Poaprat Poatriv
# 17.990 16.020 13.866 7.088 6.861 4.850
Run Code Online (Sandbox Code Playgroud)
通过查看的代码FactoMiner::PCA,我发现贡献的计算方式是:轴坐标平方除以轴特征值再乘以100%:
head(round(sort(100*fm$var$coord[,1]^2/fm$eig[1], decreasing = TRUE), 3))
# Lolipere Agrostol Eleopalu Planlanc Poaprat Poatriv
# 17.990 16.020 13.866 7.088 6.861 4.850
Run Code Online (Sandbox Code Playgroud)
我无法使用vegan::rda对象复制上述计算:
vg <- rda(dune)
head(round(sort(100*scores(vg, choices = 1, display = "sp",
scaling = 0)[,1]^2/vg$CA$eig[1], decreasing = TRUE), 3))
# Lolipere Agrostol Eleopalu Planlanc Poaprat Poatriv
# 0.726 0.646 0.559 0.286 0.277 0.196
Run Code Online (Sandbox Code Playgroud)
我显然做错了,差异可能是由于这两个程序包计算列的坐标的方式不同,因为轴的特征值非常相似(与我的实际数据集相同),但是坐标却不同:
# vegan eigenvalue for axis 1
vg$CA$eig[1]
# PC1
# 24.79532
# FactoMineR eigenvalue for axis 1
fm$eig[1]
# [1] 23.55555
# vegan column coordinates for axis 1
head(round(scores(vg, choices = 1, display = "sp", scaling = 0)[,1], 3))
# Achimill Agrostol Airaprae Alopgeni Anthodor Bellpere
# -0.176 0.400 0.007 0.155 -0.163 -0.097
#FactoMineR, column coordinates for axis 1
head(round(fm$var$coord[,1], 3))
# Achimill Agrostol Airaprae Alopgeni Anthodor Bellpere
# 0.854 -1.943 -0.033 -0.751 0.791 0.472
# Sum of column coordinates for vegan axis 1 to illustrate the difference
sum(scores(vg, choices = 1, display = "sp", scaling = 0)[,1])
# [1] -0.796912
# Sum of column coordinates for FactoMineR axis 1 to illustrate the difference
sum(fm$var$coord[,1])
# [1] 3.867738
Run Code Online (Sandbox Code Playgroud)
如何使用vegan rda
对象计算列/物种对协调轴的百分比贡献?
素食主义者中未缩放的分数在(平方)平方和为1的情况下是未缩放的,与特征值无关:
> colSums(scores(vg, choices=1:4,dis="sp", scaling=0)^2)
PC1 PC2 PC3 PC4
1 1 1 1
Run Code Online (Sandbox Code Playgroud)
我认为这是有据可查的。如果您想将这些平方项称为贡献,我可以。同样适用于cca,但是您需要研究加权平方和。此外,网站()的未缩放分数dis = "si"将具有相同的单位平方和:即未缩放的想法。如果缩放物种或地点,则相同的关系不再适用于另一组分数。通常,未缩放表示分数是正交的,因此它们的叉积是恒等矩阵(对角或平方和1与非对角元素0)。对于按比例计分的分数,这些平方和与特征值成正比(但是,阅读纯素食主义者可能会有用设计决定的小插图const,以分数的比例缩放)。
纯素功能goodness,inertcomp可能会(也可能不会)为您提供所需的信息。