Error of multiple of replacement in perf
for plsda and possible solution
#303
Labels
bug
Something isn't working
perf
for plsda and possible solution
#303
Hi mixOmics team and users,
🐞 Describe the bug:
When run function
perf
on a plsda/ splsda object, this error might happen:This is from the step to return the number of optimal component according to the error rates and happens when there are more than one component has the same minimum error rates. This error happens when using LOOV (
validation = "loo
, with alwaysnrepeat = 1
) or Mfold withnrepeat < 3
and more often when the sample size is very small.💡 Possible solution:
Before another updated
mixOmics
comes out, here is my solution in case you also encounter it:perf
.perf.mixo_plsda
(line 740- end), copy.ncomp_opt[measure, ijk] = which(t(rowMeans(mat.error.rate[[measure_i]][[ijk]])) == min(t(rowMeans(mat.error.rate[[measure_i]][[ijk]]))))[1]
(just add a[1]
at the end of this line in the orginal code to avoid multiple replacement). Then run the new function.environment()
assures that the function will be able to call other hidden functions inmixOmics
by using the code:environment(mod_perf.mixo_plsda) <- asNamespace("mixOmics")
.splsda.perf <- mod_perf.mixo_plsda(splsda, validation = "loo")
. And it should work now!Hope it helps!
Guan
The text was updated successfully, but these errors were encountered: