Predict function not working on PLSDA object

Issue #147 resolved
Former user created an issue

Hi all,

I was going through the vignette here: http://mixomics.org/methods/pls-da/

I am running the code as it is:

## For PLS-DA, train the model
plsda.train <- plsda(X[train_set, ], Y[train_set], ncomp = 4)
# then predict
test.predict <- predict(plsda.train, X[test, ], dist = "max.dist")

When I got to the point where I would make a prediction, I am getting this error:

Error in predict.mvr(object, newdata = newdata) : 'newdata' does not have the correct number of columns

Any ideas?

Thanks, Edward

Comments (3)

  1. Florian Rohart

    Hi Edward,

    That is coming from a clash between mixOmics and the pls package: "predict.mvr" is a function of the pls package.. It should be calling the predict() function from mixOmics ("predict.spls") Try detaching "pls".

    We'll eventually have to do something about these clashes as they always happen somehow.. Maybe change the class of the mixOmics objects so they don't clash with "pls".

  2. Edward Moseley

    Thanks, Florian.

    I would advise others in general that it is not enough to simply detach:pls. If you're still getting the error, check sessionInfo() and see if pls is loaded via namespace (and not attached).

    Edward

  3. Log in to comment