API reference¶
Models¶
- class pymgarch.DCC(dist: str = 'norm')[source]¶
Engle (2002) scalar DCC(1,1) with correlation targeting.
- class pymgarch.ADCC(dist: str = 'norm')[source]¶
Cappiello-Engle-Sheppard (2006) scalar asymmetric DCC.
- class pymgarch.CCC(dist: str = 'norm')[source]¶
Bollerslev (1990) constant conditional correlation.
dist=”t” adds a multivariate Student-t likelihood with the degrees of freedom estimated by one-dimensional MLE at the fixed correlation.
- class pymgarch.GOGARCH(dist: str = 'normal')[source]¶
GO-GARCH with ICA rotation and arch GARCH factors.
dist: factor innovation distribution, passed to the factor spec (“normal” default; “t” gives Student-t factors).
- class pymgarch.CopulaGARCH(copula: str = 'gaussian', dynamics: str = 'dcc', margins: str = 'parametric')[source]¶
Gaussian or Student-t copula over arch marginals.
copula: “gaussian” or “t”. dynamics: “dcc” (scalar symmetric DCC on the copula shocks) or “static”. margins: “parametric” (PIT through the fitted arch distributions; Normal and Student-t supported) or “empirical” (rank-based).
Standard errors: computed for dynamics=”dcc” with parametric margins via the same two-stage sandwich as DCC, with the correlation target held fixed at its point estimate (the same convention as the DCC sandwich and rmgarch). For other configurations compute_se downgrades to a warning: the empirical PIT is rank-based (not differentiable in the marginal parameters) and static-copula SEs are not implemented.
Targeting: the DCC recursion on the copula shocks targets their centered covariance (rmgarch’s cgarch convention, Qbar = cov(Z)), which is what the replication fixtures validate against.
- class pymgarch.BEKK(variant: str = 'scalar')[source]¶
Scalar or diagonal BEKK with variance targeting, Gaussian QML.
- class pymgarch.BEKKResult(variant: 'str', names: 'list[str]', index: 'pd.Index', mu: 'np.ndarray', Sigma: 'np.ndarray', avec: 'np.ndarray', bvec: 'np.ndarray', H: 'np.ndarray', loglikelihood: 'float', llt: 'np.ndarray', vcov: 'np.ndarray | None' = None, se: 'np.ndarray | None' = None, se_method: 'str | None' = None, converged: 'bool' = True, message: 'str' = '', filtered: 'bool' = False)[source]¶
- forecast(horizon: int = 1) MGARCHForecast[source]¶
Closed-form covariance forecasts.
E[H_{T+1}] is deterministic; for h >= 2, E[H_{T+h}] = C + M o E[H_{T+h-1}] with M = a a’ + b b’. Returns an MGARCHForecast (variances/correlations/covariances), matching the family-wide forecast contract. Filtered results forecast from their own (updated) terminal state.
Marginals¶
- class pymgarch.UnivariateSpec(mean: str = 'Constant', vol: str = 'GARCH', p: int = 1, o: int = 0, q: int = 1, power: float = 2.0, dist: str = 'normal')[source]¶
Thin declarative wrapper over arch_model for stage-1 fitting.
vol=”GARCH” with o > 0 is GJR-GARCH in arch’s parameterization.
- class pymgarch.MarginalSet(results: list[ARCHModelResult], names: list[str])[source]¶
A cross-section of fitted univariate marginals with aligned samples.
- filter_new_data(i: int, y: ndarray)[source]¶
(resids, sigma) on a new series using marginal i’s fitted params.
Only Constant and Zero conditional means are supported: for anything else the residual construction depends on arch internals tied to the estimation sample.
- garch_family(i: int)[source]¶
(vol_params, p, o, q) if marginal i is squared-power GARCH/GJR, else None.
- mean_offset(i: int) float[source]¶
Unconditional mean used when simulating returns (Constant/Zero only).
Results¶
- class pymgarch.MGARCHResult(model: 'str', dist: 'str', names: 'list[str]', index: 'pd.Index', sigma: 'np.ndarray', eps: 'np.ndarray', R: 'np.ndarray', logdet: 'np.ndarray', quad: 'np.ndarray', Sbar: 'np.ndarray', Nbar: 'np.ndarray', psi: 'np.ndarray', psi_names: 'list[str]', layout: 'ParamLayout | None', loglikelihood: 'float', llt: 'np.ndarray', q_last: 'np.ndarray | None' = None, mset: 'MarginalSet | None' = None, vcov: 'np.ndarray | None' = None, se: 'np.ndarray | None' = None, se_method: 'str | None' = None, converged: 'bool' = True, message: 'str' = '', filtered: 'bool' = False, extras: 'dict' = <factory>)[source]¶
- filter(returns) MGARCHResult[source]¶
Apply fitted parameters to a new return sample (no re-estimation).
Uses the fitted correlation targets Sbar/Nbar and Q_1 = Sbar.
- news_impact(pair: tuple[int, int] = (0, 1), kind: str = 'correlation', grid: ndarray | None = None) dict[source]¶
News-impact surface of the one-step correlation or covariance.
Shocks eps_i = x, eps_j = y (all other assets at zero) hit the recursion at its unconditional state Q = Sbar, rmgarch’s nisurface convention. Returns {“x”, “y”, “z”} with z[k, l] the response at (x[k], y[l]). kind=”covariance” scales by the mean conditional volatilities of the pair.
Simulation¶
- pymgarch.simulate_dcc(vol_params: list[dict], a: float, b: float, Sbar: ndarray, g: float = 0.0, Nbar: ndarray | None = None, mu: ndarray | None = None, dist: str = 'norm', nu: float | None = None, nobs: int = 1000, burn: int = 500, seed: int | None = None) dict[source]¶
Simulate returns from a scalar (A)DCC with GARCH/GJR marginals.
vol_params: one dict per asset with keys “omega” (float) and “alpha”, “gamma”, “beta” (sequences; “gamma” optional). The correlation intercept is (1-a-b)*Sbar - g*Nbar and must be PSD.