
Last chance! 50% off unlimited learning
Sale ends in
filter(x, filter, method = c("convolution", "recursive"), sides = 2, circular = FALSE, init)
"convolution"
or "recursive"
(and
can be abbreviated). If "convolution"
a moving average is
used: if "recursive"
an autoregression is used.sides = 1
the
filter coefficients are for past values only; if sides = 2
they are centred around lag 0. In this case the length of the
filter should be odd, but if it is even, more of the filter
is forward in time than backward.TRUE
, wrap
the filter around the ends of the series, otherwise assume
external values are missing (NA
).x
but not in filter
(where they would lead to missing values everywhere in the output). Note that there is an implied coefficient 1 at lag 0 in the
recursive filter, which gives
The convolution filter is
where o
is the offset: see sides
for how it is determined.
convolve
, arima.sim
x <- 1:100
filter(x, rep(1, 3))
filter(x, rep(1, 3), sides = 1)
filter(x, rep(1, 3), sides = 1, circular = TRUE)
filter(presidents, rep(1, 3))
Run the code above in your browser using DataLab