movavg.RdDifferent types of moving average of a time series.
movavg(x, n, type=c("s", "t", "w", "m", "e", "r"))Types of available moving averages are:
s for “simple”, it computes the simple moving average.
n indicates the number of previous data points used with the
current data point when calculating the moving average.
t for “triangular”, it computes the triangular moving average
by calculating the first simple moving average with window width of
ceil(n+1)/2; then it calculates a second simple moving average
on the first moving average with the same window size.
w for “weighted", it calculates the weighted moving average
by supplying weights for each element in the moving window. Here the
reduction of weights follows a linear trend.
m for “modified", it calculates the modified moving average.
The first modified moving average is calculated like a simple moving
average. Subsequent values are calculated by adding the new value and
subtracting the last average from the resulting sum.
e for“exponential", it computes the exponentially weighted
moving average. The exponential moving average is a weighted moving
average that reduces influences by applying more weight to recent
data points () reduction factor 2/(n+1); or
r for“running", this is an exponential moving average with a
reduction factor of 1/n [same as the modified average?].
Vector the same length as time series x.
Matlab Techdoc
filter