Learn R Programming

timeSeries (version 4041.111)

filter: Linear filtering on a time series

Description

Applies linear filtering to a univariate "timeSeries".

Usage

# S4 method for timeSeries
filter(x, filter, method = c("convolution", "recursive"), sides = 2, 
       circular = FALSE, init = NULL)

Value

a "timeSeries" object

Arguments

x

an object from class "timeSeries".

filter

coefficients of the filter.

method

"convolution" or "recursive".

sides,circular

for convolution filters only. Onesided if sides = 1, centred around lag 0 if sides = 2. Circular if circular = TRUE.

init

for recursive filters only. Values before the start of the time series.

Details

filter is a generic function with default method stats::filter. The method for "timeSeries" is a wrapper for the latter.

See ?stats::filter for details about the arguments.

See Also

base R function filter

Examples

Run this code
## Creata a dummy signal 'timeSeries' - 
   data <- matrix(rnorm(100), ncol = 2)
   s <- timeSeries(data, units=c("A", "B"))
   head(s)
   
## Filter the series - 
   f <- filter(s, rep(1, 3))
   head(f)
   
## Plot and compare the first series - 
   plot(cbind(s[, 1], f[, 1]), plot.type="s")

Run the code above in your browser using DataLab