Utilities

Utilities that do not fit well on other pages.

Test Results

class arch.utility.testing.WaldTestStatistic(stat: float, df: int, null: str, alternative: str, name: str = '')[source]

Test statistic holder for Wald-type tests.

Parameters:
stat: float

The test statistic. Must not be negative. NaN is accepted and gives a NaN p-value, for a statistic that cannot be computed.

df: int

Degree of freedom. Must be positive.

null: str

A statement of the test’s null hypothesis.

alternative: str

A statement of the test’s alternative hypothesis.

name: str = ''

Name of test.

Raises:
  • TypeError – If stat is not a real number, df is not an integer, or null, alternative or name is not a str.

  • ValueError – If stat is negative or df is not positive.

property alternative : str

Alternative hypothesis.

property critical_values : dict[str, float][source]

Critical values of the test for common test sizes.

property null : str

Null hypothesis.

property pval : float[source]

P-value of test statistic.

property stat : float

Test statistic.

Residual Diagnostics

If a model is correctly specified, the standardized residuals \(\hat{e}_t = \hat{\epsilon}_t / \hat{\sigma}_t\) behave like draws from the distribution of the model, and so the tails of the residuals can be compared to the tails of the distribution that was assumed. The functions below summarize the tails of standardized residuals, and are also available for the results of a model, which use the standardized residuals and the estimated distribution of the model.

  • excess_kurtosis() is the sample excess kurtosis, the fourth central moment divided by the squared variance, less 3. It is 0 for a Normal, and is positive when the residuals have heavier tails than a Normal. Observations that are not finite are ignored.

  • hill_estimator() is the Hill estimator of the tail index, using the k largest absolute residuals, and int(sqrt(n)) of them if k is not provided. The estimator is \(\hat{\nu} = \left(k^{-1}\sum_{i=1}^{k} \ln X_{(n-i+1)} - \ln X_{(n-k)}\right)^{-1}\), where \(X_{(j)}\) is the \(j\)-th smallest absolute residual. Smaller values indicate heavier tails. The tail index of a Student’s t distribution is its degrees of freedom.

  • var_ratio() is the ratio of the Value-at-Risk (VaR) of a Normal to the VaR of the distribution of the model, at a confidence level that is 0.999 unless level is provided. A ratio below 1 means that the Normal understates the VaR of the model’s distribution. It depends on the distribution and its parameters only, and not on residuals.

The results of a model have the same diagnostics. They use the standardized residuals, std_resid, and, for var_ratio, the estimated distribution and parameters.

In [1]: import arch.data.sp500

In [2]: from arch.univariate import arch_model

In [3]: sp500 = arch.data.sp500.load()

In [4]: returns = 100 * sp500["Adj Close"].pct_change().dropna()

In [5]: res = arch_model(returns, dist="t").fit(disp="off")

In [6]: res.excess_kurtosis
Out[6]: 2.0564921815243142

In [7]: res.hill_estimator()
Out[7]: 5.044409345328121

In [8]: res.var_ratio()
Out[8]: 0.7506387458290167

The functions can also be used with any standardized residuals, and with a distribution that is not estimated.

In [9]: from arch.univariate import (
   ...:     StudentsT,
   ...:     excess_kurtosis,
   ...:     hill_estimator,
   ...:     var_ratio,
   ...: )
   ...: 

In [10]: excess_kurtosis(res.std_resid)
Out[10]: 2.0564921815243142

In [11]: hill_estimator(res.std_resid, k=50)
Out[11]: 4.637105026823519

In [12]: var_ratio(0.99, StudentsT(), [6.0])
Out[12]: 0.9066125541022967

excess_kurtosis(std_resid)

Sample excess kurtosis of standardized residuals.

hill_estimator(std_resid[, k])

Hill tail-index estimator of standardized residuals.

var_ratio([level, distribution, parameters])

Ratio of Gaussian VaR to model-distribution VaR.

The corresponding members of the results classes are excess_kurtosis, hill_estimator() and var_ratio().