Skip to contents

Select the number of components for complete, imputed, or incomplete-data PLS workflows.

Usage

select_ncomp(
  x,
  y,
  method = c("complete", "nipals_standard", "nipals_adaptative"),
  criterion = c("Q2-LOO", "Q2-10fold", "AIC", "AIC-DoF", "BIC", "BIC-DoF"),
  max_ncomp,
  seed = NULL,
  folds = 10L,
  threshold = 0.0975
)

Arguments

x

Predictor matrix, dataset object, or misspls_imputation object.

y

Numeric response vector. This may be omitted when x already contains a response.

method

Selection workflow: "complete", "nipals_standard", or "nipals_adaptative".

criterion

Selection criterion: "Q2-LOO", "Q2-10fold", "AIC", "AIC-DoF", "BIC", or "BIC-DoF".

max_ncomp

Maximum number of components to consider.

seed

Optional random seed used by the cross-validation and imputation aggregation steps.

folds

Number of cross-validation folds used by "Q2-10fold".

threshold

Threshold applied to Q2 criteria.

Value

A one-row data frame describing the selected component count.

Examples

sim <- simulate_pls_data(n = 25, p = 10, true_ncomp = 2, seed = 1)
select_ncomp(sim$x, sim$y, method = "complete", criterion = "AIC", max_ncomp = 4, seed = 2)
#> Loading required namespace: plsdof
#>   selection_method criterion selected_ncomp criterion_value max_ncomp seed
#> 1         complete       AIC              4       -23.27543         4    2
#>   n_imputations status notes
#> 1             1     ok