
Select the optimal ncomp from sPLS cross-validation results
Source:R/spls.R
spls_get_optim_ncomp.RdSelect the optimal number of components to compute in a sPLS run from the
cross-validation results obtained with mixOmics::perf() on a PLS or sPLS
result, using the the mean Q2.total values. Note that this function is
experimental, the corresponding diagnostic plots should be considered when
selecting the optimal number of components to use.
Arguments
- spls_perf
List, the result of
mixOmics::perf().- thr
Numeric, the threshold to be used for the
Q2values. Default value is 0.0975.- min_ncomp
Integer, the minimum
ncompvalue to be returned. Default value is 1, i.e. this argument does not play a role in selecting thecompvalue. Can be useful if we want at least 2 latent components for final plots.
Details
The selection is made as follows:
If all
Q2values are below the threshold specified withthr, the number of components yielding the highestQ2value is selected.If all
Q2values are above the threshold, the number of components yielding the lowestQ2value is selected.If the
Q2values are increasing, the number of componentsnis selected such thatn+1is the smallest number of components with aQ2value above the threshold.If the
Q2values are decreasing, the number of componentsnis selected such thatn+1is the smallest number of components with aQ2value below the threshold.