Time Series Analysis (Moving Average Filters)
Description
This article describes several filters for the analysis of time series data, including:
- Simple Moving Average (SMA)
- Exponential Moving Average (EMA)
- Linear Regression Moving Average (LRMA)
Model theory
Simple moving average
The simple moving average (SMA) at element of a data series is the unweighted mean of the previous values, or the previous values if .[1] That is:
where are the data points to average.
Exponential moving average
The Exponential Moving Average (EMA), or exponential smoothing, of a data series at element is:[2]
where is the smoothing factor.
Linear regression moving average
A Linear Regression Moving Average (LRMA) fits a straight line to a moving window of data points with width .
The LRMA at element over the window of elements is calculated from:
where (intercept) and (slope) are determined by minimising the sum of squared residuals of the data points .
The coefficients and can be directly calculated from:[3]
for and .
The Linear Regression Moving Average method may alternatively be referred to as the Least Squares Moving Average.
Excel
The Simple Moving Average (SMA) filter may be invoked from the Excel formula bar with the following function calls:
=mdTimeSeries_SMA(TimeSeriesData as Range, k as Integer)
Invoking the function with no arguments will print Help text associated with the model, including a link to this page.
The input parameters and calculation results are defined below in matrix notation, along with an example image showing the selection of the same cells and arrays in the Excel interface:
|
The Exponential Moving Average (EMA) filter may be invoked from the Excel formula bar with the following function calls:
=mdTimeSeries_EMA(TimeSeriesData as Range, alpha as Double)
Invoking the function with no arguments will print Help text associated with the model, including a link to this page.
The input parameters and calculation results are defined below in matrix notation, along with an example image showing the selection of the same cells and arrays in the Excel interface:
|
The Linear Regression Moving Average (LRMA) filter may be invoked from the Excel formula bar with the following function calls:
=mdTimeSeries_LRMA(TimeSeriesData as Range, k as Integer)
Invoking the function with no arguments will print Help text associated with the model, including a link to this page.
The input parameters and calculation results are defined below in matrix notation, along with an example image showing the selection of the same cells and arrays in the Excel interface:
|
References
- ↑ Wikipedia Contributors (2024). Moving average. [online] Wikipedia. Available at: https://en.wikipedia.org/wiki/Moving_average [Accessed 8 Jun. 2024].
- ↑ Wikipedia Contributors (2024). Exponential smoothing. [online] Wikipedia. Available at: https://en.wikipedia.org/wiki/Exponential_smoothing [Accessed 8 Jun. 2024].
- ↑ Wikipedia Contributors (2024). Simple linear regression. [online] Wikipedia. Available at: https://en.wikipedia.org/wiki/Simple_linear_regression [Accessed 8 Jun. 2024].