prep.alsbasecorr: Baseline correction using asymetric least squares

View source: R/prep.R

prep.alsbasecorrR Documentation

Baseline correction using asymetric least squares

Description

Baseline correction using asymetric least squares

Usage

prep.alsbasecorr(data, plambda = 5, p = 0.1, max.niter = 10)

Arguments

data

matrix with spectra (rows correspond to individual spectra)

plambda

power of the penalty parameter (e.g. if plambda = 5, lambda = 10^5)

p

assymetry ratio (should be between 0 and 1)

max.niter

maximum number of iterations

Details

The function implements baseline correction algorithm based on Whittaker smoother. The method was first shown in [1]. The function has two main parameters - power of a penalty parameter (usually varies betwen 2 and 9) and the ratio of assymetry (usually between 0.1 and 0.001). The choice of the parameters depends on how broad the disturbances of the baseline are and how narrow the original spectral peaks are.

Value

preprocessed spectra.

Examples

# take spectra from carbs dataset
data(carbs)
spectra = mda.t(carbs$S)

# apply the correction
pspectra = prep.alsbasecorr(spectra, plambda = 3, p = 0.01)

# show the original and the corrected spectra individually
par(mfrow = c(3, 1))
for (i in 1:3) {
   mdaplotg(list(
      original = mda.subset(spectra, i),
      corrected = mda.subset(pspectra, i)
   ), type = "l", col = c("black", "red"), lwd = c(2, 1), main = rownames(spectra)[i])
}


svkucheryavski/mdatools documentation built on Aug. 25, 2023, 12:27 p.m.