# NxSMA - Seasonal Moving-average Filter

Computes Seasonal (aka. double) moving average (aka. KxM MA).

## Syntax

NxCMA(X, Order, KN, EndPoints)
X
is the univariate time series data (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)
K
is the number of terms (aka points) of the second moving average filter. If missing, K is assumed 1.
M
is the number of terms (aka points) in first moving average filter (e.g. seasonal length). If missing or omitted, N is assumed 1.
EndPoints
is a logical value for applying asymmetric weights at the end of the series. If missing or omitted, Endpoints = False, and no treatment for end points is performed.

## 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 NxSMA returns an array-type value back to Excel. User must use CTRL+ALT+ENTER to show returned values.
4. The number of terms (i.e. K+N-1) in NxSMA must be an odd-number. In effect, K and N can be either both odd-numbers or both even numbers.
5. In practice, the NxSMA is known as double moving average filter: which combines two MA to form a symmetric two-sided moving average filter.
6. Why use NxSMA? When working with time series you often smooth to remove seasonality effects, which requires period (aka moving window) to be equal to seasonal length, which is often an even number, for example, 12 months or 4 quarters. In this case, we use double moving average (e.g. 2x4 for quarterly data, or 2x12 for monthly data, etc.).
7. Mathematically, the order in which the MA filters are applied does not matter, and they will return the same results. For our application,
8. The weights or the multiplying factors of the NxSMA filter are derived, by taking the convolution of the two moving average filters ( K-MA and N-MA).
9. The weights or the mutiplying factors of the NxSMA are calculated as follow: $$w_j=\left\{\begin{matrix} \frac{j}{K\times M} & j < K\\ \frac{1}{M}& K \leq j \leq M\\ \frac{M+K-j}{K\times M} & M+K > j > M \end{matrix}\right.$$
10. By definition, the sum of all weights in the SMA is equal to one(1).
11. The NxSMA function is available starting with version 1.66 PARSON.