| ts_fil_ema | R Documentation |
Smooth a series by exponentially decaying weights that give more importance to recent observations.
ts_fil_ema(ema = 3)
ema |
exponential moving average size |
EMA is related to simple exponential smoothing; it reacts faster to level changes than a simple moving average while reducing noise.
A ts_fil_ema object.
C. C. Holt (1957). Forecasting trends and seasonals by exponentially weighted moving averages. O.N.R. Research Memorandum.
# Exponential moving average smoothing on a noisy series
# Load package and example data
library(daltoolbox)
data(tsd)
# Inject an outlier to illustrate smoothing effect
tsd$y[9] <- 2 * tsd$y[9]
# Define EMA filter, fit and transform the series
filter <- ts_fil_ema(ema = 3)
filter <- fit(filter, tsd$y)
y <- transform(filter, tsd$y)
# Compare original vs smoothed series
plot_ts_pred(y = tsd$y, yadj = y)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.