pyhctsa.operations.model_fit.garch_fit

pyhctsa.operations.model_fit.garch_fit(y, preproc='ar', P=1, Q=1, random_seed=None, model_type='garch', innovation_dist='gaussian')

A GARCH model of the changing variance of the series, and what it leaves in the residuals.

The series is whitened and z-scored, so the model is of the variance around a zero mean (hctsa’s MF_GARCHfit). A GARCH, GJR-GARCH or t-GARCH(P, Q) model is fitted by maximum likelihood (pyhctsa.operations._garch.mle()), unless the series shows no evidence of conditional heteroskedasticity, in which case the constant-variance model is reported. Statistics are the fitted parameters, the log-likelihood and information criteria, the persistence of the fitted variance process, summaries of the conditional variance series, and how well the standardized residuals pass tests for remaining ARCH effects (Engle’s ARCH test and the Ljung-Box Q-test) compared to the series itself, and residual_analysis() of the standardized residuals.

Parameters:
y : array-like

The input time series.

preproc : {'ar', 'none'}, optional

The preprocessing applied before the fit: 'ar' (default) replaces the series by the linearly detrended series by the preprocessing (from differencing, piecewise polynomial detrending, rank-mapping to a Gaussian) that maximizes whiteness under an AR(2) model, if it beats the detrended series by 5%; 'none' applies none (the series is not detrended). The series is z-scored either way.

P : int, optional

The GARCH degree: the number of lagged conditional variances. Default is 1.

Q : int, optional

The ARCH degree: the number of lagged squared innovations. Default is 1.

random_seed : int, 'default', 'none' or None, optional

The seed of the random Gaussian draws used by the whitening (rmgd), as hctsa’s BF_RandomSeed. Default is None (seed 0). The draws come from the portable generator (pyhctsa.robust.bf_random()), so they are hctsa’s.

model_type : {'garch', 'gjr'}, optional

The conditional variance model: 'garch' (default, symmetric response to shocks) or 'gjr' (GJR-GARCH, adds a leverage term so negative and positive shocks can have different effects on variance).

innovation_dist : {'gaussian', 't'}, optional

The assumed innovation distribution: 'gaussian' (default) or 't' (Student’s t, which estimates a degrees-of-freedom parameter to capture fat tails).

Returns:

  • hasStructure: 1 if the fitted variance model beats constant variance in the structure test, otherwise 0

  • constant, constanterr: the constant term of the variance equation and its error

  • offset: the mean offset of the model (0 for a z-scored series)

  • GARCH_i, GARCHerr_i (i = 1..P), ARCH_i, ARCHerr_i (i = 1..Q): the coefficients of the lagged variances and innovations, and their errors (0 and NaN without structure)

  • leverage, leverageerr: the leverage coefficient and its error ('gjr' only, otherwise NaN; 0 and NaN without structure)

  • distDoF: the degrees of freedom of a Student’s t distribution (otherwise NaN; the upper bound, 100, when the t does not fit better than a Gaussian)

  • LLF, aic, bic: the log-likelihood, AIC and BIC per observation, of the maximum-likelihood fit

  • summaryexitflag: 1 if the optimizer converged, otherwise 0

  • persistence: the sum of the ARCH and GARCH coefficients (plus half the leverage coefficient for 'gjr')

  • uncondVar: the implied long-run variance (NaN if persistence is 0.999 or more)

  • maxsigma, minsigma, rangesigma, stdsigma, meansigma: summaries of the conditional variance series

  • engle_mean_diff_p, engle_max_diff_p, lbq_mean_diff_p, lbq_max_diff_p: the mean and maximum, over lags 1 to 20, of the change in p-value of Engle’s ARCH test (series to standardized residuals) and of the Ljung-Box Q-test (squared series to squared standardized residuals)

  • engle_pval_stde_1, _5, _10, minenglepval_stde, maxenglepval_stde: p-values of Engle’s ARCH test on the standardized residuals

  • lbq_pval_stde_1, _5, _10, minlbqpval_stde2, maxlbqpval_stde2: p-values of the Ljung-Box Q-test on the squared standardized residuals

  • ac1_stde2: lag-1 autocorrelation of the squared standardized residuals

  • diff_ac1: lag-1 autocorrelation of the squared series minus ac1_stde2

  • zres_*: residual_analysis() of the standardized residuals (zres_meane, zres_meanabs, zres_stde, zres_maxonstd, zres_ac1, zres_ac2, zres_ac3, zres_propbth, zres_ftbth, zres_taurat, zres_normksstat, zres_sws, zres_swm, zres_popt, zres_minsbc)

Return type:

dict

Notes

The estimator is specified in pyhctsa.operations._garch: a deterministic grid start, a log-barrier Newton method to convergence within explicit bounds (all coefficients non-negative, persistence at most 0.9999), and a presample variance equal to the mean squared series. Without conditional heteroskedasticity the ARCH and GARCH coefficients are not identified (the likelihood is flat in the GARCH coefficient), so the variance model is reported only if its likelihood-ratio statistic against constant variance (for Gaussian innovations rescaled by 2 / (kurtosis - 1) of the standardized residuals) is at least 4 (6 for GJR). The null distribution of the statistic is not chi-squared because a parameter lies on the boundary and another is not identified under the null (D. W. K. Andrews, Econometrica 69, 683-734 (2001), DOI 10.1111/1468-0262.00210); the critical values were calibrated by simulation of white noise (3% to 6% of white-noise series of 100 to 10000 samples exceed 4, and about 5% exceed 6 for GJR). Otherwise the constant-variance model is reported: the ARCH, GARCH, leverage coefficients and persistence are 0, the conditional variance is the mean squared series, and the standard errors are NaN. For t innovations the degrees of freedom are reported only if the t fits significantly better than a Gaussian (the likelihood-ratio statistic, whose null is a 50:50 mixture of chi-squared(0) and chi-squared(1) because a Gaussian is the limit of infinite degrees of freedom, is above 2.7055, the 5% point); otherwise the upper bound, 100. The constant of the variance equation is bounded below by 1e-6 (the variance of 0.1% of a standard deviation). For series with long stretches of (near) zero values the Gaussian likelihood has no maximum, because the variance can shrink without limit where the series is zero; the fit then sits at the bound (the constant within 1% of it). In that case the log-likelihood, AIC and BIC are NaN, and, if the variance model is reported, so is everything computed from the conditional variance (the constant, the standard errors, uncondVar, the sigma summaries and the statistics of the standardized residuals). The coefficients, persistence, leverage and distDoF are still reported.

T. Bollerslev, J. Econometrics 31 (1986) 307-327 (DOI 10.1016/0304-4076(86)90063-1); L. R. Glosten, R. Jagannathan and D. E. Runkle, J. Finance 48 (1993) 1779-1801 (DOI 10.1111/j.1540-6261.1993.tb05128.x); T. Bollerslev, Rev. Econ. Stat. 69 (1987) 542-547 (DOI 10.2307/1925546).