Error 'newdata' must include all the variables of 'object$X'

Issue #127 resolved
Lijia Yu
created an issue

In sPLSDA model, if I set up near.zero.var =T in splsda(), when I plot ROC curve, it will trigger error in the internal prediction function, because newdata only include data without zero value, but object$X include all data value.

      # deal with near.zero.var in object, to remove the same variable in newdata as in object$X (already removed in object$X)
      if(length(object$nzv$Position) > 0)
        newdata = newdata[, -object$nzv$Position,drop=FALSE]

      if(all.equal(colnames(newdata),colnames(object$X))!=TRUE)
        stop("'newdata' must include all the variables of 'object$X'")

Comments (7)

  1. Kim-Anh Le Cao repo owner

    Hi Lijia, thank you for your report. The quick fix for now would be to remove the nzv variables (the indices are output from splsda()) from your newdata to carry on. We will be able to fix the bug some time in April.

  2. Log in to comment