calibrate: Fits a spectral PLS calibration model.

Description Usage Arguments Value Author(s) Examples

View source: R/calibrate.R

Description

This function is a wrapper for mvr() in the pls package. The function fits a Partial Least Squares (PLS) model relating a set of spectra to a component variable. The function uses leave-one-out crossvalidation to calculate the optimal number of latent vectors to use in the PLS regression. The optimal number of latent vectors is the minimum number of factors that result in a predicted residual error sum of squares (PRESS) statistic with a probability less than or equal to 0.75.

Usage

1
2
3
calibrate(component, spectra, optimal_params = NULL, optimal_model = 1,
  validation = "none", training_set = NULL, parallel = FALSE,
  max_comps = 10)

Arguments

component

A vector of y-values. One for each spectrum.

spectra

An object of class spectra.matrix containing spectra. Rows should be in the same order as the component y-values.

optimal_params

An object of class PLSopt containing the optimization results from the optimizePLS() function.

optimal_model

A row index (default = 1; i.e., the top model) for the parameters desired in the PLSopt object.

validation

What model validation should be taken, if any? ("none" = no validation; "LOO" = leave-one-out cross validation; "testset" = validation using a data subset specified as FALSE in training_set)

training_set

A logical vector of length(component) specifying TRUE for training/calibration data and FALSE for test/validation set data

parallel

Logical. The default is FALSE; TRUE allows for the parallelization of validation proceedures, using the number of available cores - 1. If FALSE the function will not be parallelized. Parrallelization only applies for crossvalidation approaches.

max_comps

What is the maximum number of latent vectors to possibly include in the PLS regression. An integer.

Value

Returns an object of class PLScalibration. The object is a list containing the pls model and the calibration/validation statistics. See below:

model - PLS model of class mvr form the pls package
rank - the number of latent vectors (factors, ranks, etc) chosen for the model
RMSEP - root mean squared error of prediction
R2_Cal - model calibration R2
R2_Val - model validation R2
regions - the spectra regions used in model fitting
preproc - the preprocessing steps used before model fitting
training_set - logical indicating those spectra used in the calibration fitting
data - data used in model fitting

Author(s)

Daniel M Griffith

Examples

1
2
3
4
5
6
# See main leaf.spec-package example. But:
## Not run: 
data(shootout)
temp <- calibrate(component = shootout_wetlab$N, spectra = shootout_scans, validation = "LOO")

## End(Not run)

griffithdan/plantspec documentation built on Dec. 9, 2018, 1:26 a.m.