crossValFit {metabCombiner} | R Documentation

## Cross Validation for Model Fits

### Description

Helper function for `fit_gam()` & `fit_loess()`. Determines optimal value of `k` basis functions for Generalized Additive Model fits or `span` for loess fits from among user-defined choices, using a 10-fold cross validation minimizing mean squared error.

### Usage

    crossValFit(
      rts,
      fit,
      vals,
      bs,
      family,
      m,
      method,
      optimizer,
      control,
      message,
      ...
    )

### Arguments

`rts` | data.frame of ordered pair retention times
`fit` | Either "gam" for GAM fits, or "loess" for loess fits
`vals` | numeric vector: k values for GAM fits, spans for loess fits. Best value chosen by 10-fold cross validation.
`bs` | character. Choice of spline method, either "bs" or "ps"
`family` | character. Choice of mgcv family; see: ?mgcv::family.mgcv
`m` | integer. Basis and penalty order for GAM; see ?mgcv::s
`method` | character. Smoothing parameter estimation method; see: ?mgcv::gam
`optimizer` | character. Method to optimize smoothing parameter; see: ?mgcv::gam
`control` | control parameters for loess fits; see: ?loess.control
`message` | Option to print message indicating function progress
`...` | Other arguments passed to `mgcv::gam`.

### Value

Optimal parameter value as determined by 10-fold cross validation

[Package metabCombiner version 1.2.2 Index]