NxMA - Moving (rolling) average using prior data points

Returns the moving (rolling/running) average using the previous m data points.

 

Syntax

NxMA(X, Order, N, Variant, Return)

X is the univariate time series data (a one-dimensional array of cells (e.g. rows or columns)).

Order is the time order in the data series (i.e. the first data point's corresponding date (earliest date=1 (default), latest date=0))

Order Description
1 ascending (the first data point corresponds to the earliest date) (default)
0 descending (the first data point corresponds to the latest date)

N is the number of data points (e.g. days) in a given period.

Variant is the variant/type of the moving average (i.e. 0= Simple (default), 1= Cumulative, 2=Modified, 3=Weighted). If missing or omitted, a simple moving average (i.e. Variant = 0) is assumed.

Value Description
0 Simple moving average (SMA)
1 Cumulative moving average (CMA)
2 Modified moving average (MMA)
3 Weighted moving average where weights decrease in arithmetic progression

Return is return type of the function: 0 = last/most recent value (default), 1 = filtered time series (array.

Value Description
0 Return smoothed value of the Last/most-recent observation
1 Return the whole smoothed time series (array)
 

Remarks

  1. The time series is homogeneous or equally spaced.
  2. The time series may include missing values (e.g. #N/A) at either end.
  3. The simple moving average (SMA) is given by: $$ \textrm{SMA}_t = \frac{\sum_{i=0}^N x_{t-i}}{N}$$ Where:
    • $\textrm{SMA}_t$ is the simple moving average value at time t
    • $x_t$ is the value of the time series at time t
    • $N$ is the rolling window size (aka. number of points in the moving average).
  4. The cumulative moving average (CMA) is defined as follow: $$ \textrm{CMA}_t = \frac{\sum_{i=1}^t x_i}{t}$$ Where:
    • $\textrm{CMA}_t$ is the cumulative moving average value at time t
    • $t$ is the given time.
    • CMA is basically the average of all of the data points up until the current datum point.
  5. The Modified moving average (MMA) is given as follow: $$ \textrm{MMA}_t = \frac{(N-1)\times \textrm{MMA}_{t-1}+x_t}{N}$$ Where:
    • $\textrm{MMA}_t$ is the modified moving average at time t.
    • $N$ is the rolling window size (aka. number of points in the moving average).
    • The MMA is also known as rolling-moving average (RMA), or smoothing moving average (SMMA).
    • The MMA is basically a simple exponential smoothing with $\alpha = 1/N$
  6. The weighted moving average (WMA) has weights that decrease in arithematic progression. The WMA can be expressed as follow: $$ \textrm{WMA}_t = \frac{N x_t + (N-1)x_{t-1} + (N-2) x_{t-2} + \cdots + 2 x_{t-N+2} + x_{t-N+1}}{N + (N-1) + (N-2) + \cdots + 2 + 1} $$ Where
    • $\textrm{WMA}_t$ is the weighted moving average value at time t.
    • $x_t$ is the value of the time series at time t
    • $N$ is the rolling window size (i.e. number of data points in the average).
    • The denominator is a triangle number equal to ${\displaystyle {\frac {N(N+1)}{2}}.}$
  7. The NxMA function is available starting with version 1.66 PARSON.

Files Examples

References

Have more questions? Submit a request

0 Comments