
Read model parameters from ProxiMate .cal files
Source:R/proximate_read_cal.R
proximate_read_cal.RdReads 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.
Arguments
- file
a character vector of
.calfile paths.- ignore_version
a logical. If
FALSE(default), files with no version information or created with NIRWise PLUS prior to version 1.0 raise an error. IfTRUE, such files are read with a warning instead; predictions from these files may deviate from those produced on the instrument.- object
an object of class
read_calas returned byproximate_read_cal().- newdata
a matrix of new spectral data to predict from. Column names must be coercible to the wavelengths used in the model.
- get_comp
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.- get_scores
a logical indicating whether PLS scores should be returned alongside predictions. Default is
FALSE.- bias_index
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.
Value
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 inobject.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 whenget_scores = TRUE. The projection of new samples into the PLS score space.