Derivatives are a good way to extract information to our spectra. As we know NIR contents overlapping bands, and spectra must be treated with math operations in order to extract as much information as possible and to correlate it with the constituent of interest in the case of quantitative analysis or to discriminate two similar products.
Derivatives are one of those math treatments.
With “R”, we can apply a Savitzky Golay smoothing filter to apply derivatives to our spectra, and to select the order of the derivative.
Let´s have a look first to the R help:
Apply a Savitzky-Golay smoothing filter
Smooth data with a Savitzky-Golay smoothing filter.
sgolayfilt(x, p = 3, n = p + 3 - p%%2, m = 0, ts = 1)
## S3 method for class 'sgolayFilter'
filter(filt, x, ...)
signal to be filtered.
filter length (must be odd).
return the m-th derivative of the filter coefficients.
time scaling factor.
filter characteristics (normally generated by sgolay).
additional arguments (ignored).
Let’s apply the default values for SG filter to the “fattyac” data (you can do the same for the “yarn” data or “gasoline” data).
But first remember how this data looks before any math treatment was applied:
Now let’s give to m, the values 1 (First Derivative) and 2 (Second Derivative)
Here we have a powerful tool, to continue progressing doing Chemometrics with R.
Chemometrics with R (Ron Wehrens)
R help page