rcc with p=1 or q=1

Create issue
Issue #57 resolved
Maxime Turgeon created an issue

When using the function rcc with either X or Y containing a single column, the code runs fine. However, when we want to perform cross-validation using tune.rcc, we get the following error (here, X has a single column):

Error: 'X' must be a numeric matrix.

The traceback() is as follows:

6: stop("'X' must be a numeric matrix.", call. = FALSE)
5: rcc(X[-omit, ], Y[-omit, ], 1, lambda1, lambda2, method = "ridge")
4: Mfold(X, Y, lambda[1], lambda[2], folds, M)
3: FUN(newX[, i], ...)
2: apply(grid, 1, function(lambda) {
       Mfold(X, Y, lambda[1], lambda[2], folds, M)
   })
1: tune.rcc(X_mix, Y, grid1 = 0, grid2 = grid, validation = "Mfold", 
       M = 10)

The fix is therefore very straightforward: we need to replace

 rcc(X[-omit, ], Y[-omit, ], 1, lambda1, lambda2, method = "ridge")

with

 rcc(X[-omit, ,drop=FALSE], Y[-omit, ,drop=FALSE], 1, lambda1, lambda2, method = "ridge")

and similarly every time a subset of the rows is selected.

Comments (3)

  1. Maxime Turgeon reporter

    Actually I just tried it out, and the change I explicitely mentioned above is sufficient in solving the issue (i.e. disregard the sentence "and similarly every time a subset of the rows is selected.").

  2. Florian Rohart

    Hi Maxime, thanks for noticing this issue. It has been fixed for the next release!

    Thanks again

  3. Log in to comment