Learn R Programming

rchemo (version 0.1-3)

detrend: Polynomial de-trend transformation

Description

Polynomial de-trend transformation of row observations (e.g. spectra) of a dataset. The function fits an orthogonal polynom of a given degree to each observation and returns the residuals.

Usage

detrend(X, degree = 1)

Value

A matrix of the transformed data.

Arguments

X

X-data (\(n, p\)).

degree

Degree of the polynom.

Details

detrend uses function poly of package stats.

Examples

Run this code

data(cassav)

X <- cassav$Xtest

degree <- 1
Xp <- detrend(X, degree = degree)

oldpar <- par(mfrow = c(1, 1))
par(mfrow = c(1, 2))
plotsp(X, main = "Signal")
plotsp(Xp, main = "Corrected signal")
abline(h = 0, lty = 2, col = "grey")
par(oldpar)

Run the code above in your browser using DataLab