- edited description
Error 'newdata' must include all the variables of 'object$X'
Issue #127
resolved
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)
-
reporter -
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.
-
Hi Lija,
which function are you using? predict? tune.splsda?
Thanks
-
reporter I am using
splsda()
, then plot ROC curve viaauroc()
-
so something like:
res = splsda(X,Y,ncomp) auroc(res)
or something like
res = splsda(X,Y,ncomp) auroc(res, newdata = newX)
-
repo owner - changed status to resolved
-
reporter my code:
res = splsda(X,Y,ncomp,near.zero.var =T) auroc(res)
- Log in to comment