pyhctsa.operations.model_fit.garch_compare

pyhctsa.operations.model_fit.garch_compare(y, pre_proc='none', pr=(1, 2, 3), qr=(1, 2, 3), random_seed=None)

How well GARCH models of different orders describe the changing variance of the series.

Fits a set of zero-mean GARCH(p, q) models with Gaussian innovations to the (whitened and z-scored) time series (hctsa’s MF_GARCHcompare) and returns statistics on the goodness of fit across a range of p (the number of lagged variances) and q (the number of lagged squared innovations): summaries across the grid of fitted models, and the orders that fit best. The models are fitted as in garch_fit(), in order of increasing p and q, each started also from its smaller neighbors (so the log-likelihood never decreases with an order). If the GARCH(min p, min q) model does not beat constant variance in the structure test of garch_fit(), the constant term and the residual statistics are those of constant variance (the likelihood and information criteria are always those of the fitted models). A fit with the variance constant at its floor (within 1% of the bound 1e-6; see garch_fit()) has no likelihood maximum: a summary that such a model determines is NaN (the minimum or maximum over the models if that model attains it, the mean if any model is at the floor, an order pick if the chosen model is), and the constant and residual statistics only if the variance model is reported.

Parameters:
y : array-like

The input time series.

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

A preprocessing to apply: 'none' (default; the series is not detrended), or 'ar', which detrends the series and applies the preprocessing that maximizes AR(2) whiteness (see garch_fit()).

pr : array-like of int, optional

The model orders p to compare. Default is (1, 2, 3).

qr : array-like of int, optional

The model orders q to compare. Default is (1, 2, 3).

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

How to seed the random draws used by the whitening, as in garch_fit().

Returns:

Statistics across the (p, q) models (the log-likelihood, AIC and BIC are per observation):

  • hasStructure: 1 if the structure test of garch_fit() is passed, otherwise 0

  • minLLF, maxLLF, meanLLF: the log-likelihood

  • minBIC, maxBIC, meanBIC: the Bayesian information criterion

  • minAIC, maxAIC, meanAIC: Akaike’s information criterion

  • minK, maxK, meanK: the constant term of the variance equation

  • min_meanarchps, max_meanarchps, mean_meanarchps: across models, the mean p-value (over lags 1 to 20) of Engle’s ARCH test on the standardized residuals

  • min_maxarchps, max_maxarchps, mean_maxarchps: the same for the maximum p-value over the 20 lags

  • min_meanlbqps, max_meanlbqps, mean_meanlbqps: across models, the mean p-value of the Ljung-Box Q-test on the squared standardized residuals

  • min_maxlbqps, max_maxlbqps, mean_maxlbqps: the same for the maximum

  • bestpAIC, bestqAIC, bestpBIC, bestqBIC: the orders of the models with the minimum AIC and BIC, among the grid and the constant-variance model (orders 0, 0)

  • Ks_vary_p, Ks_vary_q: how much the constant term varies with p and with q: the standard deviation of the constant across one order, averaged over the other

Return type:

dict