GMM Moment Test

Calculate the GMM orthogonality test of Hansen (1982): whether the standardized residuals of every asset’s GARCH-family model have the mean, variance, skewness and kurtosis of the innovation distribution the model assumes, with squares, cubes and fourth powers free of autocorrelation.

A correctly specified model leaves standardized residuals that are independent draws from its innovation distribution, so a set of moments has a known value. Each moment is tested on its own with a t-statistic; the autocorrelations of the squares (Q2: volatility clustering the model misses), cubes (Q3) and fourth powers (Q4) and all conditions together are tested with Wald statistics.

The formula is as follows:

  • \(z_{t}\) the standardized residuals of the GARCH-family method (GARCH(1, 1) by default) with the distribution and mean model fitted to the returns of period, see toolkit.risk.get_garch, and s and \(\kappa\) the skewness and kurtosis (not excess) of the fitted innovation distribution
\[\text{Mean:}\;\; E\left[z_{t}\right] = 0;\;\; \text{Variance:}\;\; E\left[z_{t}^{2} - 1\right] = 0;\;\; \text{Skewness:}\;\; E\left[z_{t}^{3} - s\right] = 0;\;\; \text{Kurtosis:}\;\; E\left[z_{t}^{4} - \kappa\right] = 0\] \[\text{Q2:}\;\; E\left[(z_{t}^{2} - 1) (z_{t-j}^{2} - 1)\right] = 0,\;\; \text{Q3:}\;\; E\left[(z_{t}^{3} - s) (z_{t-j}^{3} - s)\right] = 0\;\;\text{and}\;\; \text{Q4:}\;\; E\left[(z_{t}^{4} - \kappa) (z_{t-j}^{4} - \kappa)\right] = 0 \;\text{for}\; j = 1,\; \ldots,\; \text{lags}\]
  • \(g_{t}\) the conditions of return t over the T returns after the first lags and ḡ their average
\[S \text{ their covariance under the null of independent innovations:}\;\; \text{m\_\{a+\}ᵦ} - m_{a} \cdot \text{mᵦ} \;\text{between the Mean, Variance, Skewness and Kurtosis conditions} \;(\text{powers a and}\; b),\;\; \text{with}\;\; m_{k} = E\left[z^{k}\right] \;\text{of the fitted innovation distribution},\;\; (E [a_{t} \cdot c_{t}])^{2} \text{ between the products of the centred powers a and } c \text{ at the same lag, and 0 between different lags and between the moments and the products}\] \[\text{t-Statistic} = \frac{\bar{g}_{i}}{\sqrt{\frac{S_{ii}}{T}}},\;\; \text{with two-sided p-values from the normal distribution}\] \[\text{Q2},\;\; Q_{3} \;\text{and Q4 Statistic} = T \cdot \bar{g}' \cdot S^{- 1} \cdot \bar{g} \;\text{over their} \;\text{lags} \;\text{conditions},\;\; \text{chi-squared with lags degrees of freedom};\;\; \text{Joint Statistic over all}\; 4 + 3 \cdot \text{lags} \;\text{conditions},\;\; \text{chi-squared with}\; 4 + 3 \cdot \text{lags} \;\text{degrees of freedom}\]

Also known as: GMM orthogonality test, moment test, Hansen J test of standardized residuals, GARCH residual diagnostics, conditional moment test.

Example · ^GSPC, GLD · 2016 to 2025

Install the Finance Toolkit with pip install financetoolkit -U, then call get_gmm_moment_test:

from financetoolkit import Toolkit

toolkit = Toolkit(
    ["^GSPC", "GLD"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2016-01-01",
    end_date="2025-12-31",
)

toolkit.econometrics.get_gmm_moment_test(distribution="t")

Or, with the Finance Toolkit MCP set up, ask an AI assistant such as Claude or ChatGPT:

Did a GARCH model with Student-t errors capture the mean, variance, skewness and kurtosis of the daily returns of the S&P 500 and SPDR Gold Shares (GLD) from 2016 to 2025, according to the GMM moment test?

Which returns:

Using Your Own Data

get_gmm_moment_test runs on any data, not only prices: ratios, economic indicators, yield curves or your own dataset. Pass a DataFrame, a Series or a dictionary of them to Econometrics as data, with the dates in the rows or the columns, and set changes to how its changes are calculated: "percentage", "log", "difference" for rates and ratios, or None when the data are changes already. For example, for the monthly unemployment rates of the United States and Germany:

from financetoolkit import Economics, Econometrics

economics = Economics(start_date="2000-01-01")

unemployment = economics.get_unemployment_rate(
    countries=["United States", "Germany"], period="monthly"
)

econometrics = Econometrics(data=unemployment, changes="difference")

econometrics.get_gmm_moment_test()

Parameters

get_gmm_moment_test accepts the following parameters.

ParameterTypeDescriptionExample
periodstrThe data frequency for returns (daily, weekly, monthly, quarterly, or yearly). Defaults to “daily”."weekly"
lagsintThe number of lags of the Q2, Q3 and Q4 conditions. Defaults to 1.2
methodstrThe GARCH-family model fitted to the returns, as in toolkit.risk.get_garch. Options are: “garch” (GARCH(1, 1)), “gjr” (GJR-GARCH(1, 1, 1)), “egarch” (EGARCH(1, 1)), “igarch” (IGARCH(1, 1)), “aparch” (APARCH(1, 1)), “tgarch” (TGARCH), “ngarch” (NGARCH), “avgarch” (AVGARCH), “nagarch” (NAGARCH), “component” (component GARCH), “figarch” (FIGARCH(1, d, 1)). Defaults to “garch”."garch"
distributionstrThe innovation distribution of the model and of its skewness and kurtosis. Options are: “normal” (normal), “t” (Student-t), “skewt” (skewed Student-t of Hansen), “skewt_fernandez_steel” (skewed Student-t of Fernández and Steel), “ged” (generalized error distribution), “johnson_su” (Johnson SU). Defaults to “normal”."studentt"
meanstrThe mean model. Options are: “zero” (the returns themselves are the shocks), “constant” (constant mean), “arma” (ARMA(1, 1)), “in_mean” (GARCH-in-mean), “arfima” (ARFIMA(1, d, 1)). Defaults to “zero”."zero"
include_benchmarkboolWhether to include “Benchmark” among the assets tested. Defaults to False.True
roundingint | NoneThe number of decimals to round the results to. Defaults to None.2
show_columnsstr | list[str] | NoneThe columns to keep, a name or a list of names, matched on every column level, or the rows when no column has those names (such as the line items of a financial statement). Names that do not exist are logged, and when none exist the result is returned in full. Defaults to None, which keeps every column.None, which keeps every column

References

  • Paper Hansen, L.P. (1982). “Large Sample Properties of Generalized Method of Moments Estimators.” Econometrica, 50(4), 1029-1054.
  • Library Shares similar logic as rugarch (R)’s GMMTest
Share