| emsc | R Documentation |
This function implements extended multiplicative signal correction (EMSC),
as proposed by Martens and Stark (1991). EMSC extends msc() by modeling,
in addition to the multiplicative and additive effects, a smooth polynomial
baseline and, optionally, known interferent spectra.
emsc(
x,
xref = NULL,
degree = 2,
interferents = NULL,
wavelength = NULL,
robust = TRUE
)
x |
A numeric matrix or data frame, with one spectrum per row. |
xref |
An optional numeric vector giving the reference spectrum. If
|
degree |
A non-negative integer giving the degree of the polynomial baseline. Default is 2. With 0, only a constant offset is modeled. |
interferents |
An optional numeric vector (a single spectrum), matrix
or data frame of interferent spectra, one per row, with the same number
of columns as |
wavelength |
An optional numeric vector of wavelengths used to build
the polynomials. If |
robust |
A logical value indicating whether the median ( |
Each spectrum \textbf{x}_i is modeled as a linear combination of a
reference spectrum \textbf{m}, polynomials of the wavelength
\lambda and interferent spectra \textbf{k}_j:
\textbf{x}_i = b_i\textbf{m} + a_i + d_{i1}\lambda + d_{i2}\lambda^2 + \dots + \sum_j h_{ij}\textbf{k}_j + \textbf{e}_i
The coefficients are estimated by least squares, and the corrected spectrum is
\textbf{x}_i^{corr} = (\textbf{x}_i - a_i - d_{i1}\lambda - \dots - \sum_j h_{ij}\textbf{k}_j) / b_i
With degree = 0 and no interferents, EMSC is identical to msc() with
drop_offset = TRUE.
The wavelengths are rescaled to [-1, 1] before the polynomials are
formed, for numerical stability. Interferent spectra describe variation
that should be removed, for example the spectrum of a contaminant or the
dominant directions of repeated measurements of the same samples (see
epo()).
The reference spectrum is estimated from x unless xref is given, so
new spectra should be corrected with predict(),
which uses the reference and design of the calibration data.
An object of class specproc_emsc (a list), which
predict() applies to new spectra, with the
following components:
correction: The corrected spectra.
coefficients: A tibble with the estimated coefficients of each
spectrum: slope (b_i), offset (a_i), poly1, ...
(d_{ik}) and interferent1, ... (h_{ij}).
reference: The reference spectrum.
design: The design matrix (one column per model term).
Christian L. Goueguel
Martens, H., Stark, E. (1991). Extended multiplicative signal correction and spectral interference subtraction: new preprocessing methods for near infrared spectroscopy. Journal of Pharmaceutical and Biomedical Analysis, 9(8):625-635.
Afseth, N.K., Kohler, A. (2012). Extended multiplicative signal correction in vibrational spectroscopy, a tutorial. Chemometrics and Intelligent Laboratory Systems, 117:92-99.
msc(), step_emsc() to use EMSC in a tidymodels recipe.
data(forageLIBS)
spectra <- forageLIBS[-(1:14)] # the spectral channels
fit <- emsc(spectra[1:300, ], degree = 2)
head(fit$coefficients)
# new spectra are corrected with the calibration reference
corrected <- predict(fit, spectra[301:368, ])
dim(corrected)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.