ncomp_selection: Component selection methods

ncomp_selectionR Documentation

Component selection methods

Description

Constructor functions for specifying how to select the number of components in projection-based dissimilarity methods (diss_pca(), diss_pls()).

Usage

ncomp_by_var(min_var = 0.01, max_ncomp = 40L)

ncomp_by_cumvar(min_cumvar = 0.99, max_ncomp = 40L)

ncomp_by_opc(max_ncomp = 40L)

ncomp_fixed(ncomp)

Arguments

min_var

Numeric in (0, 1]. Minimum variance a single component must explain to be retained.

max_ncomp

Positive integer. Maximum number of components to compute or evaluate.

min_cumvar

Numeric in (0, 1]. Minimum cumulative variance that the retained components must explain.

ncomp

Positive integer. Exact number of components to use.

Details

Four selection methods are available:

ncomp_by_var()

Retains components that individually explain at least min_var proportion of variance.

ncomp_by_cumvar()

Retains the minimum number of components whose combined explained variance reaches min_cumvar.

ncomp_by_opc()

Optimized principal component selection based on side information (Ramirez-Lopez et al., 2013). The optimal number of components minimizes the RMSD between each observation's response and its nearest neighbor's response in the projected space. Requires Yr.

ncomp_fixed()

Uses exactly ncomp components with no automatic selection. Equivalent to passing an integer directly.

At runtime, max_ncomp is capped at min(max_ncomp, nrow(X), ncol(X)).

Value

An object of class "ncomp_selection" with a subclass indicating the method:

  • ncomp_by_var: class c("ncomp_by_var", "ncomp_selection")

  • ncomp_by_cumvar: class c("ncomp_by_cumvar", "ncomp_selection")

  • ncomp_by_opc: class c("ncomp_by_opc", "ncomp_selection")

  • ncomp_fixed: class c("ncomp_fixed", "ncomp_selection")

Author(s)

Leonardo Ramirez-Lopez

References

Ramirez-Lopez, L., Behrens, T., Schmidt, K., Stevens, A., Dematte, J.A.M., Scholten, T. 2013. The spectrum-based learner: A new local approach for modeling soil vis-NIR spectra of complex data sets. Geoderma 195-196, 268-279.

See Also

diss_pca(), diss_pls(), dissimilarity()

Examples

# Retain components explaining >= 1% variance each
ncomp_by_var(0.01)

# Retain enough components for 99% cumulative variance
ncomp_by_cumvar(0.99)

# Optimize using side information (requires Yr)
ncomp_by_opc(max_ncomp = 40)

# Fix at exactly 10 components
ncomp_fixed(10)

# Usage in dissimilarity constructors
diss_pca(ncomp = ncomp_by_var(0.01))
diss_pca(ncomp = ncomp_by_opc())
diss_pca(ncomp = 10)  


resemble documentation built on April 21, 2026, 1:07 a.m.