GARCH
chronax.models.GARCH · inherits BaseForecaster
Models time-varying volatility where conditional variance depends on past squared errors and past conditional variances.
Instance Attributes:
| Attribute | Type | Description |
|---|---|---|
p |
int |
ARCH order (lagged squared shocks). |
q |
int |
GARCH order (lagged variances). |
alias |
str |
Display name for the model (e.g., GARCH(1,1)). |
conformal_params |
ConformalIntervals \| None |
Configuration for conformal prediction intervals. |
allow_extended_iterations |
bool |
If True, allows up to 120 iterations for complex data. |
iteration_scaling |
str |
'cubic' or 'quadratic' complexity-to-iteration mapping. |
uses_exog |
bool |
False (Model does not use exogenous variables). |
model_ |
dict |
Fitted model state, including omega, alpha, beta, sigma2 (conditional variance series), fitted, y_mean, and state variables for forecasting (y_centered_last, sigma2_last, init_var). |
__init__(self, p=1, q=1, alias='GARCH', conformal_params=None, allow_extended_iterations=False, iteration_scaling='cubic')
Initialize GARCH model with ARCH/GARCH orders and optimization settings.
| Parameter | Type | Default | Description |
|---|---|---|---|
p |
int |
1 |
ARCH order (lagged squared shocks), must be >= 1. |
q |
int |
1 |
GARCH order (lagged variances), must be >= 0. |
alias |
str |
"GARCH" |
Display name for the model. |
conformal_params |
ConformalIntervals \| None |
None |
Configuration for conformal prediction intervals. |
allow_extended_iterations |
bool |
False |
If True, allows up to 120 iterations for complex data. |
iteration_scaling |
str |
"cubic" |
Complexity-to-iteration mapping: 'cubic' or 'quadratic'. |
fit(self, y, X=None, n_iters=None, actual_len=None) -> Self
Fit GARCH model to data.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
y |
jnp.ndarray |
- | Input time series (may be padded). |
X |
jnp.ndarray \| None |
None |
Exogenous variables (unused). |
n_iters |
int \| None |
None |
Fixed iteration count. None estimates from data. |
actual_len |
int \| None |
None |
Actual data length for padded inputs. |
Returns: Self (the fitted forecaster; sets self.model_).
predict(self, h, X=None, level=None, simulate=False, n_sims=1000, seed=None, return_paths=True) -> dict
Generate h-step forecasts (deterministic or Monte Carlo).
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
h |
int |
- | Forecast horizon. |
X |
jnp.ndarray \| None |
None |
Exogenous variables (unused). |
level |
list[int] \| None |
None |
Confidence levels for prediction intervals. When simulate=False, intervals are analytical (normal quantiles). When simulate=True, intervals are percentile-based from simulation paths. |
simulate |
bool |
False |
Use Monte Carlo simulation instead of analytical forecasting. |
n_sims |
int |
1000 |
Number of simulation paths (only used when simulate=True). |
seed |
int \| None |
None |
PRNG seed for reproducibility (only used when simulate=True). |
return_paths |
bool |
True |
Include full simulation paths in output (only used when simulate=True). |
Returns: dict
When simulate=False: Keys: 'mean', 'sigma2', and optionally 'lo-{lv}', 'hi-{lv}'.
When simulate=True: Keys: 'mean', 'median', 'sigma2_mean', 'sigma2_median', and optionally 'paths', 'sigma2_paths', 'lo-{lv}', 'hi-{lv}'.
predict_in_sample(self, level=None) -> dict
Return in-sample fitted values and conditional variance.
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
level |
list[int] \| None |
None |
Confidence levels for fitted prediction intervals. |
Returns: dict
Keys: 'fitted', 'sigma2', and optionally 'fitted-lo-{lv}', 'fitted-hi-{lv}'.
forecast(self, y, h, X=None, X_future=None, level=None, fitted=False, n_iters=None, actual_len=None, simulate=False, n_sims=1000, seed=None, return_paths=True) -> dict
Stateless fit-and-predict (deterministic or Monte Carlo).
Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
y |
jnp.ndarray |
- | Input time series (may be padded). |
h |
int |
- | Forecast horizon. |
X |
jnp.ndarray \| None |
None |
Exogenous variables (unused). |
X_future |
jnp.ndarray \| None |
None |
Future exogenous variables (unused). |
level |
list[int] \| None |
None |
Confidence levels for prediction intervals. When simulate=True, forecast intervals are percentile-based from paths, while fitted intervals remain analytical. |
fitted |
bool |
False |
Whether to return in-sample fitted values. |
n_iters |
int \| None |
None |
Fixed iteration count. None estimates from data. |
actual_len |
int \| None |
None |
Actual data length for padded inputs. |
simulate |
bool |
False |
Use Monte Carlo simulation instead of analytical forecasting. |
n_sims |
int |
1000 |
Number of simulation paths (only used when simulate=True). |
seed |
int \| None |
None |
PRNG seed for reproducibility (only used when simulate=True). |
return_paths |
bool |
True |
Include full simulation paths in output (only used when simulate=True). |
Returns: dict
Keys: 'mean', 'sigma2', and optionally intervals and fitted values. When simulate=True, also includes 'median', 'sigma2_mean', 'sigma2_median', and optionally 'paths', 'sigma2_paths'.