Nyblom Test
Calculate the parameter stability test of Nyblom (1989) and Hansen (1992): whether the parameters of every asset’s GARCH-family model stayed the same over the sample, or the volatility process changed (a calmer or more turbulent regime, a change in how quickly shocks fade)?
At the maximum of the likelihood the scores of every parameter (the derivatives of the log-likelihood of each return) sum to zero over the whole sample. When a parameter changes during the sample, their running sum wanders far from zero in between. The test measures that wandering for every parameter on its own and for all of them together, relative to the variance of the scores.
The formula is as follows:
- \(s_{t}\) the scores of return t: the derivatives of its log-likelihood with respect to the parameters of the GARCH-family
method(GARCH(1, 1) by default) with thedistributionandmeanmodel fitted to the returns ofperiod, seetoolkit.risk.get_garch_parameters
Large statistics (small p-values) say the parameter is not stable. A parameter that the fit leaves on a bound of its search (such as an Omega or Alpha of 0) has scores that do not sum to zero, which inflates its statistic and the joint statistic.
Also known as: Nyblom test, Hansen stability test, parameter constancy test, parameter instability test, GARCH stability test, structural change in GARCH.
Example · ^GSPC, GLD · 2016 to 2025
Install the Finance Toolkit with pip install financetoolkit -U, then call get_nyblom_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_nyblom_test()
Or, with the Finance Toolkit MCP set up, ask an AI assistant such as Claude or ChatGPT:
Were the GARCH parameters of the daily returns of the S&P 500 and SPDR Gold Shares (GLD) stable from 2016 to 2025, according to the Nyblom test?
Which returns:
| Item | ^GSPC | GLD |
|---|---|---|
| Joint Statistic | 1.2498 | 1.2938 |
| Joint P-Value | 0.0164 | 0.0134 |
| Joint Critical Value (5%) | 1.0002 | 1.0002 |
| Omega Statistic | 0.4853 | 0.4856 |
| Omega P-Value | 0.0434 | 0.0433 |
| Alpha Statistic | 0.3316 | 0.4274 |
| Alpha P-Value | 0.1104 | 0.0612 |
| Beta Statistic | 0.6822 | 0.3219 |
| Beta P-Value | 0.0141 | 0.1174 |
| Individual Critical Value (5%) | 0.4614 | 0.4614 |
| Observations | 2,513.0000 | 2,513.0000 |
11 rows
Using Your Own Data
get_nyblom_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_nyblom_test()
Parameters
get_nyblom_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" |
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. 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 Nyblom, J. (1989). “Testing for the Constancy of Parameters Over Time.” Journal of the American Statistical Association, 84(405), 223-230.
- Paper Hansen, B.E. (1992). “Testing for Parameter Instability in Linear Models.” Journal of Policy Modeling, 14(4), 517-533.
- Library Shares similar logic as rugarch (R)’s nyblom