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

- The time series is homogeneous or equally spaced.
- The time series may include missing values (e.g. #N/A) at either end.
- 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).

- 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.

- 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$

- 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}}.}$

- The NxMA function is available starting with version 1.66 PARSON.

## Files Examples

## Related Links

## References

- R.J. Hyndman, A.B. Koehler, "Another look at measures of forecast accuracy", International Journal of Forecasting, 22 (2006), pp. 679-688
- James Douglas Hamilton; Time Series Analysis; Princeton University Press; 1st edition(Jan 11, 1994), ISBN: 691042896
- Tsay, Ruey S.; Analysis of Financial Time Series; John Wiley & SONS; 2nd edition(Aug 30, 2005), ISBN: 0-471-690740
- D. S.G. Pollock; Handbook of Time Series Analysis, Signal Processing, and Dynamics; Academic Press; Har/Cdr edition(Nov 17, 1999), ISBN: 125609906

## Comments

Please sign in to leave a comment.