detrend {prospectr} | R Documentation

## Detrend transformation

### Description

Normalizes each row of an input `data.frame` or `matrix` by applying a SNV transformation followed by fitting a second order linear model and returning the fitted residuals.

### Usage

    detrend(X,wav)

### Arguments

`X` | numeric `data.frame`, `matrix` or `vector` to process
`wav` | wavelengths/ band centers

### Details

The detrend is a row-wise transformation that allows to correct for wavelength-dependent scattering effects (variations in curvilinearity). A second-degree polynomial is fit through each spectrum:

x_i = aλ^2 + bλ + c + e_i

were x_i is the spectrum, λ is the wavelength vector, a, b, c are estimated by least square, and e_i are the residuals of the least square fit. Then, a detrend spectrum corresponds to:

x\ast_i = x_i - (aλ^2 + bλ + c = e_i)

### Value

a `matrix` or `vector` with detrend values

### Author(s)

Antoine Stevens

### References

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.

### See Also

`standardNormalVariate`, `blockScale`, `blockNorm`

### Examples

    data(NIRsoil)
    wav <- as.numeric(colnames(NIRsoil$spc))
    spc <- 1/10^NIRsoil$spc # conversion to reflectance
    opar <- par(no.readonly = TRUE)
    par(mfrow=c(2,1),mar=c(4,4,2,2))
    matplot(wav,t(spc[1:10,]),type='l',xlab='',ylab='Reflectance') # plot of the 10 first spectra
    mtext('Raw spectra')
    det <- detrend(spc,wav)
    matplot(wav,t(det[1:10,]),type='l',xlab='Wavelength /nm',ylab='Reflectance')
    mtext('Detrend spectra')
    par(opar)

[Package prospectr version 0.1.3 Index]