【发布时间】:2016-04-16 00:54:39
【问题描述】:
我尝试使用 princomp() 和 principal() 在 R 中使用数据集 USArressts 进行 PCA。但是,对于加载/旋转和分数,我得到了两个不同的结果。
首先,我将原始数据框居中并归一化,以便比较输出结果。
library(psych)
trans_func <- function(x){
x <- (x-mean(x))/sd(x)
return(x)
}
A <- USArrests
USArrests <- apply(USArrests, 2, trans_func)
princompPCA <- princomp(USArrests, cor = TRUE)
principalPCA <- principal(USArrests, nfactors=4 , scores=TRUE, rotate = "none",scale=TRUE)
然后我使用以下命令获得了加载和分数的结果:
princompPCA$loadings
principalPCA$loadings
您能帮我解释一下为什么会有差异吗?我们如何解释这些结果?
【问题讨论】:
-
在 ?principle 文档中,“与 princomp 不同,它只返回最佳 nfactors 的子集。”
-
进一步说,“回归权重是从相关矩阵乘以组件负载的倒数得出的。结果是组件得分是标准得分(均值 = 0,sd = 1)标准化的输入。与 princomp 的分数的比较显示了这种差异。默认情况下,princomp 不会标准化数据矩阵,组件本身也不会标准化。"