| prep_detrend | R Documentation |
Creates a preprocessing constructor for detrending spectral data. The
constructor is intended to be passed to preprocess_recipe and
executed via process.
prep_detrend(p = 2)
p |
A positive integer specifying the polynomial order used for
fitting. Must be >= 1. Default is |
For each spectrum, a polynomial of order p is fitted using the
column wavelengths as the explanatory variable (or integer indices if column
names are not numeric). The residuals from this fit are returned as the
detrended spectrum, removing wavelength-dependent baseline effects.
This constructor always performs pure polynomial detrending without a prior
SNV transformation. Users who want the full Barnes et al. (1989) procedure
(SNV followed by detrending) should chain prep_snv before
prep_detrend in their recipe.
The computation is delegated to detrend with
snv = FALSE.
An object of class preprocessing to be used in
preprocess_recipe and executed by process.
Leonardo Ramirez-Lopez
Barnes RJ, Dhanoa MS, Lister SJ. 1989. Standard normal variate transformation and de-trending of near-infrared diffuse reflectance spectra. Applied Spectroscopy, 43(5): 772-777.
prep_snv, preprocess_recipe,
process
data("proximateCannabis")
X <- proximateCannabis$spc
# Pure polynomial detrend
dt <- prep_detrend(p = 2)
recipe <- preprocess_recipe(dt, device = "unspecified")
X_dt <- process(X, recipe)
# Barnes et al. (1989): SNV followed by detrend
recipe_barnes <- preprocess_recipe(
prep_snv(), prep_detrend(p = 2),
device = "unspecified"
)
X_barnes <- process(X, recipe_barnes)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.