Add HAR model for realized volatility (Corsi 2009)#855
Open
hass-nation wants to merge 1 commit into
Open
Conversation
Implements the Heterogeneous Autoregressive (HAR-RV) model as a standalone OLS estimator in arch/univariate/har.py, with Newey-West HAC standard errors, multi-step forecasting, and a text summary table. 29 tests added in arch/tests/test_har.py covering params, R-squared, fitted values, forecasting, custom lags, input validation, and numerical equivalence with manual OLS. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #855 +/- ##
==========================================
- Coverage 99.54% 99.53% -0.01%
==========================================
Files 78 80 +2
Lines 15818 16154 +336
Branches 1294 1315 +21
==========================================
+ Hits 15746 16079 +333
- Misses 38 39 +1
- Partials 34 36 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Owner
|
This PR makes no sense. There is already a mean HAR which works as expected for RV. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
HAR(Heterogeneous Autoregressive model for realized volatility), the standard workhorse model for forecasting realized variance in high-frequency financial econometrics (Corsi 2009, JFE).The model regresses today's realized variance on daily, weekly, and monthly rolling averages of past realized variance:
RV_t = c + β_d·RV_{t-1} + β_w·RV̄_{t-1:t-5} + β_m·RV̄_{t-1:t-22} + ε_t
Estimation is OLS with optional Newey-West HAC standard errors.
Interface
New file
arch/univariate/har.py—HARandHARResultclassesHARResult attributes
params/param_names— OLS coefficientsrsquared— R²pvalues,std_errors,tvalues— HAC-robust inferencepredict(start, end)— in-sample fitted valuesforecast(horizon)— recursive multi-step forecastsummary()— formatted text tableTests
29/29 pass (
arch/tests/test_har.py). Coverage: params shape, R² range, fitted-values shape, multi-step forecast, p-values in [0,1], custom lags, HAC vs OLS SEs, manual OLS verification.Reference
Corsi, F. (2009). A Simple Approximate Long-Memory Model of Realized Volatility. Journal of Financial Econometrics, 7(2), 174–196.