% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ncomp_by_methods.R
\name{ncomp_selection}
\alias{ncomp_selection}
\alias{ncomp_by_var}
\alias{ncomp_by_cumvar}
\alias{ncomp_by_opc}
\alias{ncomp_fixed}
\title{Component selection methods}
\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{
\item{min_var}{Numeric in (0, 1]. Minimum variance a single component must
explain to be retained.}

\item{max_ncomp}{Positive integer. Maximum number of components to
compute or evaluate.}

\item{min_cumvar}{Numeric in (0, 1]. Minimum cumulative variance that the
retained components must explain.}

\item{ncomp}{Positive integer. Exact number of components to use.}
}
\value{
An object of class \code{"ncomp_selection"} with a subclass indicating the
method:
\itemize{
\item \code{ncomp_by_var}: class \code{c("ncomp_by_var", "ncomp_selection")}
\item \code{ncomp_by_cumvar}: class \code{c("ncomp_by_cumvar", "ncomp_selection")}
\item \code{ncomp_by_opc}: class \code{c("ncomp_by_opc", "ncomp_selection")}
\item \code{ncomp_fixed}: class \code{c("ncomp_fixed", "ncomp_selection")}
}
}
\description{
Constructor functions for specifying how to select the number of components
in projection-based dissimilarity methods (\code{\link[=diss_pca]{diss_pca()}}, \code{\link[=diss_pls]{diss_pls()}}).
}
\details{
Four selection methods are available:

\describe{
\item{\code{ncomp_by_var()}}{Retains components that individually explain at
least \code{min_var} proportion of variance.}
\item{\code{ncomp_by_cumvar()}}{Retains the minimum number of components whose
combined explained variance reaches \code{min_cumvar}.
}
\item{\code{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 \code{Yr}.}
\item{\code{ncomp_fixed()}}{Uses exactly \code{ncomp} components with no automatic
selection. Equivalent to passing an integer directly.}
}

At runtime, \code{max_ncomp} is capped at \code{min(max_ncomp, nrow(X), ncol(X))}.
}
\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)  

}
\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.
}
\seealso{
\code{\link[=diss_pca]{diss_pca()}}, \code{\link[=diss_pls]{diss_pls()}}, \code{\link[=dissimilarity]{dissimilarity()}}
}
\author{
\href{https://orcid.org/0000-0002-5369-5120}{Leonardo Ramirez-Lopez}
}
