Esc
Ask AIAnswers may be inaccurate; check the linked pages.Esc
Ask anything about these docs, like how to get started or what a function does.

GARCH

garch.GARCH ยท inherits BaseForecaster

Models time-varying volatility where conditional variance depends on past squared errors and past conditional variances.

GARCH implements the BaseForecaster contract.

__init__(self, p: int = 1, q: int = 1, alias: str = 'GARCH', conformal_params: ConformalIntervals | None = None, allow_extended_iterations: bool = False, iteration_scaling: str = 'cubic')

Initialize 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'.

Attributes: * uses_exog: False

fit(self, y: jnp.ndarray, X: jnp.ndarray | None = None, n_iters: int | None = None, actual_len: int | None = None) -> GARCH

Fit GARCH model to data.

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: GARCH (the fitted model; sets self.model_).

predict(self, h: int, X: jnp.ndarray | None = None, level: list[int] | None = None, simulate: bool = False, n_sims: int = 1000, seed: int | None = None, return_paths: bool = True) -> dict

Generate h-step forecasts (deterministic or Monte Carlo).

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: list[int] | None = None) -> dict

Return in-sample fitted values and conditional variance.

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: jnp.ndarray, h: int, X: jnp.ndarray | None = None, X_future: jnp.ndarray | None = None, level: list[int] | None = None, fitted: bool = False, n_iters: int | None = None, actual_len: int | None = None, simulate: bool = False, n_sims: int = 1000, seed: int | None = None, return_paths: bool = True) -> dict

Stateless fit-and-predict (deterministic or Monte Carlo).

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'.