[R特征值/特征向量
问题描述:
我有这样的相关性矩阵[R特征值/特征向量
A
[,1] 1.00000 0.00975 0.97245 0.43887 0.02241
[,2] 0.00975 1.00000 0.15428 0.69141 0.86307
[,3] 0.97245 0.15428 1.00000 0.51472 0.12193
[,4] 0.43887 0.69141 0.51472 1.00000 0.77765
[,5] 0.02241 0.86307 0.12193 0.77765 1.00000
,我需要得到的特征值,特征向量和负载量R.
当我使用princomp(A,cor=TRUE)
功能我得到的方差(特征值) 但是当我使用eigen(A)
函数时,我得到了特征值和特征向量,但在这种情况下的特征值与当我使用Princomp函数时不同。
哪个函数是正确的一个获得特征值?
答
eigen(M)
给你M.
princomp()
的正确特征值和载体将被切换数据矩阵 - 你错误地喂养它的相关性矩阵! princomp(A,)将A视为数据,然后提出相关矩阵及其特征向量和值。因此,A的特征值(假设A保持数据的假设)不仅不相关,而且它们与princomp()在最后提出的当然不同。
用于执行R A PCA在这里看到的说明:http://www.joyofdata.de/blog/illustration-of-principal-component-analysis-pca/
答
我相信你指的是一个PCA分析时,你说话的特征值,特征向量和负荷。 prcomp
基本上从事以下(当cor=TRUE
):
###Step1
#correlation matrix
Acs <- scale(A, center=TRUE, scale=TRUE)
COR <- (t(Acs) %*% Acs)/(nrow(Acs)-1)
COR ; cor(Acs) # equal
###STEP 2
# Decompose matrix using eigen() to derive PC loadings
E <- eigen(COR)
E$vectors # loadings
E$values # eigen values
###Step 3
# Project data on loadings to derive new coordinates (principal components)
B <- Acs %*% E$vectors
谢谢!我现在如何获得装载? (对不起,我不习惯在R工作) – user3013464
p Raffael