r - EMA in the TTR package, when vector length = n, EMA = mean regardless of smoothing ratio (which becomes irrelevant)? -
i'm pretty confused on why works way.
> x <- c(1,2,3) > ema <- ema(x, n=3) > ema [1] na na 2 > ema <- ema(x, n=3, ratio= .3) > ema [1] na na 2 > ema <- ema(x, n=2, ratio= .3) > ema [1] na 1.50 1.95 > ema <- ema(x, n=2) > ema [1] na 1.5 2.5
so when n
equal length of vector, ema = mean, , smoothing ratio irrelevant? not getting @ all.
the first non-na value occur @ observation n
, equal arithmetic mean of first n
observations. exponential smoothing begin @ point.
the ratio
argument specifies decay, , not change when first non-na observation occurs.
regardless, exponential smoothing unstable until have 3 times data smoothing ratio implies. example, n=10
(ratio=2/(10+1)
), need 30 observations before exponential moving average stabilizes. see warning , examples sections of ?ema
.
Comments
Post a Comment