chol.default(Cxx) 中的错误:顺序的前导次要不是正定的 [英] Error in chol.default(Cxx) : the leading minor of order is not positive definite

查看:20
本文介绍了chol.default(Cxx) 中的错误:顺序的前导次要不是正定的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 R 中有一个非常简单的脚本.它加载两个数据帧,然后使用 mixOmics 执行 rCCA:

I have a quite simple script in R. It loads in two data frames, and then performs rCCA with mixOmics:

system('defaults write org.R-project.R force.LANG en_US.UTF-8') 
## install.packages("mixOmics")
library(mixOmics)
TCIA <- read.csv("/Users/kimrants/Desktop/Data_for_R/TCIA",
                 header=TRUE, 
                 sep=",", 
                 stringsAsFactors=FALSE) 
TCGA <- read.csv("/Users/kimrants/Desktop/Data_for_R/TCGA",
                 header=TRUE, 
                 sep=",", 
                 stringsAsFactors=FALSE)

# Remove first column (of ID) 
df_TCGA <- TCGA[,-1] df_TCIA<- TCIA[,-1]
data.shrink <- rcc(X=df_TCIA, Y=df_TCGA, ncomp = 5, method = 'shrinkage')    
plot(data.shrink, scree.type = "barplot")
grid1 <- seq(0, 0.2, length = 5)  
grid2 <- seq(0.0001, 0.2, length = 5)
cv <- tune.rcc(df_TCIA, df_TCGA, 
     grid1 = grid1, grid2 = grid2, validation = "loo") 
result <- rcc(df_TCIA, df_TCGA, ncomp = 5, 
     lambda1= cv$opt.lambda1, lambda2 = cv$opt.lambda2)

但是,在执行倒数第二行时,出现此错误:

However, when performing the second to last line, I get this error:

chol.default(Cxx) 中的错误:4 阶的前导次要不是正定的

Error in chol.default(Cxx) : the leading minor of order 4 is not positive definite

我访问过类似错误的文档:http://mixomics.org/faq/parameters-调整/

I have visited the documentation for similar errors: http://mixomics.org/faq/parameters-tuning/

在这里,它说:这很可能发生在遇到奇异矩阵时,其中来自两个数据集的变量总数远大于样本数.我们建议使用正则化 CCA"...但我已经在使用 rCCA?所以我不知道如何解决这个问题..

Here, it says: "This is mostly likely to occur when encountering singular matrices, where the total number of variables from both data sets is much larger than the number of samples. We suggest using regularized CCA" ... But I am already using rCCA? So I don't know how to fix this..

推荐答案

当您尝试操作的矩阵的某些特征向量不是正数(通常它们为零或低于一些非常小的门槛);这实质上意味着您的数据太嘈杂/太小而无法估计完整的协方差矩阵.

The error you are seeing occurs when some of the eigenvectors of the matrix you are trying to operate on are not positive (typically they'll be zero, or below some very small threshold); this means, essentially, that your data are too noisy/small to estimate a full covariance matrix.

正则化 意味着(大约)添加一个惩罚项,使您的估计远离零(在这种情况下,使您的矩阵远离非正特征向量).如果您的正则化参数(lambda1lambda2)太小,则会出现错误.由于您的 grid1grid2 序列从零或非常小的值开始,rCCA 会因这些太小的值而窒息.

Regularizing means (approximately) adding a penalty term to push your estimates away from zero (in this case, pushing your matrices away from having non-positive eigenvectors). If your regularization parameters (lambda1, lambda2) are too small, then you'll get the error. Since your grid1 and grid2 sequences start from zero or very small values, rCCA will choke for these too-small values.

尝试将 grid1 和 grid2 序列设置为从更大的值开始,例如

Try setting your grid1 and grid2 sequences to start at a larger value, e.g.

grid1 <- grid2 <- seq(0.05, 0.2, length=5)

这篇关于chol.default(Cxx) 中的错误:顺序的前导次要不是正定的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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