Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

filter

Filter a signal


Description

Generic filtering function. The default is to filter with an ARMA filter of given coefficients. The default filtering operation follows Matlab/Octave conventions.

Usage

## Default S3 method:
filter(filt, a, x, init, init.x, init.y, ...)

## S3 method for class 'Arma'
filter(filt, x, ...)

## S3 method for class 'Ma'
filter(filt, x, ...)

## S3 method for class 'Zpg'
filter(filt, x, ...)

Arguments

filt

For the default case, the moving-average coefficients of an ARMA filter (normally called ‘b’). Generically, filt specifies an arbitrary filter operation.

a

the autoregressive (recursive) coefficients of an ARMA filter.

x

the input signal to be filtered.

init, init.x, init.y

init, init.x, init.y

allows to supply initial data for the filter - this allows to filter very large timeseries in pieces.

...

additional arguments (ignored).

Details

The default filter is an ARMA filter defined as:

a[1]*y[n] + a[2]*y[n-1] + … + a[n]*y[1] = b[1]*x[n] + b[2]*x[m-1] + … + b[m]*x[1]

The default filter calls stats:::filter, so it returns a time-series object.

Since filter is generic, it can be extended to call other filter types.

Value

The filtered signal, normally of the same length of the input signal x.

Author(s)

Tom Short, EPRI Solutions, Inc., (tshort@eprisolutions.com)

References

Octave Forge http://octave.sf.net

See Also

filter in the stats package, Arma, fftfilt, filtfilt, and runmed.

Examples

bf <- butter(3, 0.1)                          # 10 Hz low-pass filter
t <- seq(0, 1, len = 100)                     # 1 second sample
x <- sin(2*pi*t*2.3) + 0.25*rnorm(length(t))  # 2.3 Hz sinusoid+noise
z <- filter(bf, x) # apply filter
plot(t, x, type = "l")
lines(t, z, col = "red")

signal

Signal Processing

v0.7-6
GPL-2
Authors
Uwe Ligges [aut, cre] (new maintainer), Tom Short [aut] (port to R), Paul Kienzle [aut] (majority of the original sources), Sarah Schnackenberg [ctb] (various test cases and bug fixes), David Billinghurst [ctb], Hans-Werner Borchers [ctb], Andre Carezia [ctb], Pascal Dupuis [ctb], John W. Eaton [ctb], E. Farhi [ctb], Kai Habel [ctb], Kurt Hornik [ctb], Sebastian Krey [ctb], Bill Lash [ctb], Friedrich Leisch [ctb], Olaf Mersmann [ctb], Paulo Neis [ctb], Jaakko Ruohio [ctb], Julius O. Smith III [ctb], Doug Stewart [ctb], Andreas Weingessel [ctb]
Initial release
2015-07-29

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.