Learn R Programming

baseline (version 1.3-8)

doOptim: Optimise several baseline algorithms on a data set

Description

Tests several baseline algorithms with one predictor for a given data set. The baseline algorithms are represented as a list of baselineAlgTest objects, and the predictor as a predictionTest object.

Usage

doOptim(
  baselineTests,
  X,
  y,
  predictionTest,
  postproc = NULL,
  tmpfile = "tmp.baseline",
  verbose = FALSE,
  cleanTmp = FALSE
)

mvrValstats( object, estimate, newdata, ncomp = 1:object$ncomp, comps, intercept = cumulative, se = FALSE, ... )

Value

A list with components

baselineTests

The baselineTests argument

results

A list with the baselineAlgResult objects for each baseline test

minQualMeas

The minimum quality measure value

baselineAlg.min

The name of the baseline algorithm giving the minimum quality measure value

param.min

A list with the parameter values corresponding to the minimum quality measure value

Arguments

baselineTests

a list of baselineAlgTest objects. The baseline algorithms and parameter values to test

X

A matrix. The spectra to use in the test

y

A vector or matrix. The response(s) to use in the test

predictionTest

A predictionTest object. The predictor and parameter values to use in the test

postproc

A function, used to postprocess the baseline corrected spectra prior to prediction testing. The function should take a matrix of spectra as its only argument, and return a matrix of postprocessed spectra

tmpfile

The basename of the files used to store intermediate calculations for checkpointing. Defaults to "tmp.baseline"

verbose

Logical, specifying whether the test should print out progress information. Default is FALSE

cleanTmp

Logical, specifying whether the intermediate files should be deleted when the optimisation has finished. Default is FALSE

object

An mvr object, as returned by pls::plsr. Internal helper used by doOptim; not meant to be called directly.

estimate

Character vector of estimate types, passed on from pls::MSEP.

newdata

Optional new data used to calculate the validation statistics.

ncomp

Vector of the number of components to calculate statistics for.

comps

Alternative to ncomp, a vector of specific components to use.

intercept

Logical, whether statistics for the intercept-only model should be included.

se

Logical, whether to calculate standard errors.

...

Other arguments, currently unused by mvrValstats.

Author

Bjørn-Helge Mevik and Kristian Hovde Liland

Details

The function loops through the baseline algorithm tests in baselineTests, testing each of them with the given data and prediction test, and collects the results. The results of each baseline algorithm test is saved in a temporary file so that if the optimisation is interrupted, it can be re-run and will use the pre-calculated results. If cleanTmp is TRUE, the temporary files are deleted when the whole optimisation has finished.

See Also

baselineAlgTest,predictionTest

Examples

Run this code
# \donttest{
if (requireNamespace("pls", quietly = TRUE)) {
data(milk)
X <- milk$spectra[,-1]
y <- milk$spectra[,1]
opt <- doOptim(
    list(ALS = new("baselineAlgTest", 
                   algorithm = baselineAlgorithms$als, 
                   param=list(lambda=6:7,p=0.5))),
    X, y, 
    new("PLSRTest", 
        ncomp = 10, 
        cvsegments = pls::cvsegments(N=45, k=5)),
    cleanTmp = TRUE)
}
# }

Run the code above in your browser using DataLab