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 thedistributionandmeanmodel fitted to the returns ofperiod, seetoolkit.risk.get_garch, and s and \(\kappa\) the skewness and kurtosis (not excess) of the fitted innovation distribution
- \(g_{t}\) the conditions of return t over the T returns after the first
lagsand ḡ their average
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:
| Item | ^GSPC | GLD |
|---|---|---|
| Mean t-Statistic | 2.8649 | 3.1991 |
| Mean P-Value | 0.0042 | 0.0014 |
| Variance t-Statistic | 0.0525 | -0.2087 |
| Variance P-Value | 0.9581 | 0.8347 |
| Skewness t-Statistic | -3.1205 | -0.0336 |
| Skewness P-Value | 0.0018 | 0.9732 |
| Kurtosis t-Statistic | -0.9192 | -2.5345 |
| Kurtosis P-Value | 0.3580 | 0.0113 |
| Q2 Statistic | 0.8941 | 0.3027 |
| Q2 P-Value | 0.3444 | 0.5822 |
| Q3 Statistic | 0.0555 | 0.0347 |
| Q3 P-Value | 0.8137 | 0.8522 |
| Q4 Statistic | 0.0296 | 0.0019 |
| Q4 P-Value | 0.8634 | 0.9654 |
| Joint Statistic | -25.9260 | 386.0920 |
| Joint P-Value | 1.0000 | 0.0000 |
| Lags | 1.0000 | 1.0000 |
| Observations | 2,512.0000 | 2,512.0000 |
18 rows
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.
| Parameter | Type | Description | Example |
|---|---|---|---|
period | str | The data frequency for returns (daily, weekly, monthly, quarterly, or yearly). Defaults to “daily”. | "weekly" |
lags | int | The number of lags of the Q2, Q3 and Q4 conditions. Defaults to 1. | 2 |
method | str | The 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" |
distribution | str | The 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" |
mean | str | The 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_benchmark | bool | Whether to include “Benchmark” among the assets tested. Defaults to False. | True |
rounding | int | None | The number of decimals to round the results to. Defaults to None. | 2 |
show_columns | str | list[str] | None | The 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