savgol: Savitzky-Golay Smoothing

View source: R/savgol.R

savgolR Documentation

Savitzky-Golay Smoothing

Description

Polynomial filtering method of Savitzky and Golay.

Usage

savgol(T, fl, forder = 4, dorder = 0)

Arguments

T

Vector of signals to be filtered.

fl

Filter length (for instance fl = 51..151), has to be odd.

forder

Filter order (2 = quadratic filter, 4 = quartic).

dorder

Derivative order (0 = smoothing, 1 = first derivative, etc.).

Details

Savitzky-Golay smoothing performs a local polynomial regression on a series of values which are treated as being equally spaced to determine the smoothed value for each point. Methods are also provided for calculating derivatives.

Value

Vector representing the smoothed time series.

Note

For derivatives T2 has to be divided by the step size to the order
(and to be multiplied by k! — the sign appears to be wrong).

Author(s)

Peter Riegler implemented a Matlab version in 2001. Based on this, Hans W. Borchers published an R version in 2003.

References

See Numerical Recipes, 1992, Chapter 14.8, for details.

See Also

RTisean::sav_gol, signal::sgolayfilt, whittaker.

Examples

# *** Sinosoid test function ***
ts <- sin(2*pi*(1:1000)/200)
t1 <- ts + rnorm(1000)/10
t2 <- savgol(t1, 51)
## Not run: 
plot( 1:1000, t1, col = "grey")
lines(1:1000, ts, col = "blue")
lines(1:1000, t2, col = "red")
## End(Not run)

pracma documentation built on March 19, 2024, 3:05 a.m.