使用关联矩阵作为R中的输入的PCA分析 [英] PCA analysis using Correlation Matrix as input in R

查看:139
本文介绍了使用关联矩阵作为R中的输入的PCA分析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我有一个7000 * 7000的相关矩阵,我必须在R中对此进行PCA. 我用

Now i have a 7000*7000 correlation matrix and I have to do PCA on this in R. I used the

CorPCA <- princomp(covmat=xCor)

,xCor是相关矩阵 但出来了

, xCor is the correlation matrix but it comes out

协方差矩阵不是非负定的"

"covariance matrix is not non-negative definite"

这是因为我在那个矩阵中有一些负相关. 我想知道我可以使用R中的哪个内置函数来获取PCA的结果

it is because i have some negative correlation in that matrix. I am wondering which inbuilt function in R that i can use to get the result of PCA

推荐答案

not non-negative definite并不意味着协方差矩阵具有负相关.这是一个线性代数,等效于尝试取负数的平方根!您无法通过查看矩阵的一些值来判断它是否为正定.

not non-negative definite does not mean the covariance matrix has negative correlations. It's a linear algebra equivalent of trying to take square root of negative number! You can't tell by looking at a few values of the matrix, whether it's positive definite.

尝试调整一些默认值,例如princomp调用中的公差.例如,检查以下线程:如何当协方差矩阵为零时在R中使用princomp()函数?

Try adjusting some default values like tolerance in princomp call. Check this thread for example: How to use princomp () function in R when covariance matrix has zero's?

一种替代方法是编写您自己的一些代码以执行所谓的n NIPLAS分析.在R-mailing列表上查看此线程: https ://stat.ethz.ch/pipermail/r-help/2006-July/110035.html

An alternative is to write some code of your own to perform what is called a n NIPLAS analysis. Take a look at this thread on the R-mailing list: https://stat.ethz.ch/pipermail/r-help/2006-July/110035.html

我什至会问您从哪里获得相关矩阵?您是自己建造的吗?有NA吗?如果您是根据自己的数据构建的xCor,您认为可以对数据进行采样并构建一个较小的xCor矩阵吗? (例如1000X1000).所有这些替代方案都尝试通过快乐路径"来驱动您的PCA算法(即,所有矩阵运算都可以在内部执行,而不会在对角线化等方面遇到困难,即,不再有非负定误差msgs")

I'd even go as far as asking where did you obtain the correlation matrix? Did you construct it yourself? Does it have NAs? If you constructed xCor from your own data, do you think you can sample the data and construct a smaller xCor matrix? (say 1000X1000). All these alternatives try to drive your PCA algorithm through the 'happy path' (i.e. all matrix operations can be internally carried out without difficulties in diagonalization etc..i.e., no more 'non-negative definite error msgs)

这篇关于使用关联矩阵作为R中的输入的PCA分析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆