"not positive definite" error in rcc()

Whiling running the following line:

grid1 <- seq(0.6, 0.7, length = 10) 
grid2 <- seq(0.3, 0.4, length = 10)
cv <- tune.rcc(X,Y, grid1 = grid1, grid2 = grid2, validation = "Mfold")
rccRe <- rcc(X,Y, ncomp = 2, lambda1 = cv$opt.lambda1,lambda2 = cv$opt.lambda2)

I got the following error:

Error in chol.default(Cyy) :
the leading minor of order 275 is not positive definite
Calls: rcc -> chol -> chol.default

I got similar error from tune.rcc and had to increase lamda, then the error disappered. But now it happens to rcc(). Do I have to go back to tune.rcc() and increase lamda again?

hi @blueskypie,

It seems that your grid is starting too low to regularise the var-cov matrices appropriately. Also remember that the tune.rcc() uses fold cross-validation (here by default you chose 5-fold I think) and so the results may vary also once you go back to an rCCA (although I have never seen it happening).
Try again with high values of lambda. Also consider in rcc() the argument method = 'shrinkage' directly. It is not as optimal (it tends to lead to canonical correlation that do not decrease fast enough), but for N << P+Q it might be more appropriate.


Thanks so much for the quick response! I’ll try higher lambda. I cannot use shrinkage due to NAs in my data.

Dear @blueskypie

If you have NAs and not too many, consider imputing your missing values as shown here:
http://mixomics.org/methods/missing-values/ first.