ema | R Documentation |
Smoothes a series by means of an exponential moving average. If x is an input series and y is the output filtered series, then:
y[i] = alpha * x[i] + (1-alpha) * y[i-1]
ema(x, alpha, miss = "reset")
x |
Input time-series as a vector. |
alpha |
Smoothing parameter, lower values have a greater smoothing effect. |
miss |
How to handle missing data. When 'reset' is used and x[i] is NA then y[i] is also NA. On the next non-NA value, j, then the rolling average is reset by using the current input, i.e. x[j] = alpha * x[j] + (1-alpha) * x[j] With 'carry' then the last non-NA value is carried over and used instead, i.e. if x = [1, NA, 3] then y[3] = alpha * 3 + (1-alpha) * y[1] 'carry_interpolate' is the same as 'carry' except that the previous non-NA value is also output from the filter. I.e. with x = [1, NA, 3], then under 'carry' y[2] = NA but under 'carry_interpolate' y[2] = 1 |
A filtered time-series the same length as x.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.