HarRvModel<T>
Models & Types · AiDotNet.Finance.Volatility
HAR-RV — the Heterogeneous AutoRegressive model of Realized Volatility (Corsi, 2009, “A Simple Approximate Long-Memory Model of Realized Volatility”, Journal of Financial Econometrics 7(2)).
Inheritance: RegressionBase<T> → HarRvModel<T>
For Beginners
Volatility clusters and has “long memory” — calm and turbulent stretches persist. HAR-RV predicts tomorrow’s variance from how volatile the last day, last week, and last month were, fit by plain least-squares. Simple, robust, and hard to beat.
How It Works
HAR-RV forecasts next-period realized variance as a linear function of realized variance averaged over three horizons — daily, weekly (5), and monthly (22) — capturing volatility’s long-memory with a simple regression:
Corsi estimates this by ordinary least squares, so this model extends RegressionBase
(AiDotNet’s classical OLS base) rather than the neural model base — faithful to the paper’s estimator.
It is the canonical baseline for the one signal the platform found rigorously predictable (volatility),
and produces the forecast realized vol consumed by the vol-edge options strategy.
Constructors
| Constructor | Summary |
|---|---|
HarRvModel(RegressionOptions<T> options, IRegularization<T, Matrix<T>, Vector<T>> regularization) |
Creates a HAR-RV model. |
Methods
| Method | Summary |
|---|---|
T ForecastAnnualizedVol(IReadOnlyList<T> realizedVariance, double periodsPerYear) |
Forecasts next-period ANNUALIZED realized vol = √(variance × periodsPerYear). |
T ForecastNextVariance(IReadOnlyList<T> realizedVariance) |
Forecasts next-period realized VARIANCE from the latest history. |
T ForecastVolFromReturns(IReadOnlyList<T> returns, double periodsPerYear) |
Convenience: fit + forecast annualized vol straight from a per-period RETURN series, using squared returns as the realized-variance proxy (RV_t = r_t²). |
ValueTuple<Matrix<T>, Vector<T>> BuildHarDesign(IReadOnlyList<T> realizedVariance) |
Builds the HAR design from a realized-variance series: each row is [RV_t, mean(RV over last 5), mean(RV over last 22)] and the target is RV_{t+1}. |
void FitRealizedVariance(IReadOnlyList<T> realizedVariance) |
Fits directly on a realized-variance series (builds the HAR design, then OLS). |
void Train(Matrix<T> x, Vector<T> y) |
Fits the HAR coefficients by OLS (normal equations) — the estimator in Corsi (2009). |
Fields
| Field | Summary |
|---|---|
int MonthlyWindow |
Monthly aggregation horizon (trading days) from Corsi (2009). |
int WeeklyWindow |
Weekly aggregation horizon (trading days) from Corsi (2009). |