apaVolatility.ExpWeighted.HalfLife.Calibrate(Returns, MinHalfLife, MaxHalfLife, InitialHalfLife, WarmupLength, RealizedVolWindow, WindowMode, RollingWindowLength)
=apaVolatility.ExpWeighted.HalfLife.Calibrate(Returns, MinHalfLife, MaxHalfLife, InitialHalfLife, WarmupLength, RealizedVolWindow, WindowMode, RollingWindowLength)Result
Calibrate the half‑life of an exponentially weighted volatility model by minimizing out‑of‑sample forecast loss, optionally across multiple return series in one call. The function returns, for each series, the optimal half‑life, the corresponding EWMA decay factor , the objective value, and optimization diagnostics. In EWMA volatility models, the decay factor controls the exponential down‑weighting of older returns, and half‑life is related to via .
Syntax
Returns: n x 1, 1 x n, or n x k matrix of arithmetic returns. If a matrix is passed, each column is treated as a separate series.
MinHalfLife: optional; lower bound for half-life, > 0. Default: 2.
MaxHalfLife: optional; upper bound for half-life, > MinHalfLife. Default: 250.
InitialHalfLife: optional; initial half-life guess. Default: 21.
WarmupLength: optional; minimum number of observations before the first forecast origin. Default: 60.
RealizedVolWindow: optional; forward realized-volatility window. Default: 5.
WindowMode: optional; 0 = Expanding, 1 = Rolling; default: 0
RollingWindowLength: optional; rolling estimation window length; used only if WindowMode = 1. Default: 60.
Algorithm
Accept returns as a vector, matrix of doubles, or Excel object matrix; validate there are no empty or missing cells and convert to a numeric array where each column is one return series.
For each series, call EWMACalibration.CalibrateHalfLife over the search interval [MinHalfLife, MaxHalfLife], starting from InitialHalfLife. The EWMA volatility model uses a decay factor with recursive form
and the calibration routine searches over half‑life (equivalently ) to minimize an out‑of‑sample forecast loss, such as realized volatility or next‑day squared return, given the chosen target.
An expanding or rolling estimation window is used (controlled by WindowMode and RollingWindowLength), with WarmupLength observations before the first forecast origin and RealizedVolWindow observations for the realized volatility computation.
The optimization uses internal settings for the perturbation scale, convergence tolerance, maximum number of evaluations, restarts and probe scale.
For each series, the following is returned:
HalfLife: calibrated half-life.
Lambda: decay factor corresponding to the calibrated half-life.
ObjectiveValue: minimized forecast-loss value.
EvaluationCount: number of function evaluations.
RestartCount: number of optimization restarts.
TerminationReason: reason the optimization stopped (e.g. converged, max evaluations).
This function allows you to empirically tune EWMA volatility decay to your data and chosen forecasting target, rather than relying on a fixed rule‑of‑thumb or half‑life.
Remarks
Exponentially weighted moments; the weights sum to one (population-type, no small-sample correction).
