iema: Iterated Exponential Moving Average

Description Usage Arguments Details See Also Examples

Description

iema returns a vector whose values are the iteratively exponentially smoothed values of an input vector.

Usage

1
iema(x, a = 2, iter = 8, direction = c("ff", "fb", "bf", "av"))

Arguments

x

a numeric vector

a

numeric; smoothing factor

iter

integer; number of iterations

direction

character; should the moving averages be run

  • ff: forwards only

  • fb: forwards then backwards then forwards ...

  • bf: backwards then forwards then backwards ...

  • av: both fb and bf, returning the average

Details

iema is a generalization of dema where the exponential moving average can be applied to the vector an arbitrary number of times. Just as the root-two'th root of a is used in dema, here the root-iter'th root of a is used for each iteration.

That is

a* = a^(1/sqrt(iter))

See Also

ema, dema, rolliter

Examples

1
2
3
4
5
6
s <- c(0, 0, 1, NA, 2, 0, 1, 1, NA, NA, 2, NA, 3, 1, 2, 1, 0, 1, NA, 0, 0, 0)
plot(s, type="b", col="#00000088")
lines(iema(s, 2, dir="ff"), col=2)
lines(iema(s, 2, dir="fb"), col=3)
lines(iema(s, 2, dir="bf"), col=4)
lines(iema(s, 2, dir="av"), col=5)

AkselA/R-rollfun documentation built on May 31, 2019, 8:41 a.m.