pub fn model_selection_ncomp(
data: &FdMatrix,
y: &[f64],
scalar_covariates: Option<&FdMatrix>,
max_ncomp: usize,
criterion: SelectionCriterion,
) -> Result<ModelSelectionResult, FdarError>Expand description
Select optimal ncomp for fregre_lm using AIC, BIC, or GCV.
Fits models for ncomp = 1..=max_ncomp, collects information criteria,
and returns the best ncomp under the chosen criterion.
§Arguments
data— Functional predictor matrix (n × m)y— Scalar responses (length n)scalar_covariates— Optional scalar covariates (n × p)max_ncomp— Maximum number of FPC components to trycriterion— Which criterion to minimise
§Errors
Returns FdarError::InvalidParameter if max_ncomp is zero.
Returns FdarError::ComputationFailed if no candidate ncomp produces a
valid fitted model (all calls to fregre_lm fail).