splsda bug with 1 component

Create issue
Issue #154 resolved
Former user created an issue

If a model is trained with splsda with only one component, the object it creates cannot be called. It gives the following error:

Error in switch(classifier, logistic = { : EXPR must be a length 1 vector

The components of the object can still be accessed through the $ operator. Also cim() still works on it but predict does not work.

This does not happen with normal plsda. I can reproduce this bug using the following code:

X <- liver.toxicity$gene
Y <- as.factor(liver.toxicity$treatment[, 4])

samp <- sample(1:5, nrow(X), replace = TRUE)  
test <- which(samp == 1)   # testing on the first fold
train <- setdiff(1:nrow(X), test)

plsda.train <- plsda(X[train, ], Y[train], ncomp = 1)
splsda.train <- splsda(X[train, ], Y[train], ncomp = 1)

Comments (2)

  1. Florian Rohart

    Hi there,

    can't reproduce this error on the latest version (6.7.1 at the moment), so... Maybe it was fixed at some point!

  2. Log in to comment