Reads the metadata and model parameters from one or more .cal files
generated by BUCHI ProxiMate sensors. The function extracts the preprocessing
recipe, regression method, PLS weights, loadings, scores, intercepts, and
bias terms required to project new spectra into the score space and produce
predictions. Spectral regression coefficients are not retrieved directly;
predictions are computed in the score space via predict.read_cal.
proximate_read_cal(file, ignore_version = FALSE)# S3 method for read_cal
predict(object, newdata, get_comp = c("optimal", "all"),
get_scores = FALSE, bias_index = 1, ...)
For proximate_read_cal(), a list of class "read_cal" with the following
elements:
summary: a data.frame describing each model:
Property: name of the response variable.
Preprocessing: sequence of preprocessing steps applied (without parameters).
Method: regression method used.
Factors: number of PLS components used.
Cross-validation: number of cross-validation segments.
A value of 0 indicates no cross-validation was used.
Auto-skip: logical indicating whether automatic outlier
removal (auto-delete) was applied during calibration.
meta_param: a list with one element per model containing
the preprocessing recipe (precipe), the indices of automatically
removed observations (auto_skip), and a logical indicating whether
sample aggregation was applied (aggregate).
file_info: a list with one element per model containing
the file paths of the spectral data used for calibration (files)
and the indices of manually skipped observations per file
(skipped_indices).
models: a list with one element per model containing all
parameters required for prediction: wavelengths, preprocessing recipe,
number of factors, mean-centering vector, scores, score scale factors,
PLS weights, loadings, biases, intercept, and target values.
For predict.read_cal(), a list with the following elements:
predictions: predicted values for each model in
object.
distances: scaled score distances for each sample and
model, which can be used to assess how well a new sample is represented
by the model.
scores: only returned when get_scores = TRUE. The
projection of new samples into the PLS score space.
a character vector of .cal file paths.
a logical. If FALSE (default), files with no
version information or created with NIRWise PLUS prior to version 1.0 raise
an error. If TRUE, such files are read with a warning instead;
predictions from these files may deviate from those produced on the instrument.
an object of class read_cal as returned by
proximate_read_cal().
a matrix of new spectral data to predict from. Column names must be coercible to the wavelengths used in the model.
a character string. Either "optimal" (default) to
return predictions only for the optimal number of components, or "all"
to return predictions for every available component.
a logical indicating whether PLS scores should be returned
alongside predictions. Default is FALSE.
the index of the bias to be applied in the list of biases. These are generated in NIRWise PLUS based on the number of files containing the calibration data. Default = 1.
not currently used.
Leonardo Ramirez-Lopez and Claudio Orellano
proximate_recalibrate_nax,
proximate_read_nax