stats-filter: Linear filtering on a time series

filterR Documentation

Linear filtering on a time series

Description

Applies linear filtering to a univariate "timeSeries".

Usage

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

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.

Value

a "timeSeries" object

See Also

base R function filter

Examples

## 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")

timeSeries documentation built on Sept. 30, 2024, 9:15 a.m.