Function forecasting::WeightedMovingAverage(dataValues, estimates, noObservations, weights, noAveragingPeriods, ErrorMeasures, Residuals)

# forecasting::WeightedMovingAverage

The weighted moving average procedure is a time series forecasting procedure. Essentially, this procedure forecasts by taking the weighted average over the last $$N$$ observations.

## Mathematical Formulation

Using the notation for observations and estimates given in Time Series Forecasting Notation, the estimates are defined as:

$\begin{split}e_t = \sum_{j=1,\tau=t-(N+1)+j}^N {w_j \tilde y}_\tau \mspace{4mu}\mspace{4mu}\mspace{4mu} \textrm{ where } {\tilde y}_\tau = \left\{ \begin{array}{ll} y_1 & \textrm{ if } \tau < 1 \\ y_\tau & \textrm{ if } \tau \in \{1 .. T \} \\ e_\tau & \textrm{ if } \tau > T \end{array} \right.\end{split}$

## Function Prototype

To provide the error measures and residuals only when you need them, there are three flavors of the WeightedMovingAverage procedure provided:

forecasting::WeightedMovingAverage(
! Provides the estimates,
! but not the error measures nor the residuals
dataValues,              ! Input, parameter indexed over time set
estimates,               ! Output, parameter indexed over time set
noObservations,          ! Scalar input, length history
weights,                 ! Input, parameter
noAveragingPeriods)      ! Scalar input, averaging length

forecasting::WeightedMovingAverageEM(
! Provides estimates and error measures, but not the residuals
dataValues,              ! Input, parameter indexed over time set
estimates,               ! Output, parameter indexed over time set
noObservations,          ! Scalar input, length history
weights,                 ! Input, parameter
noAveragingPeriods,      ! Scalar input, averaging length
ErrorMeasures)           ! Output, indexed over forecasting::ems

forecasting::WeightedMovingAverageEMR(
! Provides estimates, error measures, and residuals
dataValues,              ! Input, parameter indexed over time set
estimates,               ! Output, parameter indexed over time set
noObservations,          ! Scalar input, length history
weights,                 ! Input, parameter
noAveragingPeriods,      ! Scalar input, averaging length
ErrorMeasures,           ! Output, indexed over forecasting::ems
Residuals)               ! Output, parameter indexed over time set


Here, the time set is a set that encompasses both the history and the horizon.

## Arguments

dataValues

A one dimensional parameter containing the observations for the first $$T$$ elements of the time set.

estimates

A one dimensional parameter containing the estimates for all elements in the time set.

noObservations

Specifies the number of elements that belong to the history of the time set. This parameter corresponds to $$T$$ in the notation presented in Time Series Forecasting Notation.

weights

Specifies the weights. The weights should be indexed over a subset of Integers: $$\{ 1 .. N\}$$, in the range $$[0,1]$$ and sum to 1.

noAveragingPeriods

Specifies the number of values used to compute a single average. This parameter corresponds to $$N$$ in the mathematical notation above.

ErrorMeasures

The error measures as presented in Time Series Forecasting Notation.

Residuals

The residuals as presented in Time Series Forecasting Notation.

Note

In order to use this function, the Forecasting system library needs to be added to the application.