Class HarRv

java.lang.Object
com.quantfinlib.volatility.HarRv

public final class HarRv extends Object
HAR-RV (Corsi's Heterogeneous AutoRegressive realized-volatility model) — the forecasting benchmark GARCH papers have to beat, and it is three regressors and an intercept:
  RV_{t+1} = c + β_d·RV_t + β_w·RV̄_t^{(5)} + β_m·RV̄_t^{(22)} + ε
daily, weekly-average and monthly-average realized variance — the "heterogeneous" traders operating at three horizons (Corsi 2009, J. Financial Econometrics 7, 174-196). Fits by OLS through a Householder QR of the column-scaled design (the normal equations square a condition number that RV in 1e-4 units already makes large), reports Newey-West HAC standard errors, and forecasts one step ahead. forecast(double[], HarRv.Params) floors at zero; fitLog(double[]) fits the log-HAR, ln RV_{t+1} = c + β_d ln RV_t + β_w ln RV̄^{(5)} + β_m ln RV̄^{(22)}, which cannot forecast a negative variance and is the better-behaved specification on real data.

Feed it realized daily variance — squared returns summed intraday, or JumpRobustVolatility's bipower variance when jumps should not contaminate the forecast (the standard pairing). Static, deterministic, research lane.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    Fitted coefficients with Newey-West standard errors (order: intercept, daily, weekly, monthly), residual variance and the regression size.
    static final record 
    Fitted coefficients: rv⁺ = c + βd·d + βw·w + βm·m.
  • Method Summary

    Modifier and Type
    Method
    Description
    fit(double[] realizedVariance)
    Fits by OLS.
    static HarRv.Fit
    fitLog(double[] realizedVariance)
    Log-HAR: the same regression on ln RV with regressors ln RV_t, ln(mean of 5) and ln(mean of 22).
    static HarRv.Fit
    fitWithErrors(double[] realizedVariance)
    OLS fit of the level HAR with Newey-West standard errors (5 lags).
    static double
    forecast(double[] realizedVariance, HarRv.Params p)
    One-step-ahead RV forecast from the series' most recent day/week/ month, floored at zero.
    static double
    forecastLog(double[] realizedVariance, HarRv.Fit fit)
    One-step forecast of RV from a log-HAR fit: exp(ŷ + ½σ̂²), the lognormal mean given the residual variance.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • fit

      public static HarRv.Params fit(double[] realizedVariance)
      Fits by OLS. Needs enough history for the monthly window plus a meaningful regression sample.
      Parameters:
      realizedVariance - daily RV series, ≥ 60 finite non-negative observations
    • fitWithErrors

      public static HarRv.Fit fitWithErrors(double[] realizedVariance)
      OLS fit of the level HAR with Newey-West standard errors (5 lags).
    • fitLog

      public static HarRv.Fit fitLog(double[] realizedVariance)
      Log-HAR: the same regression on ln RV with regressors ln RV_t, ln(mean of 5) and ln(mean of 22). Requires strictly positive RV.
    • forecastLog

      public static double forecastLog(double[] realizedVariance, HarRv.Fit fit)
      One-step forecast of RV from a log-HAR fit: exp(ŷ + ½σ̂²), the lognormal mean given the residual variance.
    • forecast

      public static double forecast(double[] realizedVariance, HarRv.Params p)
      One-step-ahead RV forecast from the series' most recent day/week/ month, floored at zero.