sav_gol {RTisean}R Documentation

Savitzky-Golay filter

Description

A Savitzky-Golay filter to either clean the data from high frequency noise or to get a better estimate of its derivative of a chosen order.

Usage

sav_gol(series, l, x = 0, c, m, n = "2,2", p = 2, D = 0)

Arguments

series a vector or a matrix.
l number of data to use.
x number of lines to be ignored.
c column to be read.
m number of components to be read (dimension).
n a string containing the two lengths of the averaging windows back and forward in time, separated by comma (see example)
p order of the fitted polynomial.
D order of the derivative to be estimated.

Value

A matrix containining the filtered data, disposed in l lines, each of which has m columns. The first length of the averaging window back in time and the last length of the averaging window forward in time lines are special. They contain the raw data in the case that D was set to 0 and zeroes in the case that D was larger than zero.

References

W. H. Press, B. P. Flannery, S. A. Teukolsky, and W. T. Vetterling, ``Numerical Recipes'', 2nd edn., Cambridge University Press, Cambridge (1992).

Examples

## Not run: 

numdata <- 500
dat <- cos(1:numdata/25)+rnorm(numdata,0,0.1)
windowlength <- 15
plot(dat[windowlength:(numdata-windowlength)],xlab="Time",t="l",ylab="Cos Data",ylim=c(-1.5,1.2))
filteredata <- sav_gol(dat,n="15,15")
lines(filteredata[windowlength:(numdata-windowlength)],col=2,lwd=2)
legend(300,-1.2, c("Noisy Data","Filtered Data"),fill=c(1,2), bty="n")

## End(Not run)

[Package RTisean version 3.0.10 Index]