I am trying to fit a sPLS model to my data (regression mode). I use spls
with a larger number of components and then I use perf
to select the best parameter. It seems that 1 component is sufficient (judging from the Q2 values). Now I should re-fit the model using this number: if I do so, and I try to use plotVar
, I get the following message error:
Error: Each element of 'comp' must be positive <= 1.
3.
stop("Each element of 'comp' must be positive <= ", min(object$ncomp), ".", call. = FALSE)
2.
mixOmics::plotVar(pls.results, legend = TRUE, title = "Variable plot") at multivariate_analysis.R#166
1.
plot.pls(res.spls.simple, perf.spls.simple)
What am I doing wrong?
Is there a way to automatically re-fit the model using the best value of ncomp
? Moreover, if I want to compute for instance the Q2 or any other metric, why can I do that only on the results of perf
and not spls
? Thanks.