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

Popular posts from this blog

node.js - How to mock a third-party api calls in the backend -

node.js - Why do I get "SOCKS connection failed. Connection not allowed by ruleset" for some .onion sites? -

matlab - 0-by-1 sym - What do I need to change in order to get proper symbolic results? -