mfe.univariate¶
mfe.univariate ¶
mfe.univariate — Univariate time series models.
Note: ARCH/GARCH/EGARCH/FIGARCH/APARCH are in the arch package (Kevin Sheppard).
This module provides:
har_rv HAR-RV with vector and matrix interval notation, NW SEs
har_rv_j HAR-RV-J with jump component
har_forecast Multi-step point forecast from fitted HAR
HEAVY Joint model of returns and realized variance (Shephard & Sheppard 2010)
HARResult
dataclass
¶
HARResult(params: FloatArray, std_errors: FloatArray, t_stats: FloatArray, p_values: FloatArray, r_squared: float, r_squared_adj: float, residuals: FloatArray, fitted: FloatArray, n_obs: int, bandwidth: int, param_names: list[str] = list(), spec: str = 'standard', intervals: list[tuple[int, int]] = list())
HAR-RV estimation result.
HEAVY ¶
HEAVY model — joint model of returns and realized variance.
Shephard & Sheppard (2010). Not available in the arch package (stubbed
but never completed as of 2026).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
realized_measure
|
'rv' | 'bpv' | 'kernel'
|
Which realized measure to use (informational, does not change estimation). |
'rv'
|
Source code in src/mfe/univariate/heavy.py
fit ¶
fit(returns: FloatArray, realized: FloatArray, starting_values: FloatArray | None = None, method: str = 'L-BFGS-B', options: dict | None = None) -> HEAVYResult
Estimate HEAVY by joint QML.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
returns
|
FloatArray
|
|
required |
realized
|
(T,) daily realized variance series (same frequency)
|
|
required |
Source code in src/mfe/univariate/heavy.py
forecast ¶
forecast(result: HEAVYResult, horizon: int = 1, last_realized: float | None = None) -> tuple[FloatArray, FloatArray]
Multi-step ahead forecasts of h_r and h_rm.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
HEAVYResult
|
|
required |
horizon
|
int
|
|
1
|
last_realized
|
float | None
|
|
None
|
Returns:
| Type | Description |
|---|---|
(h_r_forecast, h_rm_forecast) — both (horizon,) arrays
|
|
Source code in src/mfe/univariate/heavy.py
HEAVYResult
dataclass
¶
HEAVYResult(params: FloatArray, log_likelihood: float, h_returns: FloatArray, h_realized: FloatArray, residuals_r: FloatArray, residuals_rm: FloatArray, converged: bool, n_obs: int, diagnostics: dict = dict())
HEAVY model estimation result.
har_rv ¶
har_rv(rv: FloatArray, p=(1, 5, 22), horizon: int = 1, nw_lags: int | None = None, spec: str = 'standard') -> HARResult
HAR-RV estimation by OLS with Newey-West standard errors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rv
|
FloatArray
|
|
required |
p
|
|
(1, 5, 22)
|
|
horizon
|
forecast horizon h (LHS is h-day forward average)
|
|
1
|
nw_lags
|
Newey-West bandwidth; None => 2*horizon
|
|
None
|
spec
|
str
|
|
'standard'
|
Source code in src/mfe/univariate/har.py
har_rv_j ¶
har_rv_j(rv: FloatArray, jump: FloatArray, p=(1, 5, 22), horizon: int = 1, nw_lags: int | None = None) -> HARResult
HAR-RV-J: HAR augmented with a jump component.
Andersen, Bollerslev & Diebold (2007). The jump regressor is the daily jump contribution J_t = max(RV_t - BPV_t, 0).
Source code in src/mfe/univariate/har.py
har_forecast ¶
Multi-step HAR-RV point forecast.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
HARResult
|
|
required |
last_rv
|
FloatArray
|
|
required |
horizon
|
int
|
|
1
|
Returns:
| Type | Description |
|---|---|
(horizon,) forecast array
|
|
Source code in src/mfe/univariate/har.py
har ¶
HAR-RV model and extensions.
Corsi, F. (2009): "A Simple Approximate Long-Memory Model of Realized Volatility", JFEC.
Extensions vs. original har.py
- Matrix interval notation: P=[[1,1],[2,5],[6,22]] (non-overlapping intervals)
- MODIFIED spec: non-overlapping reparameterisation (same fit, different interp)
- HAR-RV-J: jump-augmented HAR
- har_forecast: multi-step point forecast from fitted result
HARResult
dataclass
¶
HARResult(params: FloatArray, std_errors: FloatArray, t_stats: FloatArray, p_values: FloatArray, r_squared: float, r_squared_adj: float, residuals: FloatArray, fitted: FloatArray, n_obs: int, bandwidth: int, param_names: list[str] = list(), spec: str = 'standard', intervals: list[tuple[int, int]] = list())
HAR-RV estimation result.
har_rv ¶
har_rv(rv: FloatArray, p=(1, 5, 22), horizon: int = 1, nw_lags: int | None = None, spec: str = 'standard') -> HARResult
HAR-RV estimation by OLS with Newey-West standard errors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rv
|
FloatArray
|
|
required |
p
|
|
(1, 5, 22)
|
|
horizon
|
forecast horizon h (LHS is h-day forward average)
|
|
1
|
nw_lags
|
Newey-West bandwidth; None => 2*horizon
|
|
None
|
spec
|
str
|
|
'standard'
|
Source code in src/mfe/univariate/har.py
har_rv_j ¶
har_rv_j(rv: FloatArray, jump: FloatArray, p=(1, 5, 22), horizon: int = 1, nw_lags: int | None = None) -> HARResult
HAR-RV-J: HAR augmented with a jump component.
Andersen, Bollerslev & Diebold (2007). The jump regressor is the daily jump contribution J_t = max(RV_t - BPV_t, 0).
Source code in src/mfe/univariate/har.py
har_forecast ¶
Multi-step HAR-RV point forecast.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
HARResult
|
|
required |
last_rv
|
FloatArray
|
|
required |
horizon
|
int
|
|
1
|
Returns:
| Type | Description |
|---|---|
(horizon,) forecast array
|
|
Source code in src/mfe/univariate/har.py
heavy ¶
HEAVY (High frEquency bAsed VolatilitY) model.
Shephard, N. & Sheppard, K. (2010): "Realising the Future: Forecasting with High-Frequency-Based Volatility (HEAVY) Models", Journal of Applied Econometrics, 25(2), 197-231.
Model specification
The HEAVY model jointly models daily returns r_t and realized measures RM_t (e.g. realized variance) using two equations:
h_{r,t} = omega_r + alpha_r * RM_{t-1} + beta_r * h_{r,t-1} h_{RM,t} = omega_RM + alpha_RM * RM_{t-1} + beta_RM * h_{RM,t-1}
where h_{r,t} is the conditional variance of returns and h_{RM,t} is the conditional mean of the realized measure.
The second equation is a separate GARCH-like model for RM itself.
Estimation: joint QML assuming: r_t | F_{t-1} ~ N(0, h_{r,t}) RM_t | F_{t-1} ~ Gamma(nu, nu / h_{RM,t}) (variance = h_{RM,t}^2 / nu)
The joint log-likelihood is: L = L_r + L_RM L_r = -0.5 * sum_t [log(h_{r,t}) + r_t^2 / h_{r,t}] L_RM = -0.5 * nu * sum_t [log(h_{RM,t}) + RM_t/h_{RM,t} - log(RM_t/h_{RM,t}) - 1] (Gamma log-likelihood in terms of scale; simplified constant dropped)
This is the model that arch partially stubs (ResearchModel) but never completes.
Key innovation vs. standard GARCH
By using realized measures in the variance equation, HEAVY produces forecasts that update faster: when overnight volatility is high (RM_{t-1} large), h_{r,t} responds immediately rather than waiting for the squared return signal.
Reference implementation cross-check
MATLAB mfe-toolbox: heavy.m The MATLAB version computes analytic gradients. We compute numerical gradients via scipy; analytic scores are a future optimization.
HEAVYResult
dataclass
¶
HEAVYResult(params: FloatArray, log_likelihood: float, h_returns: FloatArray, h_realized: FloatArray, residuals_r: FloatArray, residuals_rm: FloatArray, converged: bool, n_obs: int, diagnostics: dict = dict())
HEAVY model estimation result.
HEAVY ¶
HEAVY model — joint model of returns and realized variance.
Shephard & Sheppard (2010). Not available in the arch package (stubbed
but never completed as of 2026).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
realized_measure
|
'rv' | 'bpv' | 'kernel'
|
Which realized measure to use (informational, does not change estimation). |
'rv'
|
Source code in src/mfe/univariate/heavy.py
fit ¶
fit(returns: FloatArray, realized: FloatArray, starting_values: FloatArray | None = None, method: str = 'L-BFGS-B', options: dict | None = None) -> HEAVYResult
Estimate HEAVY by joint QML.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
returns
|
FloatArray
|
|
required |
realized
|
(T,) daily realized variance series (same frequency)
|
|
required |
Source code in src/mfe/univariate/heavy.py
forecast ¶
forecast(result: HEAVYResult, horizon: int = 1, last_realized: float | None = None) -> tuple[FloatArray, FloatArray]
Multi-step ahead forecasts of h_r and h_rm.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
HEAVYResult
|
|
required |
horizon
|
int
|
|
1
|
last_realized
|
float | None
|
|
None
|
Returns:
| Type | Description |
|---|---|
(h_r_forecast, h_rm_forecast) — both (horizon,) arrays
|
|