Validation¶
Every number pymetrix produces should be checkable against something other than pymetrix. This page lists what each area is checked against in the test suite, and how closely they agree. The checks run on every change, on Windows, macOS and Linux.
Kinds of reference.
- Library (wrapped): pymetrix calls this library to do the work, and the test calls it directly. This checks the wrapper: data alignment, sample, degrees of freedom and naming.
- Library (independent): pymetrix computes the result itself, and the test compares it with another library's result.
- Other package: another program's recorded output (named, with its version).
- Published: a table or result from a paper.
- Formula: a closed form, a hand calculation or a known exact value.
- Recovery: a simulation from known true values, which the estimate must recover.
"Default" tolerance means NumPy's allclose: relative 1e-5, absolute 1e-8.
How pymetrix defines each statistic (AIC, BIC and HQ as totals, R² variants, degrees of freedom, covariance estimators)
is in design/definitions.md; the reference conformance suite in tests/reference/
checks key estimators against certified and published values.
The tables below have about 290 rows for the core and 75 for the finance plugin, most of them several checks of one method; counting parametrised cases separately, there are several hundred assertions. In the core, the references are independent libraries, other packages' recorded output (Dynare 6.0, R, gretl, JMulTi, Stata, x13as, rjd3tramoseats), published tables, closed forms, simulation and recovery; about 20 rows are wrapper checks. In the finance plugin, the copulas are checked against R's VineCopula and copula packages, and options, volatility and credit against QuantLib, arch, statsmodels and scipy; the rest against closed forms, published examples (He and Litterman 1999), hand calculations and recovery from simulation.
The register. reference/validation-register.md (and the same rows as
CSV) lists, for every public estimator and result-producing function, each test that
checks it against an outside reference: the reference, what is compared, the tolerance, the test's node id and the
extras it needs. It is written from the tests' @pytest.mark.reference(...) markers by
scripts/make_validation_register.py, and names the estimators that have no outside check yet, with the reason.
tests/test_validation_register.py fails when it is out of date or when a public estimator is in neither list.
Apart from these, two checks keep code and app in step. The script the app writes for each demo project, run in a fresh Python process with no display, reproduces the project's numbers to 1e-8 and loads no Qt or plotting library. The code in building and estimating models runs as written.
Reference conformance suite¶
tests/reference/ checks key estimators against certified or published numbers from outside pymetrix. Each case
runs twice: through the public API, and as a recorded call saved to JSON and replayed in a fresh session (see
design/commands.md). The fixtures and their sources are built by
tests/fixtures/reference/make_reference.py, from the copies that statsmodels (BSD-3) ships.
| Estimator | Reference | Achieved |
|---|---|---|
| OLS | NIST StRD Longley, certified values | coefficients 10.8 correct digits (LRE), standard errors 8.3, SSR 12.1, R² 14.5; required: 9 and 8 |
| OLS | Stata on Longley: log likelihood, AIC, BIC, White (HC1) errors | as printed (HC1 within 3e-8 relatively) |
| ARMA(1,1), ARMA(2,2) with a constant | gretl, exact maximum likelihood | coefficients 1e-5, log likelihood 1e-6, s.e. 1e-3 (gretl's numerical Hessian) |
| VAR(4) with a constant | JMulTi on statsmodels' macrodata | every coefficient and s.e. to JMulTi's three printed decimals |
The other NIST linear regression sets (Norris, Pontius, NoInt1/2, Filip, Wampler1–5) are added when their files can be fetched from NIST.
Least squares and single equations¶
| Method | Checked against | Agreement |
|---|---|---|
| OLS: coefficients, standard errors, R², AIC | statsmodels OLS (independent) | default |
Equation lag search (select_lags) |
statsmodels ar_select_order (AutoReg on a common sample): AIC, BIC, HQ differences between lag lengths, and the lags chosen | 1e-8; equal |
| ML for explicit-form equations | the linear-form fit (Logit, Probit, Poisson; classic and white); statsmodels GenericLikelihoodModel for a power index in a logit and an identity-link Poisson | 1e-8 (s.e. 1e-9); 1e-6, s.e. 1e-5 relatively |
| Hannan-Quinn criterion | by its formula from statsmodels OLS's log likelihood; statsmodels ARIMA's hqic for a regression with AR(1) errors | 1e-10; 1e-8 |
| White (HC1), HAC (Newey-West), one- and two-way cluster standard errors | statsmodels (independent) | default; two-way 1e-8 |
HC0, HC2, HC3 (OLS(cov="hc0"/"hc2"/"hc3")): OLS, WLS, restricted least squares (as the substituted regression), HC0 with absorbed fixed effects (as the dummy regression) |
statsmodels' cov_type="HC0", "HC2", "HC3" called directly (independent); the hand formula with the leverages h_ii on six observations; R 4.3.3 sandwich 3.1.0 vcovHC (HC0 to HC3) on Mroz's hours equation, recorded |
1e-12; 1e-12; 1e-11 (R printed 15 digits) |
HC2 to HC5 with absorbed fe() terms (one and two, unbalanced), and HC4, HC5 (OLS(cov="hc4"/"hc5")) |
statsmodels' cov_type="HC2", "HC3" on the regression with explicit dummies (independent); the hand formulas of R sandwich's vcovHC(type="HC4") and "HC5" on the dummy regression and without effects; the one-way leverage 1/n_g and the two-way leverage as the dummies' projection |
1e-10 |
HC0 for IV (IV(cov="hc0")) |
linearmodels' IV2SLS with cov_type="robust", debiased=False (independent) |
1e-10 |
The reference level of a categorical term (C(g, base="b"), tests/test_categorical_base.py) |
statsmodels 0.15.0 with patsy 1.0.3's C(g, Treatment(reference="b")): OLS coefficients and standard errors (a text level and a number level), a logit by ML; without base= the first level as before; the fitted values unchanged by the reference |
1e-10; 1e-6 (logit) |
A time axis from a first period (Dataset.from_frame(df, start=, freq=), Dataset.read(..., start=), File → Load data… Dates start at): years, July-June years, quarters, months, weeks |
pandas' period_range from the first period written out by hand; a Parquet round trip (frame, axes, labels and sources equal); a CSV read and the dialog's step equal |
exact |
HAC with and without the n / (n - k) factor (hac_correction), OLS and IV |
statsmodels' HAC with use_correction set to match |
1e-10 |
| Fixed effects (within) | statsmodels OLS with entity dummies | default |
| Nonlinear least squares | SciPy curve_fit; exact values on noise-free data |
1e-6 (coefficients), 1e-4 (s.e.) |
| Symbolic derivatives | finite differences | 1e-6 |
Expression functions: round, floor, ceil, log10, na, isna, fillna, iif, year() ... obsnum(), normrnd, unifrnd (tests/test_expr_functions.py) |
rounding against Python's decimal (ROUND_HALF_UP) and NumPy; the calendar against pandas' periods, and obsnum() against pandas' rank within each entity; missing values against pandas' isna, fillna and where; the draws against NumPy's Generator built from the same seed and bit generator (and Generator.normal and uniform); the compiled functions and a solved model against the interpreter and a hand loop |
exact; 1e-15 |
Distribution functions (normpdf ... binocdf: normal, t, chi-squared, F, gamma, beta, lognormal, uniform, exponential, Poisson, binomial; pdf, cdf, inverse cdf), erf, erfc |
scipy.stats at many points and parameter values, MATLAB's parameterisations mapped by hand; scipy.special | 1e-12 relatively |
poissinv, binoinv (MATLAB: the smallest integer k with cdf(k) >= p) |
scipy.stats ppf at 405 probabilities (0, 1e-300, 1e-12, ..., 1 - 1e-12, 1) for seven parameter sets (scipy's -1 at p = 0 read as MATLAB's 0); the definition, cdf(k) >= p > cdf(k - 1); back from the cdf at every integer of the support; all mass at 0, invalid parameters and p outside [0, 1]; linearising through one refused |
exact |
| Inverse cdfs | inv(cdf(x)) = x for every continuous family | 1e-9 |
| Derivatives of distribution and moving-window functions, in x and in the parameters offered | central finite differences, interpreted and compiled | 1e-6 (moving windows 1e-5) |
A model with a probit-style rule p = normcdf(a + b*y), solved and linearised; the same model from a Dynare file |
steady state and decision rules by hand (the stable root of 0.2 c g² − g + ρ = 0, c = b φ(a + b y*)); the pymetrix model | 1e-8; 1e-10 |
describe: skewness and excess kurtosis; other columns |
scipy.stats.skew and kurtosis with bias=False; pandas describe | 1e-12 |
corr (Pearson, Spearman, Kendall tau-b), cov |
scipy.stats pearsonr, spearmanr, kendalltau on each pair's complete periods; numpy.cov | 1e-12 |
partial_corr |
correlations of OLS residuals by hand (numpy lstsq); the textbook formula for one series held constant | 1e-10 |
coskewness, cokurtosis (matrix and pairs, standardized or not) |
every element by hand (loops of means of products of deviations); symmetric under every permutation of the indices; diagonal against scipy.stats skew and kurtosis (bias=True, fisher=False) and, converted, describe()'s G1 and G2; unchanged by location and positive scale, sign flips by the parity of a negated series |
1e-12 (location and scale 1e-9) |
systematic_comoments |
the definitions by hand (beta, standardized co-skewness and co-kurtosis, their betas); beta against a least-squares slope; co-skewness against the pairs table | 1e-12 (slope 1e-10) |
Random generator (set_random_generator) |
raw draws against NumPy's Generator over PCG64, MT19937, Philox and SFC64 called directly (integer seeds, seed lists, spawned SeedSequence streams); the default against np.random.default_rng; seeded simulation, VAR bootstrap, MCMC, SMC and copula draws build MT19937 and never default_rng when it is chosen, and are bit-identical to before the setting under the default; chains in two processes against one; project round trip |
exact |
crosscorrelogram, autocov |
a plain loop over numpy (full-sample moments, sums over T); Pearson at lag 0; statsmodels acovf | 1e-12 |
Moving-window functions (movavg, movsum, movsd, movvar, movmin, movmax, movcov, movcorr, movbeta) |
pandas rolling (beta as rolling cov / var), per entity in a panel; a gap in the dates | 1e-9 |
Standing in a window (movzscore, movrzscore, movpctrank, movquantile; expzscore, exprzscore, exppctrank) |
pandas rolling and expanding (mean and std, median and a MAD by apply, rank(pct=True), quantile), with missing values, per entity in a panel; the compiled function against the interpreter, array and scalar paths; movpctrank's ties by hand |
1e-12 |
Surveillance heatmaps (surveillance_heatmap, normalise) |
the formula functions above; z-scores, robust z-scores and percentile ranks against a reference span by hand (scipy percentileofscore(kind="mean")); gaps against Dataset.filter (HP, Hamilton) and movavg; flips (sign, 100 - p); group averages and the equal composite by hand; the PCA composite's weights against PCA(...).fit loadings; the row order against scipy's linkage and leaves_list; mixed-frequency alignment and release lags by hand; the latest table's changes by hand |
1e-12; 1e-10 |
K-means (kmeans, kmeans_k) |
scikit-learn KMeans (not wrapped): the same partition and centres on well-separated data; from the same k-means++ centres, the same sum of squares (Lloyd, tol 0); over 50 starts no higher than its best of 10; the silhouette against silhouette_score and silhouette_samples, and a five-point example by hand; deterministic with a seed |
1e-10; 1e-8; 1e-10 |
Centred and expanding windows (cmovavg ... cmovbeta, cumavg ... cumbeta) |
pandas rolling(n, center=True) (odd and even n) and expanding() (beta as expanding cov / var on pairwise-complete values), per entity in a three-country panel with a missing value, and on one series; missing at both ends of a centred window until it is full; centred windows' derivatives against finite differences, their leads seen by the model checker; expanding windows refused in models, in differentiation and on arrays |
1e-9; 1e-5 |
| Static forecasts and intervals | statsmodels get_prediction |
default |
| Rolling and recursive regressions; CUSUM | statsmodels RollingOLS, recursive_olsresiduals; CUSUM bounds by formula |
default |
| CUSUM of squares critical value | Durbin (1969) table | within 0.02 |
| Wald, Breusch-Godfrey, Jarque-Bera, White, Breusch-Pagan, ARCH LM, RESET, Ljung-Box | statsmodels (independent) | default |
Wald test with coefficient names such as dlog(Y), x[-1], log(P), L(x, 1), const and backticked names |
the same hypothesis with plain names on the same regression (regressors computed by hand); the textbook (R b - r)' (R V R')^-1 (R b - r); a system's cross-equation Wald by hand | 1e-12 (1e-10 for the system) |
Breusch-Godfrey's F form and presample="drop" |
statsmodels' acorr_breusch_godfrey (LM, F and both p-values; lags 1 and 4, and without a constant with auxiliary_constant=True; independent); the drop variant by hand on observations p+1..n |
1e-10 (statistics), 1e-8 (p-values) |
Breusch-Godfrey without a constant in the equation: the default (auxiliary regression on the equation's regressors) and auxiliary_constant=True |
both by hand (loops for the zero-filled lags, normal equations, R-squared about the mean); the option against statsmodels' acorr_breusch_godfrey (lags 1, 2, 4, with and without a constant); the default against values recorded before the option |
1e-10; 1e-9; 1e-10 |
pymetrix.ols (arrays passed directly) |
Equation.fit(method=OLS(...)) on the same data: coefficients, covariance, standard errors, every statistic, residuals, fitted values, design, every applicable test and the diagnostics table, summary text, forecasts; classic, White, HAC (automatic and given lags, with and without the correction), one- and two-way clusters (columns and index levels), weights, no constant, dummy columns (and C()), missing values, unsorted rows, dates, numpy, mappings and structured arrays; provenance field by field (all equal but the creation time and vintage_request) |
1e-12 |
| Chow break test, first-stage F | formula from statsmodels' sums of squares | default |
| Quandt-Andrews sup F | the statistic as the largest Chow F by hand; the shipped table of Andrews' limit (100,000 draws) against Andrews' (1993) critical values with 15% trimming, and against a fresh simulation off the table's trimmings | 1e-10; 0.02; 0.03 |
| Likelihood-ratio test | statsmodels compare_lr_test |
1e-10 |
| 2SLS | statsmodels IV2SLS; linearmodels k-class with κ = 1 | default |
| LIML (Fuller), IV-GMM with Hansen J | linearmodels (wrapped) | default |
Complementary log-log (CLogLog, OrderedCLogLog) |
statsmodels' GLM Binomial(link=CLogLog()) by Newton (observed information): coefficients, classic and HC0 s.e., log likelihoods, fitted values; the null log likelihood; score and Hessian by finite differences into the tails; statsmodels' OrderedModel with distr=scipy.stats.gumbel_l (independent) |
1e-8; 1e-6 (ordered coefficients), 1e-5 (s.e.) |
| Logit, probit, Poisson: estimates, s.e., likelihoods, predictions | statsmodels (independent) | 1e-7 (coefficients), 1e-6 (s.e.) |
| Quantile regression | statsmodels QuantReg (wrapped); the sample median | default |
Robust regression (RobustLS): Huber and Tukey bisquare norms, scale by the MAD or fixed |
statsmodels RLM (independent) with HuberT() and TukeyBiweight(), default and other tuning constants, iterated to convergence (maxiter 1000, tol 1e-14 on the coefficients): coefficients, H1 standard errors, scale, final weights; a fixed scale against the estimating equations sum psi(u / s) x = 0 and the H1 formula (and RLM with start_scale where statsmodels has it); a location model inside the tuning constant against the sample mean and its standard error |
1e-8; 1e-9 and 1e-12; 1e-12 |
The test of the restrictions reported with a restricted fit (fit.stats["restrictions_f"], "restrictions_wald") |
statsmodels' f_test and wald_test on the unrestricted OLS (classic, HC1, HC3; independent); pymetrix's Wald test on the unrestricted fit; the SSR comparison for the classic F; IV against the Wald statistic on the unrestricted 2SLS fit |
1e-10 (statistics), 1e-8 (p-values) |
Restricted least squares (OLS(restrictions=...), IV(restrictions=...)) |
the substitution estimate (the restrictions substituted into the equation, fitted unrestricted) and its delta-method covariance J V J': OLS with classic, White, HAC and clustered standard errors, IV with classic and White, one and two restrictions; unrestricted fits against the closed form (X'X)^-1 X'y, s^2 (X'X)^-1 | 1e-12 (coefficients), 1e-10 (covariance, relatively) |
| Regression with ARMA errors; AR and MA models; their forecasts | statsmodels SARIMAX (independent) | 1e-4 (coefficients), 2e-3 (s.e.), 1e-3 (forecasts) |
| ARMA order selection | statsmodels SARIMAX information criteria | 1e-6 |
| ACF, PACF, Q statistics | statsmodels (independent) | default |
Volatility¶
| Method | Checked against | Agreement |
|---|---|---|
| GARCH(1,1) and GJR-GARCH-t (native) | arch (independent); a separately coded likelihood; the optimum by perturbation | 5e-4 (parameters), 1e-5 (log likelihood), 1e-3 (s.e.) |
| GARCH variance forecasts and bands | closed-form recursion | default |
| EGARCH, TARCH, FIGARCH, APARCH; skewed-t and GED errors with the arch backend; their forecasts | arch (wrapped) | default |
| Native skewed-t and GED GARCH and GJR-GARCH: densities, quantiles, estimates, forecasts and bands; AR(1)-GARCH with them | arch 9.0 (independent): the densities and quantiles; GARCH on simulated t(6) returns; AR(1) errors on simulated skewed-t data | 1e-12; 1e-5 (log likelihood), 1e-3 relative (parameters), 2e-3 (s.e.); 1e-4, 1% (s.e.) |
| GARCH parameters | recovery from simulated data | within 4 s.e. |
Unit roots and cointegration¶
| Method | Checked against | Agreement |
|---|---|---|
| ADF, KPSS, Engle-Granger | statsmodels (wrapped) | default |
ADF and Engle-Granger on arrays (pymetrix.stats.adf_arrays, behind the simulated critical values) |
statsmodels adfuller and coint (independent): every trend, aic / bic / t-stat / fixed lags, n = 16 to 90, two and three variables, the default largest lag capped in short samples (statsmodels given the same largest lag); arch engle_granger and ADF at the lag chosen on 16 annual observations, where statsmodels' own default gives a degenerate 0.0 |
the same lag; statistic 1e-9 |
Simulated critical values and p-value (critical_values="simulated") |
a direct simulation in the test: the same seeded random walks, each tested by statsmodels (with dummies: numpy least squares and statsmodels' ADF on the residuals); the mt19937 generator too | 1e-9 (critical values); p-value exact |
| Simulated critical values at n = 500, fixed lag | MacKinnon's response surfaces (statsmodels mackinnoncrit): share of 2,000 draws below the 1, 5 and 10% values, ADF c and ct, Engle-Granger with 2 and 3 variables |
within 4 binomial standard errors |
| Phillips-Perron, DF-GLS, variance ratio, Zivot-Andrews | arch (wrapped) | default |
| Phillips-Ouliaris Zt and Za | the formulas of Phillips and Ouliaris (1990), coded in the test; arch (wrapped), whose version the details record | 1e-10 |
| Johansen trace and maximum eigenvalue | statsmodels (wrapped) | default |
| Levin-Lin-Chu | gretl 2026b levinlin: 10 cases, T = 27 to 120, every trend option |
1e-5 |
| Im-Pesaran-Shin t-bar | gretl 2026b adf on a panel |
1e-5 |
| Im-Pesaran-Shin W t-bar (moments simulated, not tabled) | gretl 2026b | within simulation error (about 0.01) |
| Simulated IPS moments at large T | the Dickey-Fuller limit (mean −1.53, variance 0.71) | 0.03 |
| Pesaran's CADF statistic | statsmodels OLS on the explicit regression | 1e-10 |
| CIPS critical values (simulated) | Pesaran (2007), Tables II(b) and II(c), as transcribed in R's plm | 0.03 |
| CIPS statistic, balanced and unbalanced (a late start, an early end, a gap) | R plm 2.6.3 cipstest on the Grunfeld data, every trend, 1 and 2 lags |
1e-9 |
| Breitung | the statistic written out by hand (constant; constant and trend); its null distribution in 1,000 panels (mean, s.d., size); Breitung and Das's robust version under a strong common factor | 1e-10; 0.15; 8-11% at 5% with N = 10 (the standard statistic 37%) |
| Pedroni's moments (simulated) | Pedroni (1999), Table 2, one regressor with a constant, at T = 1000 | means 0.1, variances 6% |
| Pedroni's group ADF term | statsmodels OLS t on the residuals' ADF regression | 1e-10 |
| Kao | the within regression by statsmodels with entity dummies, its pooled Dickey-Fuller regression, Kao's DF rho and DF t formulas | 1e-10, 1e-3 |
| Westerlund Gt | the average of statsmodels OLS t-statistics of each entity's error-correction regression (lags and leads) | 1e-10 |
| Pedroni, Kao, Westerlund | size under the null (independent random walks) and power under cointegration, in repeated samples (N = 15, T = 60) | size under 16%, 12% and 13%; power 1 |
| Fisher-type (Maddala-Wu, Choi), Hadri | formulas applied to statsmodels' ADF and KPSS | 1e-6 |
Exercise packs¶
| Method | Checked against | Agreement |
|---|---|---|
| The test pack's wage equation (mroz): coefficient, R², White standard error | statsmodels OLS with cov_type="HC1" on the same rows (independent) |
the checks' tolerances (5e-4; s.e. 1e-3 relative) |
| The test pack's ADF statistics (Nile, constant; constant and trend; one lag) | the Dickey-Fuller regression fitted by hand with NumPy least squares in the test | 1e-3 |
| Checks pass on the reference solution, fail on a wrong one (no robust errors, a regressor left out) | the expected values above | exact pass/fail |
| Value paths never call | a test object whose method records any call: methods and __ names refused, nothing recorded |
exact |
VARs, VECMs and Bayesian VARs¶
| Method | Checked against | Agreement |
|---|---|---|
| VAR estimates, covariance, information criteria, roots; lag selection | statsmodels VAR (independent) | default |
| Impulse responses (orthogonalised, cumulative), variance decompositions, forecasts | statsmodels (independent) | default |
| Granger causality, portmanteau, normality tests | statsmodels (independent) | default |
Bootstrap bands (pymetrix.bootstrap, tests/test_bootstrap.py) |
the residual bootstrap's draws (coefficients, deterministic terms, covariance) against a hand-written recursive-design loop with the same seed; the default bands (VAR parametric irf, girf, historical decomposition; VECM residual irf) against the bootstrap as it was written before, bit for bit; Monte Carlo coverage of 90% percentile bands of a stable bivariate VAR(1), T = 100, horizons 1 to 4, 200 samples of 99 draws (_coverage in the test file): residual 0.84, wild 0.83, parametric 0.85, moving blocks 0.77; under GARCH(1,1) errors wild 0.73 against residual and parametric 0.68 (the test runs 40 samples, bounds 0.78 to 0.98); a VECM's 90% bands on a simulated cointegrated system (30 samples, bounds 0.75 to 0.99) with K - r unit roots in every draw; Kilian's correction raising a near-unit-root AR(1)'s estimate (true 0.95, T = 80) towards the truth on average; workers against one process |
1e-12; exact; Monte Carlo |
Bootstrap of regressions (fit.bootstrap, LocalProjection.fit(bootstrap=), tests/test_bootstrap_regressions.py) |
an OLS fit's pairs, residual and wild draws against hand-written loops with the same seed; on n = 2,000, bootstrap standard errors over White's (pairs 0.98 and 1.01, wild 1.00 and 0.98) and the residual bootstrap's over the classic ones (1.00, 1.02), 999 draws; under heteroskedasticity (y = 1 + 0.5x + abs(x)^1.5 e, n = 40, 200 samples of 199 draws) 90% percentile intervals for the slope cover 0.47 (residual), 0.74 (wild), 0.80 (pairs), bootstrap-t 0.78, 0.83, 0.80 (the test runs 60 samples: wild above residual by 0.1); a lag-augmented local projection (cov="white") of an AR(1) (rho 0.6, T = 150, horizons 0 to 8, 100 samples of 199 draws) covers the true responses with 90% bands on average 0.87 (analytic), 0.85 (wild), 0.86 (moving blocks), 0.80 (blocks of periods, pairs) (the test runs 30 samples of wild, bounds 0.70 to 1.0); the analytic bands unchanged by default, against the standard errors' formula, bit for bit |
1e-12; 12%; Monte Carlo; exact |
Conditional forecasts with ranges and structural scenarios (tests/test_conditional_ranges.py) |
exact conditions against Gaussian conditioning on the stacked covariance built in the test from the VAR recursion; a one-sided range in a one-shock VAR against the truncated-normal mean and variance; two correlated ranges against rejection sampling of 400,000 unconditional paths; a range wide enough not to bind against the unconditional forecast, and one shrunk to a point against the exact condition; every draw within its bounds; only the named shocks moving against the impact matrix; a positive-only shock against the half-normal mean; the Bayesian VAR's sampler with the posterior updated against the predictive when no condition binds | 1e-10 (exact); 4 Monte Carlo s.e., 2-4% (sd) |
| Ranges in first-order model plans | a slack range against the plan without it; a binding one against numpy's minimum-norm shocks for its active bound, on responses from separate simulations | 1e-12; 1e-6 |
| FMOLS, CCR, DOLS, Gregory-Hansen | the Bartlett long-run covariance and automatic bandwidth against the installed arch's (its automatic choice with arch 9; with arch 7 and 8, whose rule differs, a whole-number bandwidth handed to both); all three estimators, estimates and s.e., against arch's automatic choice with a constant and a trend (DOLS's BIC leads and lags too, and a fractional bandwidth given), and FMOLS with a span and a row condition against arch on just those rows; Gregory-Hansen against statsmodels' ADF at its break, a simulated break recovered, the simulated 5% values against the published table | 1e-12; 1e-10; 1e-10, 2 periods; 0.25 |
Long-run covariance, automatic bandwidth (tests/test_lrv_bandwidth.py, whatever arch is installed) |
every lag j < b + 1 used: a brute-force sum of the Bartlett kernel over all lags; positive semi-definite: the spectral window non-negative for b = 0 to 15 by 0.05, the eigenvalues of a three-series estimate for b = 0 to 12 by 0.1, and an AR(1) with phi = -0.9 at b = 1.5 (+1.40, where 0.1.0a18 gave -0.54); the default rule's FMOLS, CCR and DOLS (bandwidth, estimates, s.e.) against numbers recorded from arch 9.0.0 on the simulated system (constant, trend) and sample_macro; Newey and West's S, the long-run variance and FMOLS's whole-number bandwidth against R sandwich 3.1.0's bwNeweyWest, kernHAC and NeweyWest on DOLS residuals (sample_macro, statsmodels' macrodata); the removed bandwidth_rule="legacy" refused with an error naming it, in a call, a replayed script and a dialog step saved by 0.1.0a20 (one saved with the default rule loads and equals the API call and its replayed script) |
1e-12; 1e-12; 1e-10; 1e-10; exact; exact |
| Mean group, CCE, pooled mean group | MG against per-unit statsmodels OLS; CCEMG against per-unit OLS with the averages; CCE near the truth where MG is biased, s.e. against the spread over 30 samples; PMG's likelihood by hand, one unit against its ARDL long run, Hausman's size over 60 samples | 1e-12; 1e-10; 0.1, 40%; 1e-10, 1e-6, 0.05 +- 0.06 |
| Synthetic DiD | the estimate against two-way fixed effects weighted by omega lambda (statsmodels WLS); DiD by hand; the unit weights against Frank-Wolfe on the same objective; the truth recovered where DiD is biased | 1e-10; 1e-10; 1e-8; 3 s.e. |
| Diffusions | Vasicek against the mapped AR(1) least squares; CIR's likelihood against scipy's noncentral chi-squared, simulated values recovered; GBM against its closed forms, its s.e. against the spread over 60 samples | 1e-6; 1e-10, 3 s.e.; 1e-12, 30% |
| Threshold VAR, bilinear, VARMA, BHHH | the threshold VAR's regimes by least squares, its threshold by brute force, its LR by hand; the bootstrap test rejecting a simulated threshold (p < 0.05) and not a linear VAR; the bilinear residuals by a loop and simulated values recovered; VARMA(2, 0) against the VAR; VARMA(1, 1)'s residuals by a loop and its estimates near statsmodels' VARMAX; BHHH against Newton; OPG errors by hand | 1e-12; exact; 1e-10; holds; 1e-10, 3 s.e.; 1e-10; 1e-10, 0.04; 1e-7; 1e-6 |
| DECO, diagonal VECH (finance) | DECO with two series against DCC (parameters, likelihood); its closed-form likelihood against numpy's determinants and inverses; a simulated common correlation recovered; the diagonal VECH's likelihood by a loop, no lower than the scalar BEKK's nor the true parameters', simulated values within 3 s.e. | 1e-5, 1e-8; 1e-10; 0.06; 1e-10 |
| Ng-Perron, ERS, Perron break | the GLS detrending through arch's DF-GLS statistic; the M statistics by formula; size under a random walk and power against an AR(0.9) at the tabulated 5% values; Perron's simulated 5% values against his tables (T = 100, lambda = 0.5); his statistic against statsmodels OLS | 1e-10; 1e-10; 0.05 +- 0.035, > 60%; 0.12; 1e-10 |
The omitted-variables test (omitted_variables) |
statsmodels' compare_f_test, compare_lr_test and compare_lm_test on Mroz's wage equation (independent); with HC3, statsmodels' wald_test on the augmented fit; a logit's LR against statsmodels' Logit log likelihoods; the dialog's call typed again |
1e-10; 1e-10; 1e-6 |
General-to-specific selection (gets) |
each step's checks against the tests of pymetrix.stats run directly on the reduced equation refitted by Equation.fit, and the encompassing test against the Wald test a restricted least-squares fit of the GUM reports; potency 1.0 and gauge under 0.15 (target size 0.05) over six simulated DGPs (pymetrix computes the search itself; not compared with R's gets) |
1e-8 |
Indicator saturation (isat) |
a planted outlier (1997Q3) and level shift (2005Q1) found at their dates, the shift's size within 0.5 of its true 3; the share of impulse indicators retained under no outliers near the target size (Johansen and Nielsen) | dates exact |
Specification sensitivity (specification_grid) |
every cell against its specification fitted directly: 18 VARs (lags, samples, Cholesky orderings; responses, BIC, portmanteau, stability), 24 equations (lags, deterministic terms, controls, classic and HAC errors; coefficients and standard errors, Breusch-Godfrey), BIC-chosen lags and IV, rolling windows, VECM ranks and cases, local projections, bootstrap bands, forecasts; the long-run multiplier's delta-method standard error and a VAR's long-run response by hand; the robustness shares, median, range, means by choice and variance shares against pandas; parallel runs against serial ones, failures included | 1e-12; exact |
| Interventions and transfer functions | the decaying pulse against a hand recursion; a step with ARIMA errors (SARIMA(interventions=...), TransferFunction without decay) against statsmodels' SARIMAX with that column, estimates and forecasts; a first-order transfer function's omega and delta recovered from simulated data within 3 standard errors; the effect path, its permanent and temporary parts and the forecasts' effect against omega_s + omega_p delta^k by hand |
1e-15; 1e-8; 3 s.e.; 1e-10 |
| AR(1) errors, multiplicative heteroskedasticity, frontier, J and Cox | Cochrane-Orcutt against statsmodels GLSAR at its rho; Prais-Winsten against GLS with the AR(1) covariance; Harvey's model and the frontier against their likelihoods maximised by general optimisers, and simulated values recovered; J and Cox against statsmodels' compare_j and compare_cox | 1e-10; 1e-10, s.e. 1e-8; 1e-5; 1e-10, 1e-8 |
| Kernel density, kernel regression, partially linear, nonparametric AR | densities and bandwidth rules against statsmodels' KDEUnivariate; the cross-validated bandwidth against KDEMultivariate's cv_ls; Nadaraya-Watson and local linear (fits, gradients, R^2) against KernelReg; their cross-validated bandwidths; Robinson's slope by hand from KernelReg's means | 1e-12; 1%; 1e-12, 1e-10; 1%; 1e-12 |
| Semiparametric GARCH | the QML step against arch (estimates, robust s.e.); the kernel step's RMSE of omega and beta below QML's under t(5) shocks over 20 samples; bootstrap s.e. of alpha against its robust spread | 2e-3, 10%; holds; factor 2 |
| ACH | the Bernoulli likelihood by a loop over periods; independent events showing no duration dependence and a hazard at the sample frequency; simulated values recovered | 1e-10; 3 s.e., 0.01; 3.5 s.e. |
| INAR, Poisson autoregression, ACD | transition probabilities by explicit summation; the Poisson likelihood and intensity by a loop; the exponential ACD as twice the Gaussian quasi-likelihood on square roots, near arch's GARCH; the Weibull likelihood by scipy's density; simulated values recovered | 1e-10; 1e-10; 1e-10, 0.01; 1e-10; 3 s.e. |
| Generalised IRFs, GARCH-in-mean, neural-network test | each shock's response against Cholesky with it first, and invariance to ordering; GARCH-in-mean without the in-mean term against arch (estimates, log likelihood, robust s.e.); the neural-network F by hand, size over 100 samples, power over 40 | 1e-12, 1e-10; 1e-5, 1e-10, 0.2%; 1e-10, 0.05 +- 0.05, > 70% |
| Max share, narrative restrictions, heteroskedasticity | max share at horizon 0 against Cholesky with the target first; its share against 2,000 random rotations and the FEVD; the news shock's zero impact; every narrative rotation by hand, and within the plain sign set; both regimes' covariances reproduced; a simulated impact matrix recovered from 3,000 periods; the variance decomposition in the first variance regime against the squared responses cumulated, its shares adding to one (tests/test_dialogs_var_extra.py) |
1e-10; holds, 1e-8; 1e-12; exact; 1e-10; 0.12; 1e-7 |
| SVAR by A-B restrictions | recursive A-B and B models against the Cholesky factor; long-run restrictions against Blanchard-Quah; an over-identified model against statsmodels' SVAR; B's standard errors against b / sqrt(2T); the LR statistic by hand and its size over 100 samples; combined restrictions holding exactly and the simulated impact recovered | 1e-7; 1e-7; 1e-6; 0.1%; 1e-8, 0.05 +- 0.06; 1e-10, 0.05 |
| FIML | exactly identified equations against 2SLS; one structural equation beside the reduced form against LIML (linearmodels); without endogenous regressors against iterated SUR (estimates; s.e., observed against expected information; log likelihood); the log likelihood with an identity's Jacobian by hand, above 3SLS's | 1e-6; 1e-6, s.e. 5%; 1e-6, 1%, 1e-9; 1e-10 |
| VECM restrictions | the reduced-rank regression's beta and log likelihood against statsmodels in all five cases; the beta test against least squares with the restricted beta; weak exogeneity against a conditional reduced-rank regression by hand; both tests' size over 60 samples | 1e-9, 1e-10; 1e-8; 1e-8; 0.05 +- 0.07 |
GMM on moment functions (MomentGMM): an Euler equation |
statsmodels' generic GMM (one-step sandwich, two-step and iterated estimates, standard errors and J; CUE; Newey-West); least squares as moments against OLS with White errors | 1e-6, 1e-5; CUE objective no higher; HAC s.e. 1e-3; 1e-8 |
| GMM flavours | CUE with homoskedastic S against LIML (linearmodels); the CUE objective by hand; the C test by hand (Hayashi's form) and against linearmodels' c_stat; an invalid instrument rejected; the Anderson-Rubin F by hand; its size over 200 samples with weak instruments (the t test over-rejects); Stock-Wright as the CUE objective by hand; minimum distance against GLS in the linear case |
1e-6; default; 1e-8, 0.2%; 1%; 1e-10; 0.05 +- 0.04; 1e-10; 1e-8 |
| Estimation by simulation | an MA(1) by indirect inference (AR(3) auxiliary) and EMM against exact maximum likelihood (statsmodels); geometric Brownian motion by indirect inference against its closed-form maximum likelihood; a normal's mean and standard deviation by simulated moments; the standard errors against the spread over 40 simulated samples | 1.5 s.e.; 2%, 0.05; 2/3 s.e., 3%; 35% |
| BVAR-SV, FAVAR, MS-VAR | the BVAR-SV coefficient step against SUR least squares and its covariance; a volatility break recovered (1 to 3; the other shock flat); the FAVAR's factors against the principal components' space, its loadings and a series' responses by hand, the slow-variable purge; a one-equation MS-VAR against statsmodels' MarkovRegression (likelihood, parameters); a simulated VAR's intercepts, transitions and regimes | 1e-10, 1e-6; 0.25, 0.6; 1e-10; 1e-10; 1e-6, 1e-3; 0.15, 0.05, corr > 0.9 |
| Spectra, GPH, local Whittle, ARFIMA | the periodogram against scipy.signal.periodogram; the variance recovered; an AR(1)'s smoothed spectrum against the true density; the Daniell average by hand; coherence and gain for a noisy multiple, small coherence for independent series; GPH's slope by hand; the local Whittle objective minimised; d = 0.3 recovered by all three; ARFIMA(1, d, 0) on an AR(1) | 1e-10; 1e-3; 5%; 1e-12; 0.99, 0.02; 1e-10; holds; 3 s.e.; 3 s.e. |
| Quantile VAR, spatial models, full VECH | each quantile equation against statsmodels' QuantReg; the responses by hand; the median system against the OLS VAR's recursive unit responses; a location-scale model's 10% and 90% responses; spatial lag and error estimates, s.e. and log likelihoods against spreg; Moran's I and the LM tests against spreg; the weights against libpysal; the full VECH's likelihood by a loop, no lower than the diagonal VECH's | 1e-5; 1e-12; 0.15; 0.2; 1e-6, 1e-5, 1e-10; 1e-8; exact; 1e-10 |
| TVP-VAR with stochastic volatility | the Kim-Shephard-Chib mixture against the exact log chi-squared(1) density and its mean; forward-filtering backward-sampling draws against the Kalman smoother's mean and variance; a simulated volatility break recovered; coefficients averaging near least squares; responses at a date from the draws by hand | 0.011, 1e-4; 4.5 Monte Carlo s.e., 5%; 0.15-0.4; 0.25; default |
| Proxy SVAR | the impact by its covariance formula by hand; the true column of a simulated non-recursive SVAR (Cholesky's misses it); the relative impact equal to LP-IV's horizon-0 coefficient with the same lags (an identity); responses as moving-average coefficients times the impact; the first stage by least squares | 1e-10; 0.06; 1e-10; default; 1e-8 |
| Staggered DiD with covariates | an uninformative covariate reproducing the unconditional estimate (outcome regression, IPW, doubly robust); outcome regression by hand; the true effect recovered and no pre-trend where trends depend on the covariate (the unconditional estimate biased) | 1e-10; 1e-10; 0.1 |
| Staggered DiD | an ATT(g, t) by hand from group means; growing effects recovered and no effect before adoption; Sun and Abraham equal to Callaway and Sant'Anna with never-treated controls (balanced, no covariates) | 1e-12; 4 s.e.; 1e-10 |
| Goodman-Bacon decomposition | weights summing to one and weighted estimates to the two-way fixed effects coefficient; that coefficient against linearmodels' PanelOLS with unit and period effects (independent) | 1e-12; 1e-10 |
| Panel VAR, within | linearmodels' PanelOLS with entity effects, equation by equation: coefficients and entity-clustered standard errors (no small-sample factors) (independent) | 1e-10, 1e-8 |
| Panel VAR, GMM on forward orthogonal deviations (just identified) | linearmodels' IV2SLS on data transformed by hand, clustered by entity (independent); the transform against its formula, and i.i.d. errors kept i.i.d. | 1e-10 (coefficients), 2% (s.e.); 1e-12, 0.03 |
| Panel VAR coefficients, Hansen's J | recovery from a simulated panel VAR with fixed effects (400 entities, 10 periods; the within estimator's Nickell bias shown); J not rejecting a correct model | 3.5 s.e. |
| Panel VAR Granger tests and responses | the Wald statistic by hand; responses' first steps from the coefficients and Cholesky factor | default |
| Cholesky and long-run (Blanchard-Quah) identification | the defining properties | 1e-8 |
| VECM bootstrap bands | the bootstrap rebuilding the data from the actual residuals in the five cases, with seasonal dummies and an exogenous series; its deterministic part explained by time terms alone; the spread of the levels-VAR coefficients against statsmodels' asymptotic standard errors (cov_var_repr; 1,000 draws) | 1e-10; 1e-10; 10% |
| VECM cointegrating relations | R urca 1.3.3 (ca.jo transitory, cajorls's normalised beta) applied to the data, constant restricted (ci) or not (co) | 1e-8 |
Models solved per entity (over=) |
each country's path by the recursion written out by hand, with shared parameters, a country's own and a country's own scenario | 1e-9 |
| Links between entities | the same three-country model written out by hand as one stacked model (each country's variables named apart, foreign variables as weighted sums) and solved by Newton: backward-looking with two links and their lags, a country's own parameter and scenario; forward-looking by perfect foresight with an anticipated shock; each link in the solution equals the weighted solutions; links from data equal the weighted data | 1e-8 |
| Draws of linked entities | each draw of the three-country model (errors drawn by hand with the same seeds, a country's own add factor and shift) against the stacked model solved with the same errors as add factors; the draw's links against the weighted stacked solution; the seed reproduces the draws | 1e-8 |
| Restricted VARs (feasible GLS) | linearmodels SUR (GLS, unadjusted covariance), one-step and iterated, with a block-exogenous variable and a single zero; least squares with no restrictions | 1e-10; 1e-12 |
| VAR and VECM residual correlograms | statsmodels VARResults.resid_acorr; the formula by hand on a VECM's residuals | 1e-12 |
| VAR and VECM roots | statsmodels' VAR roots (inverted); a VECM's K - rank unit roots | 1e-10; 1e-8 |
| Fluctuation test of the eigenvalues (bootstrap) | the statistic from the R-representation recursive eigenvalues by hand; size under constant parameters and power after alpha falls from -0.3 to -0.03 mid-sample, 200 samples of T = 200, 99 bootstrap draws | 1e-10; 3% at 5% (7% at 10%); 54% at 5% (69% at 10%) |
| Recursive Johansen eigenvalues (Z representation) | R urca 1.3.3 ca.jo on each truncated sample, constant restricted (ci) or not (co), three end dates | 1e-9 |
| VECM historical decomposition | each shock's contribution by the error-correction recursion from statsmodels' alpha, beta and gamma (the decomposition uses the levels VAR), five deterministic cases; the parts adding up to the data, with seasonal dummies and an exogenous series | 1e-8 |
| Panel VAR lag selection | MBIC, MAIC, MQIC by their formulas from each lag length's J with the same instruments (fitted directly); CD by hand; the lags of simulated VAR(1) and VAR(2) panels (500 firms, 12 years) found | 1e-10; 1e-10; exact |
| FAVAR additions | Bai-Ng ICp1-3 from their definitions (and three factors found in a clean three-factor panel); lags as select_order on the factor block; the bootstrap's VAR against VAR.fit; VAR-only bands as draws mapped by hand; panel FEVDs by hand; the whole-procedure bands covering a simulated true policy response |
1e-10; equal; 1e-10; exact; 1e-10; 75% of horizons |
| Zero and sign restrictions (ARW) | every draw's zeros (impact and long run) to 1e-10, its signs and B B' = Sigma, at the estimates, for bootstrap and for posterior draws; recursive zeros alone against Cholesky (every draw, up to the columns' signs; responses and FEVD); the importance weights constant without zeros and when just identified, the impact-only shortcut against the general volume element; against brute force: Sigma inverse-Wishart and Q uniform, kept within a thin tube around one zero's manifold in A0's coordinates (1,000,000 draws, 0.4% kept), the weighted ARW draws' quartiles of squared impact responses within 12% of the tube's, the unweighted ones off | 1e-10; 1e-10; 1e-7; 1e-6; 12% |
| MS-VAR starting values | the vectorised filter and smoother against the period-by-period Hamilton filter and Kim smoother (T 1 to 301, 2 to 4 regimes; densities 2000 log units apart); three simulated two-variable VARs (300 periods, regimes persisting with probability 0.97) whose regimes differ in the intercepts, the covariance, or everything: the fit's log likelihood against EM started from the true regime path (-791.49, -985.89, -897.82; the earlier fit reached -892.77 on the first), the smoothed probabilities' classification of the periods (100%, 100%, 99.3%); every earlier test's fit no lower than the earlier fit's recorded log likelihood; same seed, same fit; collapsed regimes recognised | 1e-10 (likelihood), 1e-13 (probabilities); 0.1; above 98%; 1e-7 |
| MS-VAR bands (parameter draws) | loglike_batch (the batched exact likelihood) against the fit's; the standard errors (inverse observed information) against statsmodels' MarkovRegression for one equation (intercepts, AR coefficient; variances and transition probabilities by the delta method); regimes sharing dynamics and covariance (only the intercepts switch, 300 periods): IRF and FEVD 90% band widths against the least-squares VAR's parametric bootstrap with the regime as a dummy; FEVD bands equal to the quantiles of each draw's shares, which add up to one; draws' covariances positive definite, transition rows summing to one; historical decomposition bands against the decompositions at each drawn parameter set (each adding up to the data); bands containing the estimates, reproducible by seed. Offline Monte Carlo (100 samples, MSIH, 90% bands, 500 draws): coverage of the true responses 0.87 to 0.88 on average, of the true variance shares 0.92 to 0.95 |
1e-9; 2e-3; ratio 0.92 to 1.10 (IRF), 0.81 to 0.96 (FEVD); 1e-12; 1e-12; 1e-4 (quantile interpolation); — |
Generalised impulse responses (girf, tests/test_girf.py) |
a threshold AR, smooth-transition AR and threshold VAR with identical regimes against the linear responses sd phi^h and the VAR's Cholesky responses, for sizes 1, -1, 2.5 and 2 (antithetic draws make them exact); a VAR's own irf through a threshold VAR with both regimes at its coefficients; an MS-VAR (everything switching) with the regime held against irf(regime=j) for each regime; a simulated threshold AR (0.9 at or below zero, 0.1 above, 400 periods): held-regime responses persistent below and dying out above, evolving ones between them, a negative shock in the low regime more persistent than a positive one, and 2 sd not twice 1 sd; same seed, same responses and bands |
1e-10; 1e-9; 1e-12; holds; exact |
| BVAR-SV, MS-VAR and quantile VAR decompositions | a BVAR-SV draw with constant volatilities at the least-squares VAR (A and D from Sigma's LDL factors): FEVD at any date and the historical decomposition (contributions, baseline, shocks) equal FittedVAR's; fitted draws' FEVD at a date against the Cholesky shares of that date's covariance A^-1 D_t^2 A^-T; every draw's (and the mean's) parts adding up to the data; contributions unchanged by any volatility path; an MS-VAR with identical regimes (and a random, often-switching regime path) equal to FittedVAR's FEVD and historical decomposition; a fitted MS-VAR's contributions against brute-force sums over the regime path's lag-matrix products, its baseline's regime intercepts; FEVD rows adding up to one; a median quantile VAR's FEVD of a Gaussian VAR(2) (800 periods) against the least-squares VAR's; a quantile VAR's generalised FEVD by hand (loops over the moving average and the residual covariance), on impact sigma_ij^2 / (sigma_ii sigma_jj) normalised, and Cholesky's with uncorrelated residuals |
1e-12, 1e-10; 1e-12; 1e-10; 1e-10; 1e-12, 1e-10; 1e-10; 1e-12; 0.03; 1e-12 |
| Historical decomposition bands | for every posterior draw (and every rotation of a sign or zero-sign set, at the estimates and over posterior draws) the contributions plus the baseline equal the data; the point decomposition unchanged with bands; the per-draw recursion against the moving-average sums; lower <= median <= upper; a point-identified VAR's bootstrap replications the ones irf uses, each with its own Cholesky impact, adding up to the data, the point within the bands in 80% of periods |
1e-10; exact; 1e-10; exact; exact, 1e-10 |
| Panel VAR and proxy SVAR historical decompositions | the parts adding up to each entity's data, for GMM on forward orthogonal deviations and within least squares, at the estimates and under perturbed coefficients and rotated impact matrices, and to the data for every moving-block bootstrap draw of a proxy SVAR; a one-entity panel by within least squares against the ordinary VAR with a constant (contributions, baseline; the fixed effect equal to the constant); a simulated SVAR (2,000 periods) with the true shock as the proxy: the identified contribution against the true shock's (demeaned) contribution through the true VAR; the contribution independent of the shock's scale; lower <= median <= upper, the point within the bands in 90% of periods | 1e-10; 1e-9; correlation > 0.99, RMSE < 10% of its sd; 1e-10; exact |
| VAR historical decomposition | each shock's contribution by the companion-form recursion from statsmodels' coefficients, residuals and sigma_u, and the baseline simulated from its intercept and coefficients; the parts adding up to the data under long-run, max-share and sign restrictions and for a BVAR; simulated structural shocks recovered (600 periods) | 1e-10; 1e-10; correlation > 0.98 |
| VECM: estimates, forecasts, tests, lag selection | statsmodels (wrapped) | default |
| BVAR marginal likelihood (conjugate Minnesota) | SciPy multivariate t density | 1e-9 |
| BVAR posterior mean and covariance | closed form | default |
| BVAR limits: loose prior and tight prior | OLS; the prior mean | 1e-6; 1e-4 |
| BVAR, independent normal-Wishart (Gibbs) | an AR(1)'s exact posterior means (the variance by quadrature, the coefficients in closed form given it); a two-variable VAR's closed-form posterior given a Sigma the prior pins down; a loose prior against OLS; a tight prior against its mean | 0.003; four Monte Carlo s.e.; 0.01; 0.01 |
| BVAR, hierarchical prior (GLP) | GLP's eigenvalue formula for the log marginal likelihood against the conjugate one (_niw) at fixed hyperparameters, with and without the dummy observations; the gamma hyperpriors' modes and standard deviations; the mode a local maximum of the hyperparameters' log posterior; MCMC over the hyperparameters (one variable: tightness and psi) against their posterior integrated on a 110 x 110 grid (means within 4 Monte Carlo standard errors); with the lag decay a hyperparameter, the joint mode against the maximum of the profile over a grid of fixed decays (each the mode plus the decay's log hyperprior). GLP's published estimates were not reproduced (their data and code were not available offline) |
1e-8 (formula); 4 MC s.e. |
| BVAR, independent normal-Wishart: Chib's marginal likelihood | one variable: the exact log marginal likelihood by quadrature over sigma^2 (the coefficients integrated in closed form), without and with a dummy observation; two variables: importance sampling from the prior (200,000 draws); the search raising Chib's estimate above the starting hyperparameters' | 0.01 to 0.02; 4 IS s.e. |
| BVAR posterior draws | analytic posterior moments | Monte Carlo error |
| DSGE-VAR prior moments | the uncentred moments of 200,000 periods simulated from the New Keynesian template through its measurement equations (growth from a lagged state) | 0.02 of each moment's Cauchy-Schwarz bound (error about 0.003) |
| DSGE-VAR marginal likelihood p(Y given theta, lambda) | the normal-inverse-Wishart identity p(Y) = p(Y given Phi, Sigma) p(Phi, Sigma) / p(Phi, Sigma given Y) at the posterior mean and at a point far from it, each density from scipy, three values of lambda and two of theta | 1e-7 absolute |
| DSGE-VAR limits in lambda | the posterior mean the precision-weighted average of least squares and the model's VAR; moving monotonically from least squares to the model's population projection as lambda grows, the projection itself at lambda = 1e7 | 1e-10; 1e-6 |
| DSGE-VAR responses (the model's rotation) | the model's own responses, at lambda = 1e6 for a fully observed model that is exactly a VAR(1) with a non-triangular impact; the rotation orthonormal and the factor lower triangular | 1e-4 relative |
| DSGE-VAR lambda-hat | the grid's maximum; the hump (rising, then falling) for data from the model with another intertemporal elasticity; Dynare's dsge_var/dsge_prior_weight read as the same estimate by hand | 1e-6 |
State space, filters and seasonal adjustment¶
| Method | Checked against | Agreement |
|---|---|---|
| Kalman filter and smoother (native), with missing data | statsmodels state space | 1e-7 (log likelihood) |
Diffuse log likelihood, both conventions (diffuse_terms) |
statsmodels' exact diffuse filter: the default against its log likelihood, "exclude" against it with the diffuse periods burnt in (loglikelihood_burn = nobs_diffuse), on a local level, a local linear trend, a local linear trend with a quarterly seasonal and an ARIMA(1,1,1) (SARIMAX), and a random-walk DSGE estimate; statsmodels' default approximately diffuse likelihood (1e-3, its own approximation); the offset against d/2 log 2pi + 1/2 log det(X X') for d = 1, 2, 3, 5 at three parameter values, both engines |
1e-8; 1e-9 |
| Soft filter tunes | a tiny standard deviation pins the smoothed value; a large one barely moves it; none or 0 gives the exact result unchanged; met more closely as the standard deviation shrinks | 1e-8; 1e-5; identical |
Smoothed shocks (filter(shocks=True)), both engines |
x(t) - P x(t-1) = Q e(t) on the smoothed path; the smoothed states of the same model with the shocks carried as states (e(0) included); the native disturbance smoother's identity R eta(t) = a(t+1) - c - T a(t) | 1e-12; 1e-9; 1e-12 |
| Least-norm plans and soft holds | the weighted minimum-norm and soft solutions computed with numpy from responses taken from separate simulations; square plans against the paired solution | 1e-10 |
| Decompositions from a pre-sample state | the parts add up to the path in both modes; the two modes converge as P^t | 1e-12 |
| Identification without data | the same Identification as fitting and testing at the same point (levels and elasticities); a product of two parameters one short of full rank; pairwise collinearity by hand | 1e-12 |
| Dynare measurement errors on varobs | the log posterior and estimates of the model written by hand with a MeasurementMap carrying the errors | 1e-8; 1e-6 |
| Posterior by Metropolis-Hastings | the posterior of an AR(1) coefficient integrated exactly on a grid: mean (within 4 Monte Carlo standard errors), standard deviation, log marginal data density by modified harmonic mean and Laplace | 8%; 0.05 |
| Sequential Monte Carlo | the AR(1) posterior and log marginal data density against the exact ones on a grid; both modes of a coefficient that enters squared; the New Keynesian posterior against Metropolis-Hastings, its density against Laplace; the same draws in one process or several | 4 Monte Carlo SE, 8%, 0.08; 0.3 |
| NUTS on a linearised model | the New Keynesian template (kappa, rho; 120 simulated quarters): 2 x 300 NUTS draws against 2 x 2,500 Metropolis-Hastings draws and 600 SMC particles, posterior means within 2 combined Monte Carlo s.e. of Metropolis-Hastings's (0.11 and 0.09 posterior s.d.) and 0.11 and 0.07 s.d. of SMC's, s.d. within 6% and 11% (run by hand; the test suite checks an AR(1) model's posterior on a grid) | 2 MC s.e. |
| The analytic gradient of the Kalman likelihood | against five-point central differences of the log likelihood as the statsmodels filter computes it: the New Keynesian template with measurement errors and a correlation of shocks (eleven parameters of every kind), Schorfheide's cash-in-advance model in Dynare's syntax (read_mod, loglinear, leads of two periods, nonlinear steady state; nine parameters), the growth model with log measurement equations, a model with a two-period lag, a static and a forward-looking variable, missing observations, a presample and each start (stationary, scaled); the posterior mode and standard errors against those with finite differences; the Hessian from the gradient against a five-point Hessian of the log posterior (standard errors within 0.2%). The filter's adjoint alone on a random five-state system whose every matrix moves (300 periods, the variance converged and taken up again after a missing observation, a presample, stationary and fixed starts) against five-point differences of a textbook filter written apart (1e-7); Smets and Wouters (2007) at Dynare's mode (36 parameters, 27 states, scaled start), twelve parameters of every kind against five-point differences (1e-6; the forward-mode recursion it replaced overflowed there). Measured by hand (Dynare's fs2000 files could not be downloaded here): the cash-in-advance model's gradient agrees with differences at the best step to 1e-11; all 36 Smets-Wouters parameters within 1e-7 at the best step. Timings (one BLAS thread, best of several, a shared machine): New Keynesian template (7 parameters, 100 quarters) a log posterior 3.3 ms, a gradient 6.7 ms (was 20.6); Smets and Wouters (36 parameters, 230 quarters) a log posterior 11.6 ms (was 17.3), a gradient 41 ms (was 282). One chain, NUTS 300 warmup + 300 draws against random-walk Metropolis-Hastings: template, NUTS 67 s, smallest effective sample 147 (2.2 a second, was 0.89), Metropolis-Hastings 6,000 + 6,000 in 53 s, 163 (3.1 a second); Smets and Wouters from the posterior mode, NUTS 1,394 s, smallest 11.7, median 93 (0.008 and 0.066 a second; mean tree depth 5.4), Metropolis-Hastings 20,000 + 20,000 in 564 s, smallest 4.8, median 47 (0.009 and 0.083 a second); posterior means agree within Monte Carlo error in both (details in docs/design.md) | 1e-6 relative |
| NUTS's mass matrix; the compiled filter | the dense metric on a six-dimensional Gaussian, every pair correlated 0.99, scales 0.1 to 10: means within 4 Monte Carlo s.e.; whitened by the true covariance, the draws' covariance within three times the Marchenko-Pastur edges at their effective sample size, and the adapted metric within a factor of 4 in every direction and 30% in scale, under every OpenBLAS kernel (Haswell, Zen, SandyBridge, Nehalem, SkylakeX); the adapted metric exactly Stan's regularised covariance of its last slow window (to 1e-10); and more than 10 times the diagonal metric's smallest effective sample per gradient (about 50 times, measured); a fixed dense metric (adapt_metric=False) kept, with short trees; a regression whose intercept and slope correlate about -0.99 (flat priors: the t posterior around least squares) with metric="dense" and "mode", each under a third of the diagonal metric's gradients; an AR(1) model's posterior on a grid with both. The numba kernels against the NumPy loops: the log likelihood and every adjoint of a random six-state system (missing observations, a presample, a converged variance) to 1e-10 relative; the plain log likelihood against the native filter to 1e-10 and statsmodels' to 1e-9; the New Keynesian template's gradient to 1e-10. Benchmarks by hand (one BLAS thread; a machine shared with other jobs, load 2 to 5, so seconds are loose and effective samples per gradient are given too), New Keynesian template (7 parameters, 100 quarters), 1,000 draws after 500 warmup (150 for "mode"), Metropolis-Hastings for about the same time: one chain with numba, smallest effective sample a second (and per 1,000 gradients after warmup) diagonal 4.2 (50), dense 10.5 (118), mode 16.0 (162), Metropolis-Hastings 4.1 (15,796 + 15,796 draws); without numba 3.1, 9.0, 12.1 and 2.3; four chains on four processes (workers=4) 4.9, 13.1, 33.6 and 7.1, R-hat at most 1.004; posterior means within 2.2 combined Monte Carlo s.e. of Metropolis-Hastings's (dense 1.4, mode 1.9), s.d. within 10%. Smets and Wouters (2007) from the posterior mode, one chain: dense 0.023 a second (2.4 per 1,000 gradients; smallest effective sample 78, median 437, mean depth 5.1, no divergences), diagonal 0.010 (0.8; smallest 29, median 280, depth 5.2, 7 divergences), mode 0.006 (0.3; smallest 5, 22 divergences), Metropolis-Hastings 0.005 (61,801 + 61,801 draws in 1,115 s; smallest effective sample 5, median 98; the slowest parameters in every sampler crhob, sd_eb, chabb). Posterior means against Dynare 6.0's (2 chains of 200,000, tests/fixtures/dynare-sw2007.json): dense within 0.14 posterior s.d. (one of 36 beyond 2 Monte Carlo s.e., at 2.4), diagonal within 0.21, mode within 0.77 (its s.d. up to 3 times Dynare's), the equal-time Metropolis-Hastings chain within 0.64 (13 of 36 beyond 2 s.e.: it had not mixed); dense and diagonal NUTS agree with each other within 2 s.e. on every parameter. A gradient with and without numba, in one session: template 4.4 and 8.0 ms, a log posterior 2.3 and 4.3 ms; Smets and Wouters 40 and 49 ms, 7.2 and 13.4 ms |
4 MC s.e.; 1e-10 |
| MCMC diagnostics | effective sample size of AR(1) chains against n(1-phi)/(1+phi); split R-hat; HPD of normal and exponential draws | 10%; 0.01; 0.03 |
| Identification (Iskrev) | the Jacobian of an AR(1)'s mean and autocovariances against the analytic one; a product of two parameters found not identified | 1e-5 relative |
| Estimating a linearised model (maximum likelihood) | statsmodels SARIMAX on an AR(1) model; recovery of New Keynesian parameters from simulated data | 1e-4 (estimates), 1e-7 (log likelihood); within 3 standard errors |
| Exact diffuse initialisation | statsmodels | 1e-9 |
| Unobserved components | statsmodels UnobservedComponents; recovery | 1e-3 |
| HP, Baxter-King, Christiano-Fitzgerald; one-sided HP | statsmodels (independent) | default; 1e-8 |
| Hamilton filter; moving averages | statsmodels OLS; pandas rolling means | default |
| STL, classical decomposition | statsmodels (wrapped) | default |
| Calendar regressors (trading days, Easter, leap years) | the calendar | exact |
| AR errors with GARCH variance: estimates, log likelihood, multi-step forecasts | arch (AR mean, GARCH volatility) | 1e-4; 1e-6; 1e-4 |
| ARMA errors with GARCH variance | R fGarch 4032.91 garchFit(~arma(1,1)+garch(1,1)) (it starts its recursions differently) |
0.2 standard errors; standard errors 5% |
| ARMA-GARCH multi-step forecast variances | the fitted process simulated forward | 5% |
| Dynamic forecasts, y on its lag with ARMA(1, 1) errors: means and standard errors | statsmodels ARIMA(2, 0, 1) at the same parameters (exact Kalman filter) | 1e-6 |
| Dynamic forecasts, y on its lag with GARCH(1, 1): means and variances | arch's AR(1)-GARCH(1, 1) at the same parameters (analytic) | 1e-4 |
| Dynamic forecasts, dlog(y) on two of its lags and x with ARMA, ARMA-GARCH or GARCH errors | the equation solved as a model; its stochastic simulation (20,000 draws) | 1e-10; 5% (variances) |
| Dynamic forecasts with other functions of the dependent variable (y ~ d(y)[-1] + x, AR(1) errors) | the recursion written out | 1e-10 |
| Stochastic simulation of a fitted AR(1): forecast mean, standard deviation, 5% and 95% quantiles | the exact normal forecast distribution | four Monte Carlo standard errors (20,000 draws) |
| Stochastic simulation of two equations with correlated errors | statsmodels VAR forecast MSE (sigma_u with n - k) | 5% (covariances); point forecasts 1e-8 |
| Stochastic simulation of a nonlinear equation (dlog random walk) | the exact lognormal quantiles | 0.3% |
| Bootstrapped errors; coefficient draws | the residuals themselves (every one-step draw is one); the one-step variance s^2 + x'Vx | exact; four Monte Carlo standard errors |
| Forecasts from a posterior (parameter uncertainty), an AR(1) | each draw's forecast rho^h y_T at that draw; the one-step predictive mean E[rho] y_T and variance E[sd^2] + Var(rho y_T) | 1e-12; four Monte Carlo standard errors |
| A model of one equation with ARMA errors (AR, ARMA, MA), ARMA-GARCH or GARCH, solved; also after a 40-period gap | the equation's own dynamic forecast | 1e-10 |
| Stochastic simulation of those models (normal, t, bootstrapped errors) | the equation's forecast variances (ARMA weights and the GARCH variance path); its forecast means | 5%; four Monte Carlo standard errors (20,000 draws) |
| Stochastic simulation of a first-order solution | the h-step variance from the decision rules; theoretical moments (Lyapunov) | four Monte Carlo standard errors; 2% |
| TRAMO's estimates (JDemetra+ 3.9): airline MA parameters; six trading-day and leap-year coefficients | statsmodels SARIMAX, exact ML on the same differenced regARIMA model with a constant | 2e-4; 1e-5 |
| SEATS (JDemetra+ 3.9) | x13as 1.1's SEATS given TRAMO's model (MA parameters and mean fixed), monthly and quarterly, logs and levels | 5e-4 relative (2e-4 mid-sample) |
| TRAMO outliers | an additive outlier and a level shift planted in a simulated series | found at their dates |
| TRAMO interventions and user regressors | generalised least squares by hand on the differenced series, given TRAMO's ARIMA parameters; an effect assigned to the irregular changes the adjusted series by exactly the effect; planted effects recovered | 1e-6; 1e-8 |
| TRAMO-SEATS through pymetrix's bridge | Eurostat's R interface to the same JDemetra+ (rjd3tramoseats, from CRAN), five of R's datasets (AirPassengers, UKgas, USAccDeaths, nottem, UKDriverDeaths) with each of RSA0 to RSAfull; made afresh in CI weekly, on demand and on every pull request that touches seasonal adjustment (jdemetra-reference.yml) |
adjusted series 1e-8 relative; model, logs and outliers identical |
Systems and panels¶
| Method | Checked against | Agreement |
|---|---|---|
| SUR (one-step and iterated), 3SLS | linearmodels (independent); GLS formula | 1e-10 (iterated coefficients 1e-7) |
| Random effects, between, first differences, Fama-MacBeth | linearmodels (wrapped); between also against OLS on entity means | default |
Hausman test (and Stata's sigmamore) |
textbook formula | default |
| Arellano-Bond, exactly identified | linearmodels IV2SLS on differenced data | 1e-10 |
| Arellano-Bond and Blundell-Bond estimates; Windmeijer s.e. | recovery; Monte Carlo spread of estimates | within 0.08; ratio 0.7-1.3 |
Double/debiased machine learning (tests/test_double_ml.py) |
PLR without cross-fitting against OLS (Frisch-Waugh-Lovell) and PLIV against 2SLS; cross-fitted PLR, its score variance, clustered variance and the median aggregation coded from the result's folds; IRM's ATE and ATT scores by hand; the DoubleML package's PLR and IRM (ATE) on the same folds with least-squares learners (where installed); bias and 95% coverage over 150 (PLR) and 100 (IRM) simulated samples; the IV-type score by hand and against DoubleML 0.11.4's IV-type PLR and PLIV; two-way clusters' product folds, and DoubleML's two-way clustered PLR (both scores), PLIV and IRM on the same folds; two-way coverage over 60 samples with firm and year shocks; the sensitivity analysis's bounds, robustness values (closed form for RV) and benchmark against DoubleML's sensitivity_analysis and sensitivity_benchmark (PLR both scores, IRM ATE and ATT; its lower and upper standard errors are swapped relative to ours, see pymetrix.dml) |
1e-10; 1e-12, 1e-10; 1e-10; 1e-8 and 1e-6 (PLR), 1e-5 and 1e-4 (IRM, our logit's tiny ridge); 3 MC s.e., 0.89-0.99; 1e-10 and 1e-9; 1e-10, 1e-9 (IRM 1e-5, 1e-4); 0.85-1; 1e-8 (IRM 2e-4), RV 1e-4 (DoubleML's numerical search) |
Causal forests (tests/test_causal_forest.py) |
recovery of a step in the effect (RMSE, the gap between the two groups) and 85-100% coverage of the pointwise intervals in simulated data, 0/1 and continuous treatments; the ATE, its standard error, the ATT and the AIPW identity of the doubly robust scores coded by hand; the best linear projection's coefficients against least squares; the calibration test near 1 and 1 with heterogeneity, and no heterogeneity found without it; the clustered standard error and the out-of-bag rule by cluster; checked once by hand against EconML 0.17.1's CausalForestDML (least-squares nuisances, 2,000 trees, 3,000 simulated observations; not a test, EconML is not a dependency): the ATE 1.4851 (s.e. 0.0386) against 1.4856 (0.0386), the individual effects correlated 0.99 with the same RMSE against the truth (0.159), pointwise coverage 0.95 against 0.94 (ours out of bag, so wider intervals) |
1e-12, 1e-10; MC bands |
LightGBM and XGBoost learners (tests/test_boosting_learners.py) |
in-sample predictions, every setting and the expanding-window cross-validated RMSE against lightgbm.LGBMRegressor and xgboost.XGBRegressor called directly with the same data and arguments; out-of-sample forecasts against the model's own predict; double ML's cross-fitted PLR with LightGBM or XGBoost nuisances against the libraries' estimators fitted by hand on the result's folds |
exact (one thread, deterministic modes), 1e-12 relative for the CV RMSE; 1e-10 |
SHAP values (tests/test_shap_values.py) |
shap.TreeExplainer and shap.explainers.Exact called directly; LightGBM's and XGBoost's own TreeSHAP (pred_contrib); additivity (contributions plus the base value equal the prediction); for a linear model, the hand formula b_j (x_j - mean x_j) with the base value the mean prediction, by the exact and the permutation explainers; the seeded background sample redrawn by hand |
1e-12 (shap), 1e-10 (LightGBM), 1e-5 (XGBoost, single precision); additivity 1e-10 (1e-5 XGBoost); 1e-8 |
Conformal intervals (tests/test_conformal.py) |
split conformal by hand (least squares on the training periods, absolute-error scores, the rank ceil((n + 1)(1 - alpha)) in exact rational arithmetic); MAPIE 1.x's SplitConformalRegressor with the same model and calibration periods (where installed); CQR by hand with scikit-learn's and LightGBM's quantile learners; ACI's recursion by hand and its bound on the miss rate (Gibbs and Candès 2021, Proposition 4.1); coverage over 200 (split, 20 calibration and 50 new periods) and 60 (CQR) simulated samples against its exact mean k / (n + 1) |
1e-12; 1e-10; 1e-12; exact; 3.5 standard errors of the mean from the Beta(k, n + 1 - k) conditional coverage plus binomial noise (about 0.019 and 0.035) |
Shift-share IV (tests/test_shift_share.py) |
the coefficient against pymetrix's 2SLS with the built instrument; Borusyak-Hull-Jaravel's shock-level IV equal to the regional IV (with and without regression weights) and its exposure-robust error by formula; AKM and robust errors by loops on six regions and three industries (and AKM0 unbounded there, as it must be with three shocks); the AKM0 set's end points solving the null-imposed test; Rotemberg weights summing to one and reproducing the estimate, beta_k against 2SLS with share k alone; coverage with industry-correlated errors (robust undercovers, AKM0 near 95%); errors clustered by region (region_clusters) against pymetrix's IV with cov=Cluster(...), with and without weights |
1e-10; 1e-12; 1e-10; 1e-9; 1e-12, 1e-10; over 150 samples; 1e-10 |
Interactive fixed effects (tests/test_interactive_fe.py) |
known factors driving the regressors: beta within 0.03 where two-way FE is off by more than ten times that; the estimate a fixed point of Bai's iteration and no worse than the truth in the concentrated SSR; no factors against pooled OLS, unit FE and two-way FE (coefficients and s.e.); Bai and Ng's criteria picking the true number; the bias correction against Bai's B and C coded with loops; coverage over 40 samples | 0.03; 1e-7; 1e-10, 1e-8; exact; 1e-10; 0.85-1 |
Conditional logit (tests/test_conditional_logit.py) |
Chamberlain's logit against statsmodels' ConditionalLogit on the wage panel (estimates, s.e., log likelihood); Howard's recursion against enumerating every subset; McFadden's model against its likelihood coded by hand and maximised by scipy, with varying choice sets; the same estimates as the panel code with cases as groups, and as statsmodels' | 1e-6; 1e-12; 1e-4 (estimates), 1e-8 (log likelihood); 1e-10, 1e-6 |
Conditional logit discrete changes (tests/test_clogit_discrete.py) |
0/1 attribute and characteristic changes from 0 to 1, and changes by an amount, against the probabilities recomputed from the data (varying choice sets), averaged and at the means; columns summing to zero; a change of 1e-6 over its size against the derivative; the 1996 ANES party identification with vote (0/1) against statsmodels' MNLogit get_margeff(dummy=True) (overall and at the means; effects and standard errors), and a change of educ by 2 against its predictions; delta-method standard errors against 2000 draws of the coefficients; the panel logit's at a fixed effect against Lambda(a + x'b) by hand |
1e-13; 1e-13; 1e-6; 1e-8, rtol 1e-4 (errors); 1e-8; 8%; 1e-14 |
Margins (tests/test_margins.py) |
logit, probit and Poisson average effects and effects at the means (0/1 regressors as discrete changes) on Mroz against statsmodels' get_margeff(dummy=True) (effects and s.e.); the effect of x through x, x^2 and x*z against the closed forms (average and at the variables' means); a log term against a finite difference by hand; predictive margins, effects at profiles, contrasts and discrete changes (two values, an amount, one SD) against predictions recomputed by hand; a linear equation's effects and s.e. against the linear combination of its coefficients; models without such terms against the old term-by-term calculation; ordered probabilities summing to one at each profile |
1e-5 (effects), 2e-3 (s.e.); 1e-6; 1e-5; 1e-10; 1e-6, 1e-5; 1e-9; 1e-8 |
Conditional logit marginal effects (tests/test_clogit_effects.py) |
average derivatives and elasticities against finite differences of the probabilities recomputed from the data (varying choice sets); at the means against the closed forms and finite differences, with IIA's equal cross elasticities; cross effects summing to zero; delta-method s.e. against a parametric bootstrap (2000 coefficient draws); the 1996 ANES party-identification multinomial logit written as a conditional logit against statsmodels' MNLogit and get_margeff (average and at the means); panel odds ratios, and effects at a fixed effect against the formula and finite differences |
1e-6; 1e-12, 1e-6; 1e-12; 8%; 1e-8 (effects), 1e-4 (s.e.); 1e-6 |
Nested logit (tests/test_nested_logit.py) |
Biogeme 3.3.5's recorded estimates on Greene and Hensher's travel-mode data (statsmodels' modechoice): two nests of two (estimates, Rao-Cramer and robust s.e., log likelihood) and Greene's nests with air alone; every lambda 1 against choice_logit (estimates, s.e., log likelihood, probabilities); the likelihood at lambdas of 1 against the conditional logit's; probabilities against McFadden's GEV formula coded in the test; the analytic gradient against central differences (varying choice sets); marginal effects against finite differences of the GEV probabilities; recovery of the truth from 5000 simulated trips with lambda 0.5 |
rtol 1e-4 (Biogeme stops at a gradient of 4e-6), 1e-3 (s.e.), 1e-7 (log likelihood); 1e-8; 1e-10; 1e-12; 1e-6; 1e-6; 3.5 s.e. |
Mixed logit (tests/test_mixed_logit.py) |
xlogit 0.2.7's recorded estimates on the same 100 Halton draws (lognormal and normal coefficients, with and without a panel): our simulated log likelihood at xlogit's estimates against xlogit's, estimates and s.e.; the Halton draws against the radical inverse coded in the test; the analytic gradient against central differences (uncorrelated and correlated); recovery of means, the Cholesky factor and a correlation of 0.6 from 1000 simulated people (200 draws); conditional means and averaged effects recomputed from the draws | 1e-8; 1e-5, rtol 1e-4; 1e-12; 1e-6; 3 s.e.; 1e-12 |
Survival (tests/test_survival.py) |
Kaplan-Meier, Greenwood and log-log intervals by hand on seven subjects; Freireich's leukaemia trial against the published estimates (Kleinbaum and Klein, Survival Analysis: A Self-Learning Text, 3rd ed., chapters 2 and 3: S(t) of the 6-MP group, log-rank 16.793, Cox 1.509 (0.410) with Breslow's ties and 1.572 (0.412) with Efron's) and against statsmodels' SurvfuncRight, survdiff and PHReg called directly (also with entry times, strata and clusters, the clustered sandwich with entry times by loops over the risk sets); lifelines 0.30.3's recorded Cox estimates, robust s.e. and proportional-hazards tests (km, rank, identity and log transforms) and its log-log intervals; the global Grambsch-Therneau statistic by hand | 1e-15; printed decimals; 1e-12; rtol 1e-6, 1e-10; 1e-12 |
Survival, second batch (tests/test_survival_completion.py) |
Cox curves (native): H0 against statsmodels' baseline_cumulative_hazard (shifted one event time: statsmodels gives it just before each); Tsiatis' variance against loops and a numerical derivative of the Breslow hazard. Counting-process Cox: spells cut at event times reproduce the unsplit fit (Breslow and Efron), equal PHReg with the starts moved to the next float, and a hand-coded partial likelihood with a time-varying covariate; the counting-process sandwich against loops (statsmodels' differs: its score residuals keep a spell whose (start, stop] holds no event time at risk at earlier event times). Entry times without id=: at risk in (entry, stop] (PHReg with the entries moved to the next float, the id= path, a hand-coded partial likelihood), robust and clustered Lin-Wei sandwiches by loops; without entry times the fit is PHReg's bit for bit. Nelson-Aalen by hand and against SurvfuncRight's numbers at risk. Parametric models (native): the exponential against statsmodels' Poisson GLM with a log-time offset; uncensored Weibull and log-logistic against scipy.stats' weibull_min.fit and fisk.fit, the log-normal's closed form; the likelihood with censoring and delayed entry from scipy.stats' distributions; predictions against their medians, means, survival and hazards. Aalen-Johansen (native): with one cause, 1 - Kaplan-Meier and Greenwood's variance; causes and survival add to 1; the Marubini-Valsecchi variance in loops |
1e-12; 1e-7; 1e-9; 1e-14; 1e-8 (s.e. rtol 1e-6); 1e-4 (scipy's optimiser); 1e-9; 1e-13 |
Forecasting, mixed frequency and other methods¶
| Method | Checked against | Agreement |
|---|---|---|
| ARDL estimates | statsmodels (wrapped) | default |
| ARDL long-run multipliers | formula | 1e-8 |
| Markov switching | statsmodels (wrapped); recovery of simulated regimes | 1e-6 (log likelihood) |
| Unrestricted MIDAS | statsmodels OLS | default |
| Bridge equations | OLS on quarterly means by hand; the nowcast step by step (AR fill, average, equation) | 1e-10 |
| Mixed-frequency dynamic factor model | statsmodels DynamicFactorMQ called directly; nowcast from its smoothed prediction |
1e-8 |
| News decomposition | identity: impacts plus revisions equal the change in the nowcast | 1e-10 |
Nowcast densities (tests/test_nowcast_uncertainty.py) |
factor model: the variance against DynamicFactorMQ's own get_prediction(...).var_pred_mean (fitted directly), the interval against its conf_int; bridge with no month filled: statsmodels OLS get_prediction (se_obs) on the quarterly means; bridge with months filled: the 90% interval's coverage of 20,000 outcomes drawn from the true process (0.87 to 0.93), and the standard error against their spread; U-MIDAS: OLS get_prediction on the lag design; log score, CRPS and PIT against the normal formulas |
1e-10; 1e-10; 0.03 (coverage), 8%; 1e-10; 1e-12 |
| Factor blocks and the full sample | DynamicFactorMQ called directly with the same blocks (parameters, log likelihood, nowcast and its variance), and on the uncut data with a series starting five years late (the default cut against the data from that year) |
1e-8 |
Nowcast backtest by release day (tests/test_nowcast_backtest.py) |
the factor model at fixed parameters: each day's nowcast against a direct fit on as_of data of the estimation day, updated to that day's data; RMSE, MAE, relative RMSE and Diebold–Mariano by horizon by hand; the AR(1) benchmark by least squares written in the test |
1e-10 |
| Nowcast tracking | identity: chained news, revisions and re-estimation equal each day's change and the total change in the nowcast; the first day against a direct fit | 1e-8 |
Masks and outliers (tests/test_nowcast_masks.py) |
the factor model with a masked range, per-series masks and the IQR rule against DynamicFactorMQ fitted directly on the data with those values set to NaN (parameters and nowcast); the outliers against the IQR and scaled-MAD rules applied by hand; the bridge equation with masked quarters against statsmodels OLS without them (lags kept); U-MIDAS with masked quarters against least squares on the lag design |
1e-10; exact; 1e-10; 1e-10 |
Release calendars (tests/test_nowcast_realtime.py) |
as_of with a calendar built from fixed lags against as_of (exactly equal data on four days); a crafted calendar of an employment release and retail sales gives the availability worked out in the test; backtests with that calendar equal those without it, and move when a release is a week later |
exact; exact; 1e-12 |
| ALFRED vintages and revisions | the vintage table from a recorded ALFRED response (every value, vintage date, first and second release, latest and first-release date checked by hand); revision means, standard deviations, mean absolute revisions, noise-to-signal ratios and t statistics by hand; Mankiw and Shapiro's news and noise regressions against statsmodels OLS (coefficients, standard errors, F and p-value) | exact; 1e-12; 1e-10 |
| Real-time nowcast backtest | on a crafted two-vintage example, each day's data equal the vintage in force that day as published by then (and the growth rate made from it), and each day's nowcast equals a bridge fitted on those data | 1e-12; 1e-10 |
Scoring against a chosen release (outturn=) |
on crafted vintages of the target, each nowcast's outturn and error against the first and the second release worked out in the test (a quarter without that release unscored); a target derived from vintages of its level against 400 times the log change within the first vintage that has the quarter | 1e-12; 1e-10 |
Transformation codes (tests/test_tcodes.py) |
each of FRED-MD's codes 1 to 7 against its formula written in the test, with and without a scale | 1e-12 |
Quantile nowcasts (tests/test_nowcast_quantile.py) |
each quantile's coefficients against statsmodels QuantReg on the quarterly averages and on the quarter's months (U-MIDAS) built by hand; the skewed t's quantiles against the fitted ones at the four knots; growth at risk and expected shortfall against the skewed t's quantile and its mean below it by quadrature; the CRPS against the integral of (F(x) - 1{x >= y})^2 by quadrature; the backtest's pinball losses, coverage and PITs recomputed by hand |
1e-8; 1e-4; 1e-6; 1e-4; 1e-12 |
Targeted predictors (tests/test_nowcast_targeted.py) |
hard thresholding against a loop of statsmodels OLS t-tests (constant, the target's lags, the indicator); least angle regression's order of entry against scikit-learn's lars_path; the elastic net's path against scikit-learn's ElasticNet fitted at each penalty, and its order of entry (both skipped without [ml]); the model on the kept series against DynamicFactor and Bridge fitted directly; the backtest's record against the selection on each day's data |
1e-10; exact; 1e-8; 1e-8 |
Weekly data made monthly (tests/test_nowcast_weekly.py) |
complete months' means and month-to-date means against a hand computation from the weeks published by each of five days; values published after the day change nothing; the backtest's monthly data on each day against as_of and weekly_to_monthly on that day |
1e-12; exact; exact |
Tracking with weekly data (nowcast_tracking(weekly=)) |
each day's monthly data handed to the model against the monthly data as known that day beside weekly_to_monthly of the weekly data on that day |
exact |
Nowcasting dialogs (tests/test_nowcast_dialogs.py) |
each dialog's generated code replayed in a fresh session against the API called directly (the window's contents, or the numbers): quantile bridge and its nowcast, targeted predictors, the mixed-frequency BVAR, weekly to monthly, vintages and revision analysis, the release calendar, transformation codes; masked periods in the bridge and MIDAS dialogs against mask= |
exact; 1e-12 |
Component bridges (tests/test_nowcast_components.py) |
nominal shares: the aggregate against the previous quarter's shares (from the levels, or rolled forward by the nowcasts by hand) times the components' nowcasts; each component's nowcast and standard error against its model fitted alone (bridge, dynamic factor); chained: the aggregate against a Fisher index computed from the levels and prices in the test, the contributions adding up to it, equal to the nominal shares for simple growth with no or equal deflators, and to the exact Laspeyres log growth, which exceeds the share-weighted sum by the stated second-order term (within 5%); the band against sqrt(g' D R D g) by hand and the correlation against the residuals' np.corrcoef; the backtest's nowcast against a component bridge fitted on that day's data; tracking's parts by component adding up to each day's change, and within each component by release |
1e-12; exact; 1e-12; 1e-12; 1e-10 |
Mixed-frequency BVAR (tests/test_mfbvar.py) |
with monthly variables only, the draws' mean against the conjugate posterior mean of VAR(...).fit(method=Bayes(prior=Minnesota(...))) (same prior, same rows); with a quarterly variable, every draw's months against the quarterly figures (mean and Mariano-Murasawa aggregation); the same seed, the same draws; the simulation smoother's draws for fixed parameters against the conditional normal worked out densely (mean and covariance) |
five Monte Carlo standard errors; 1e-10; exact; five Monte Carlo standard errors |
Nowcast refresh (tests/test_nowcast_refresh.py) |
the stored factor-model nowcast and standard error against a direct fit on the data as known that day; the change since the previous refresh equals news plus revisions plus the rest, and the stored news add up to the news | 1e-10 |
Large Parquet reads (Dataset.read(path, columns=, where=, span=), pymetrix.io.scan; tests/test_large_parquet.py) |
pandas reading the whole file (pd.read_parquet) and selecting with Dataset.select, for 14 conditions (comparisons, in and not in, and/or, not, functions, two columns, dates, periods, missing values), columns and spans; a pandas mask written by hand; a hive-partitioned folder of 60 files; a pymetrix file with its time axis and flags; the row groups read against pyarrow's own split_by_row_group on the file's statistics (3 of 20 for a range of a sorted column, 1 of 20 in a 2-million-row file read in under 5 seconds); scan's minimum, maximum and missing values against pandas on the data |
exact |
| Connector search and browse (FRED, World Bank, SDMX) | hand-written answers in each provider's documented format (FRED JSON, World Bank v2 JSON, SDMX-ML 2.1 structures); the ECB EXR key built from its dimensions equals the key the readers' recorded data use | exact |
Generate series for each (Dataset.with_each, Data → Generate series… with For each) |
the explicit with_series/derive call written by hand (frames identical); 100 × log differences by NumPy; on a panel (Grunfeld), NumPy differences within each firm, missing at each firm's first year; the recorded script replayed in a fresh namespace; templates expanded by hand for lists, wildcards with one and two parts, and mixed entries |
exact; 1e-12 |
Empty dataset and assignment within a sample (tests/test_assign_within.py) |
Dataset.empty's periods against pandas' period_range (count, first, last, consecutive) for Y, Q, M, Y-JUN and D; values inside and outside a span, a Sample, Sample(where=...) and a panel's entities and windows against arrays written by hand; the recursive x[-1]*1.02 against the closed form 4 × 1.02^k (EViews' period-by-period assignment), a lead and the series itself against the values before the call; EViews' wfcreate, series y, smpl, y = 1 sequence against its missing, 1, 1, missing; New dataset and Generate series → Within against the API call, their recorded code, the replayed script and the reopened project; a schema-2 Generate series step against its old code |
exact; 1e-14; exact |
A saved result's call (provenance["call"], save_result) |
Call(**provenance["call"]).invoke({"data": data}) against the saved file's numbers: a dialog's fit with a span and a row condition, a VAR, a HAC fit typed as code, a forecast from a named fit (tables cell by cell), a fit reopened from a project, and a call given for a fit made outside a session |
exact |
The commit beside the version (pymetrix.build, provenance.build) |
git rev-parse HEAD and git status --porcelain run directly in the package's folder; an installed package's folder, and one inside another repository, give no commit; a missing or slow git gives none and no error; read once per process |
exact |
| Series browser loads | Dataset.read of the address called directly; the recorded script replayed with no searchers, no cache and the browser unimportable |
exact |
| Principal components | eigendecomposition of the correlation matrix by hand | 1e-10 |
Matrix factors (Matrix.svd, qr, lu, schur, qz, eig) |
NumPy and SciPy on the same matrix; reconstruction U diag(s) V' = A, Q R = A, P L U = A, Q T Q' = A, Q AA Z' = A and Q BB Z' = B; A v = λ v for complex eigenvalues; symmetric results unchanged | 1e-12 |
| The matrix expression dialog's live check | twelve expressions typed into Model > Matrix > Expression… (offscreen Qt): unknown names with a suggestion, @@ with its column, lambda, files, underscores, imports, shapes that do not conform and a number refused with OK disabled; a matrix's shape and names and a decomposition's factors shown; large inputs or arrays checked but not evaluated; nothing recorded |
exact |
Functions of a matrix (expm, logm, sqrtm, norm, cond, null, orth, perp) |
the exponential's power series and SciPy; expm(logm A) = A, sqrtm(A)^2 = A; numpy.linalg's norms; A N = 0, perp' A = 0, [A perp] of full rank, Johansen's β⊥(α⊥'Γβ⊥)^-1 α⊥' the same for another complement | 1e-12; 1e-11; 1e-10 |
| Commutation, duplication and elimination matrices | K vec(A) = vec(A'), D vech(A) = vec(A) for symmetric A, L vec(A) = vech(A), L D = I | exact |
Matrix equations (Matrix.lyapunov, sylvester, riccati) |
a VAR(2)'s unconditional covariance by (I - F⊗F)^-1 vec(Q) on its companion form; the continuous Lyapunov and Sylvester equations by their vec formulas; the discrete Riccati equation against the Kalman filter's covariance recursion iterated 3,000 times, and SciPy | 1e-10; 1e-12 |
Monte Carlo standard errors of posterior means (mcse, a Bayes fit's MCSE column) |
the AR(1) closed form for the variance of a chain's mean (phi 0, 0.5, 0.9; 4 x 20,000 draws); batch means by hand; independent draws (s.d. / sqrt(N)); ArviZ 0.22 mcse(method="mean") when installed (within 0.3% on three AR(1) cases); the posterior's other columns unchanged |
10%; 10%; 3%; 1% |
Batch-means MCSE (mcse_batch); quantiles' MCSE (mcse_quantile, ess_quantile); mcse() of Bayesian VARs, DSGE posteriors and single equations |
the AR(1) closed form (phi 0, 0.5, 0.9) and the autocorrelation-based mcse; independent normal draws' sqrt(q (1 - q) / N) / phi(z_q) at q = 0.05, 0.5, 0.9, and ESS = N; AR(1) chains (phi 0.8) against the spread of the 10% and 50% quantiles over 300 replications, both methods; exact conjugate BVAR draws (ESS near N); the tables' mean errors against the summaries' |
15%; 10% (batch 15%), 10%; 20%; ESS > 0.75 N; 1e-6 |
| Bayesian single equations | flat priors: least squares and the multivariate t's variance; normal priors with an inverse gamma on sigma or sigma^2, by Gibbs and by Metropolis-Hastings: the exact posterior (the variance by quadrature, the coefficients in closed form given it); a Beta prior, a logit and a Poisson model: two-parameter posteriors on a 400 x 400 grid | four Monte Carlo s.e.; 4%; 0.1 posterior s.d. |
Bayesian ARMA errors (tests/test_bayes_arma.py) |
the innovations filter (exact Kalman, then the steady-state recursion) against the exact Kalman filter for ARMA(2, 1), AR(1), MA(2), ARMA(3, 2); the partial-autocorrelation map stationary and inverted for 50 random draws; a regression with ARMA(1, 1) errors (400 periods, flat priors): posterior means against statsmodels' SARIMAX maximum likelihood, R-hat below 1.1, ESS above 50 (a longer run, ARMA(2, 1) on 600 periods: every mean within 0.42 posterior sd of the ML estimates); a conditional AR(2) without a mean (flat priors, 1/sigma^2) against its normal-inverse-gamma posterior (t means and sd, inverse-gamma mean); priors honoured (a Uniform on a partial autocorrelation bounds every draw); same seed, same draws; posterior predictive intervals widening with the horizon and reverting to the mean; simulation-based calibration (10 replications, truth from the prior) | 3 posterior sd; 1e-10; 4 MCSE, 5%, 3%; exact; rank mean 0.2 to 0.8 |
| No-U-Turn sampler | a correlated (0.9), ill-scaled (s.d. 0.1 to 10) Gaussian: means within 4 Monte Carlo s.e., covariance, the adapted metric near the variances, no divergences; the conjugate normal-inverse-gamma regression's closed-form posterior (multivariate t, inverse gamma); Bayesian equations with flat priors (least squares, the t variance, the inverse-gamma sigma^2); a logit against random-walk Metropolis-Hastings (means within 4 combined MC s.e., s.d. 15%); the analytic gradients (Gaussian with each error prior, logit, probit, Poisson) against finite differences; an AR(1) model's posterior against the exact one on a grid; Stan's warmup windows | 4 MC s.e.; 1e-6 (gradients) |
| InvGamma1 prior (Dynare's inverse gamma of type 1) | its mean and s.d. by quadrature, including means of 1 and more | 1e-6, 1e-5 |
| Monte Carlo experiments | OLS under a fixed design: the slope's mean and its exact sampling s.d.; a true Wald null's rejection rates at 5% and 10% (exact F under normality); identical draws with one and two workers | three Monte Carlo s.e.; 5%; exact |
| Factor analysis (maximum likelihood) | R 4.3.3 factanal on the mroz data, 2 and 3 factors: uniquenesses, loadings unrotated, varimax and promax, the chi-squared test, regression and Bartlett scores (promax regression scores as R's times the factor correlations, which R 4.3 leaves out); rotations keep the common part |
1e-8 (k = 2); 2e-4 (k = 3, a Heywood case); 1e-7 |
| Data as known on a day | the publication lags, day by day | exact |
Filling, realigning and combining nowcasts (tests/test_nowcast.py) |
fill_edge: an AR(2) forecast by least squares written in the test (two months ahead), the data before the edge kept; realign: each series moved on by its months at the edge, the series already at the edge unchanged; combine: equal and given weights against the means worked out in the test; the bridge nowcast from the filled edge against the equation applied by hand |
1e-6; exact; 1e-6; 1e-10 |
| Parametric MIDAS weights | recovery (correlation with true weights above 0.99) | n/a |
| Chow-Lin (GLS step) | statsmodels GLS | default |
| Temporal disaggregation (all methods) | the aggregation constraints; exact Denton case; recovery | 1e-8 |
| Aggregation matrices (calendar and fiscal years mixed) | C·y = Y for Chow-Lin, Fernández, Litterman and both Dentons; Chow-Lin against its GLS formulas written in the test; the same series from a Matrix, DataFrame, array, dataset of weights and file, and from the conversion | 1e-10; 1e-10; 1e-12 |
| Soft constraints | regression: the GLS formulas with measurement error at the fit's scale, which maximises the likelihood; tiny standard deviations give the exact fit, large ones the indicator path X b; Denton: its penalised normal equations, and the same two limits (a constant ratio or shift) | 1e-8; 1e-5 |
| Denton in seasonal differences | the quadratic programme solved by elimination over the constraints' null space (seasonal and first differences, proportional and additive); the adjustment's within-year pattern constant across years (quarterly and monthly) | 1e-9; O(level_penalty) |
Proportional Denton against the IMF's worked example (tests/test_qna_manual_examples.py) |
published: IMF Quarterly National Accounts Manual, 2017 edition, chapter 6, Example 6.2 (p. 95), transcribed in tests/fixtures/reference/imf_qna_2017.json: all 16 benchmarked quarters, the three benchmarked years and the 2013 extrapolation (1,064.9), and the 16 quarterly benchmark-to-indicator ratios (measured: within 0.049 and 0.00004) |
half the last printed digit (0.05; 0.00005) |
Chain-linking against the IMF's worked examples (tests/test_qna_manual_examples.py) |
published: IMF Quarterly National Accounts Manual, 2017 edition, chapter 8, Example 8.6 (pp. 187-188, annual overlap) and Example 8.7 (p. 190, one-quarter overlap), from Example 8.2's current prices and price indices (p. 175): chain volumes in monetary terms, chain indices (2010 = 100) and discrepancies of both components and the total, quarterly, as sums of the quarters (1,524.7 and 1,560.2; 1,524.1 and 1,556.3 with the one-quarter overlap) and from annual data; from prices and quantities and from values at previous year's prices; the derived values at previous year's and the same year's prices against the printed columns as a transcription check. Linking the printed one-decimal values instead misses by up to 0.15: the manual's tables come from unrounded values | half the last printed digit (0.05; 0.005 for indices) |
| Litterman | Fernández at rho = 0; GLS with the covariance built from the process's moving average; the maximum of the likelihood on a grid | 1e-12; 1e-8; grid step |
| Reconciliation | the components add up to the total and keep their annual totals; fixed ones unchanged; the full KKT system for each method; least squares against the pro-rata rule by hand | 1e-10; exact; 1e-7; 1e-12 |
Reconciliation, weighted (method="weighted") |
the full KKT system of sum e_ct^2 / w_c built with NumPy (with fixed and annual-total constraints); with equal weights the minimum-norm adjustment from numpy.linalg.lstsq and the pseudo-inverse; with the total only, each gap shared in proportion to the weights by hand; a negative component (imports) adjusted as its positive mirror; constraints met and fixed components unchanged; the other methods against results recorded before the method was added (tests/test_reconcile_weighted.py) |
1e-10; 1e-10; 1e-10; 1e-10; 1e-10, exact; 1e-12 |
| Diebold-Mariano (HLN-corrected) | SciPy t-test at h = 1; formula at h > 1 | 1e-6 |
| Superior predictive ability (Hansen's SPA) and the model confidence set | arch's SPA and MCS (wrapped); on simulated forecasts the biased model beaten and the good one not, the SPA p-value between the lower and the Reality Check p-values; Backtest.spa (Forecast → Superior predictive ability…) against spa on the backtests' own losses (tests/test_dialogs_tests_forecasts.py) |
holds; identical |
| Binary forecast scores | Brier and log scores, Kuipers' score and the ROC area against formulas written in the test, the AUC against every positive-negative pair and the trapezoid area under the ROC curve | 1e-6 |
ROC analysis and DeLong's test (roc_analysis, roc_test; tests/test_signals.py) |
R's pROC 1.19.1 on R 4.3.3, recorded (pymetrix computes them itself): auc, var, ci.auc(method="delong") at 95% and 90%, roc.test(method="delong") paired (normal) and unpaired (Welch's t and degrees of freedom), auc(partial.auc=..., partial.auc.correct=TRUE) (McClish's standardisation) on data with ties; scikit-learn's roc_auc_score and roc_curve; DeLong's variance against its O(mn) definition; the stratified bootstrap interval against pROC's ci.auc(method="bootstrap", boot.n=2000) (another random stream) |
1e-12 (tests 1e-10); bootstrap within 0.02 |
Classification tables and thresholds (classification_table, choose_threshold) |
counts and rates by hand; Wilson intervals against statsmodels' proportion_confint(method="wilson"); Woolf's odds-ratio interval by hand; Sarlin's (2013) and Alessi and Detken's (2011) loss and usefulness worked by hand; each criterion's threshold against a brute-force search (KLR's noise-to-signal ratio with its minimum-signals guard); pROC's Youden threshold's sensitivity and specificity |
1e-12; exact |
Event windows and early-warning rankings (event_windows, early_warning) |
hand-built cases: overlapping crises, a crisis in the first period, missing readings, windows at the data's end (censored), a (first, last) range, panel entities with a gap in the calendar; the ranking against its pieces called directly; lead times and the share of crises called counted by hand on the simulated crisis panel | exact; 1e-12 |
| Fan charts, forecast-store accuracy | formulas | default |
Chart house look (tests/test_figure_style.py) |
series colours against Okabe and Ito's (2008) published RGB values, in order; fan legend keys against the shading of k overlapping bands, 1 - (1 - alpha)^k; matplotlib's global rcParams compared before and after drawing, saving and exporting; size in inches and PNG pixels (inches times dpi); the canvas' renderer width at a device pixel ratio of 2 |
exact; 1e-6 |
| Local projections | statsmodels OLS with HAC, horizon by horizon | 1e-10 |
| Smooth local projections | with no penalty, the ordinary local projection on the same periods; a large penalty giving a straight line or a constant in the horizon; Newey-West errors by hand; responses nearer the truth than the ordinary LP on average (five samples) | 1e-10; 1e-6; 1e-8 |
| LP-IV | the shock as its own instrument equal to least squares (responses and s.e.); each horizon's coefficient against linearmodels' IV2SLS (independent); true responses recovered where least squares is biased by an endogenous shock | 1e-10, 1e-8; 1e-10; 4 s.e. |
| Smooth-transition AR | known LSTAR and ESTAR parameters recovered from simulated processes (2,000 periods); the concentrated sum of squares equal to the fitted model's; a very fast transition's sum of squares equal to the threshold AR's at its threshold; Gauss-Newton standard errors against the numerical Hessian of the sum of squares (not gamma's, which differ by about 25%, as the summary warns); the one-step forecast against the model's prediction | 3.5 s.e.; 1e-10; 1e-8; 10%; 4 Monte Carlo s.e. |
| Growth at risk: the skewed t | integrates to one; Student's t with no skew; the skew normal with many degrees of freedom (scipy); quantiles and expected shortfall by numerical integration; known parameters recovered from their quantiles | 1e-8; 1e-12; 1e-5; 1e-4, 2e-3; 1e-4 |
| Growth at risk: quantile projections | statsmodels QuantReg on the same regressors; each quantile's slope in a location-scale model (4,000 periods); quantiles never crossing | 1e-6; 0.08 |
| Model solution: backward, perfect foresight, rational expectations | analytic solutions and the model's own equations | 1e-10 |
| Compiled model equations (steady state, linearisation, perfect foresight) | the tree interpreter, on templates and a model with a binding max |
1e-10 |
| Steady states with growth and simulation along the path | analytic balanced growth path; every model equation in levels on the simulated path | 1e-9 |
| Filtering along a growth trend | exact recovery of a simulated path when the observables pin every state; estimation within 3 standard errors | 1e-6 |
| Perfect foresight with surprises | the first-order plan with unanticipated shocks (linear model); the path before a surprise unchanged | 1e-9 |
| Calibration to steady-state targets | the RBC closed form (k/y and c/y for beta and delta) | 1e-10 |
| Theoretical moments and variance decompositions | the AR(1) closed form; a sum over impulse responses; long horizons of the FEVD; a long simulation | 1e-10; 2% |
| Shock decompositions | shocks recovered exactly from a path built from known shocks; contributions add up to the path | 1e-10 |
| Data contributions (each observed series' part of the smoothed estimates) | the parts add up to the smoothed path and the forecast; linearity in each series; the smoothed-state weights calculated directly, E[a | y] = Cov(a, y) Var(y)^-1 (y - d) over the whole sample at once (no Kalman recursion), for the New Keynesian template with a missing stretch of data, observed without measurement error (inflation and the policy rate then come from their own series alone) and with errors on every series | 1e-12; 1e-12; 1e-8 |
| Parameter sweeps | each run against the model solved on its own with those values; a sweep over phi_pi in the New Keynesian template against impulse responses by undetermined coefficients (by hand, the lagged rate the only state) at each value | 1e-10 |
| Forecasts from a fitted model; filter tunes | the smoothed state carried forward by the decision rules; tunes hit exactly, observed series still fitted | 1e-10; 1e-6 |
| Simulation plans (first order): news, surprises, exogenize/endogenize | impulse responses; stacked perfect foresight; period-by-period closed form; a nonlinear model near its steady state | 1e-10; 1e-9; 1% of the deviation |
| Optimal policy | the closed forms for the New Keynesian model with a persistent cost-push shock (Galí 2015, ch. 5): discretion (inflation and the output gap on the shock), commitment (the targeting rule and the output path); optimal simple rules against a grid search | 1e-9; 1e-12; grid spacing |
| First-order solution (reduced pencil) | QZ on the full companion pencil of every variable, written out in the test: decision rules, shock impacts and finite roots, on the templates and on random-coefficient models with static, led-only and two-period-lead variables; the likelihood on the states it needs against the likelihood on every state | 1e-10; 1e-8; 1e-7 |
| Second-order perturbation | the exact solution of the growth model with log utility and full depreciation: every second-order term, and no correction for risk; Dynare 6.0's own stoch_simul(order=2) for a growth model with persistent technology (tests/fixtures/dynare/rbc_order2.mod, reference from the dynare-reference workflow): ghx, ghu, ghxx, ghxu, ghuu agree to about 1e-14, ghs2 to 1e-12 |
1e-12; 1e-10 |
| Third-order perturbation | Dynare 6.0's own stoch_simul(order=3) (Ubuntu package under Octave 8.4; tests/fixtures/dynare/rbc_order3.mod, a growth model with correlated technology and spending shocks, and rbc_order3_habit.mod, with habits and an AR(4): seven states, three auxiliary): every term (ghx to ghuss) agrees to about 1e-13; Dynare's simult_ paths for fixed shocks, with and without pruning, to 1e-14; the pruned mean (oo_.mean) to 1e-14. The exact solution of the growth model with log utility and full depreciation: in levels each third-order term is a derivative of the exact rule, no correction for risk; in logs every term beyond the first is zero. The second-order terms equal second_order's; the corrections for risk vanish without risk and scale with the shocks' variance; the Kronecker Sylvester solver against a dense solve. The variance of the pruned process from 4,000 simulated paths against Dynare's theoretical oo_.var |
1e-9 relative; 1e-12; 1e-11; 1e-10; 7% (simulation) |
| The particle filter; estimating second-order solutions | on a linear Gaussian model (the New Keynesian template), the Kalman filter: the mean log likelihood over seeds within four standard errors of Kalman's, its spread shrinking about as 1/sqrt(N) (250 to 4000 particles), filtered means within 0.15 Kalman standard deviations (guided, 20,000 particles); a point-mass grid filter for an AR(1) state observed through exp(z) + z^2/2; a two-dimensional grid filter of the pruned second-order state of a scalar process (all of ghxx, ghxu, ghuu, ghs2); the propagation against SecondOrderSolution.simulate path for path; posterior mode and particle marginal Metropolis-Hastings recovering persistence and shock size from data simulated by a second-order growth model. No Dynare particle-filter output is recorded in the fixtures |
within Monte Carlo error (4 standard errors); 1e-12 for the paths |
| The particle smoother | on a linear Gaussian model (the New Keynesian template, first order, a lagged measurement equation), the Kalman smoother: smoothed means within 0.12 smoothed standard deviations on average and 0.5 at worst, 5% quantiles within 0.2, smoothed shocks within 0.15 shock standard deviations of the disturbance smoother (300 paths, 3,000 particles); a grid forward-backward smoother for an AR(1) state observed through exp(z) + z^2/2 (mean error 0.06 of the state's standard deviation, the worst period 0.3, where the smoothed distribution has two modes); a forward-backward smoother on a two-dimensional grid of the pruned second-order state of a scalar process (a degenerate transition), within 0.15 standard deviations; in each, the smoothed means at least twice as close as the filtered ones | Monte Carlo error |
| Occasionally binding constraints (OccBin) | the nonlinear perfect-foresight solution (stacked Newton) of a New Keynesian model with a zero lower bound: one shock, anticipated shocks and repeated surprises; a nonlinear simulation of a backward model with min; the linear solution when nothing binds; the path without the constraint, with anticipated shocks: perfect foresight of the model without it; Dynare 6.0 on the New Keynesian template with a lower bound (tests/fixtures/dynare/nk_zlb.mod, reference from the dynare-reference workflow): occbin_solver with surprises (its piecewise-linear and linear paths) and perfect_foresight_solver with anticipated shocks, with the floor as max and without it |
1e-10; Dynare 1e-9 |
| The OccBin filter and its likelihood | a constraint that never binds: the linear Kalman filter; given the regimes chosen, statsmodels' Kalman filter with the same time-varying transition, intercept and selection; data simulated by OccBin and observed without error: the true states, binding periods and shocks (those the bound does not mute); estimation with a constraint that never binds: the linear estimate | 1e-9; 1e-9; 1e-10; 1e-5 |
| OccBin forecasts | the nonlinear perfect-foresight solution (stacked Newton) of the model with its max, from the same smoothed state with an anticipated shock path; the linear forecast when the constraint never binds; the floor in the forecast and every draw | 1e-8; 1e-10 |
| Regimes with known dates: paths and forecasts | the nonlinear perfect-foresight solution (stacked Newton) of the same linear model with the regimes' parameters as exogenous series and the alternative rule switched in by an indicator (a new policy response, a temporary peg, a new inflation target with its own steady state, a rule without the policy shock); a surprise regime: the path without it to its start, then the known path from the state reached; regimes equal to the base, or one regime throughout: the ordinary solution | 1e-8 (1e-15 found); 1e-12; exact |
| Regimes with known dates: filter, likelihood and estimation | statsmodels' Kalman filter with the time-varying transition, intercept and selection built by hand from each regime's linearisation (a missing observation included); no regime change: the Kalman filter and smoother; regimes equal to the base: the same likelihood, estimates and forecast; estimation on data simulated with a change in phi_pi: both values within three standard errors; the Estimate and Forecast dialogs: the code's results | 1e-8; 1e-7; exact; 3 s.e.; exact |
| The iterated OccBin smoother | a constraint that never binds: the linear Kalman smoother; data simulated by OccBin without error: the true path and regimes; with measurement errors, over eight samples: regimes agreeing with the truth at least as often as the filter's, and the model's own policy equation with its max satisfied on the smoothed path in every period | 1e-10 (1e-8 with errors); 1e-10; 1e-8 |
| OccBin posterior forecasts | each draw against occbin (anticipated shocks) from the OccBin filter's state at that draw's parameters, recomputed independently; the floor in every draw with shocks, where the linear posterior forecast breaks it |
1e-10 |
| OccBin forecasts with held targets | the nonlinear perfect-foresight solution (stacked Newton) with the same holds and free shock over the span; with holds in some periods, perfect foresight with the shocks found reproduces the path and targets | 1e-8 |
| OccBin shock decompositions | the parts add up to the smoothed path; a constraint that never binds: the linear decomposition, with a zero binding part | 1e-10 |
| Perfect foresight with known-date regimes | a model whose equations are linear: the time-varying first-order solution through five regimes (a new response, a temporary peg, a new target, an alternative rule), also with an unanticipated shock; the nonlinear growth model with a new discount factor for good and a temporary depreciation rate: the same model by stacked Newton with the parameters as series in the data; one regime throughout: that regime's model; regimes equal to the base: the path without them | 1e-8; 1e-8; exact; exact |
| Surprise regimes with perfect foresight and OccBin | perfect foresight: before the surprise, the path without it; after, the known-regime path by stacked Newton from the state at its start; expected instead, a different path; on a linear model with two surprises (one temporary) and expected regimes, also with an unanticipated shock: the first-order solution; OccBin with anticipated shocks: the path without the regime spliced with the path from the state at its start, each by stacked Newton with the parameter as a series; OccBin with surprise shocks: perfect foresight with the max, the same surprise regime and unanticipated shocks; the OccBin filter where nothing binds: the regime filter | 1e-8; 1e-8; differs; 1e-8; 1e-8; 1e-8; 1e-8 (likelihood rel 1e-9) |
| OccBin regimes that change a constraint | a floor switched off for a while, then rewritten (-0.5), and a floor brought into a model without one: perfect foresight (stacked Newton) with the floor as a series in the data; perfect foresight with the same regimes' equations | 1e-8; 1e-8 |
| Identification with known-date regimes | regimes equal to the base: the check without regimes (Jacobian, sensitivities, collinearities, elasticity version); a regime's parameter: not identified when the regime starts after the sample, identified inside it; the stacked moments 150 periods into a permanent regime: that regime's own stationary moments; a fit with regimes: the model's check at the estimates; the Identification dialog: its code | exact; holds; 1e-8; 1e-5; exact |
| OccBin with known-date regimes | the nonlinear perfect-foresight solution (stacked Newton) of the model with its max and the regimes' parameters as series in the data, anticipated shocks and repeated surprises, the floor binding across a regime's start and a regime moving the steady state; perfect foresight with the same dated regimes; the path without the constraint: the linear regime path; regimes equal to the base: the path without them | 1e-8; 1e-8; 1e-10; exact |
| The OccBin filter with correlated shocks and regimes | nothing binds: the linear Kalman filter with the same correlated Q (likelihood, smoothed states and shocks, the shocks' own decomposition); with two regimes (a new response, a lower floor) and correlations on data where the floor binds in both: statsmodels' Kalman filter given time-varying matrices built here from each period's regime and constraint branch, written out as models and linearised by hand; estimation with correlations where nothing binds: the linear estimate; with regimes, the likelihood at the estimates is the filter's; decompositions (orthogonalised or not, the iterated smoother's too) add up to the smoothed path | 1e-8; 1e-8; 1e-4 (values), 1e-6 (likelihood); 1e-8; 1e-10 |
| OccBin forecasts with correlated draws and regimes | the drawn shocks' sample covariance (400 draws of 12 periods) against the covariance given, in correlations; with regimes and a constraint that never binds: the linear forecast through the same regimes, the peg holding the rate | 0.06; 1e-8 |
| Posterior forecasts, decompositions and moments with regimes | each posterior draw's forecast against the regime forecast worked out again at that draw's parameters through a template built with them, regime_filter and solve(regimes=), the measurement equations included; the Forecast dialog from a posterior with regimes: its code's result; the regime decomposition adds up to the smoothed path and equals LinearSolution.decompose(regimes=) on it, a path's own shocks recovered; regimes equal to the base: the linear decomposition; a regime's moments: the template at the regime's values on its own |
1e-10; exact; 1e-10; exact; 1e-10 |
| Dynare import (RBC model) | closed-form steady state and decision rule | 1e-8 |
| Dynare estimation (Smets and Wouters 2007) | Dynare 6.0's own output for Pfeifer's DSGE_mod replication (reference run by the dynare-reference workflow, files at a pinned commit): steady state and first-order decision rules (ghx, ghu) at the published mode; log posterior with presample=4, lik_init=2 and 36 priors at the published mode and at Dynare's own mode; on request, pymetrix's posterior mode from the file's starting values (measured: within 0.002 s.e.), standard errors at the mode (0.5%) and Laplace density (0.013) | 1e-12, 1e-10; 6e-4 (Dynare prints three decimals), 1e-6; 0.05 s.e., 5%, 0.05 |
| Metropolis-Hastings with mode jumps | a two-component normal mixture with known weights (modes of the same and of different widths): the share of draws in each mode and the means; a model whose likelihood depends on rho squared, its posterior computed exactly on a grid: the share of draws below zero; without jumps, chains stay in their first mode | 4 Monte Carlo s.e. |
| Smets and Wouters (2007) posterior | Dynare 6.0's Metropolis-Hastings (2 x 200,000 draws, 20% dropped; reference run by the dynare-reference workflow): pymetrix with mode jumps (4 x 40,000 after 20,000 burn-in) has every posterior mean within 0.25 of Dynare's posterior standard deviation (median 0.09), the same two modes (risk-premium persistence 90% interval 0.07-0.80, Dynare's 0.08-0.82), and modified harmonic mean -1571.14 against -1571.42; R-hat 1.03 (1.43 without jumps). Slow test (PYMETRIX_SLOW, about 45 minutes): eight starts must find both modes, then every posterior mean within 0.4 of Dynare's posterior s.d., the persistence's 5% and 95% points within 0.06 of Dynare's HPD, the modified harmonic mean within 0.6, R-hat below 1.3. The tail: R-hat varies from 1.03 to 1.22 between runs of this length. The cause is a thin tail in the price-markup shock's persistence (crhopinf towards 0.87, ctrend and cmap lower with it), which a chain enters rarely and leaves slowly. pymetrix's 5% point for crhopinf is 0.909, while Dynare's HPD starts at 0.955. A longer run (4 x 400,000 kept draws with jumps) has every chain in that tail: 9 to 22% of each chain's draws lie below 0.955 (Dynare's HPD implies about 5%). R-hat there was 1.06, with only 67 effective draws. So the difference is not one chain's accident. Dynare's own log posterior at sixteen points, ten of them in that tail (next row), equals pymetrix's to 2e-8. So the two compute the same posterior, and the difference is in the sampling: Dynare's two random-walk chains visit the tail less than pymetrix's four chains with mode jumps. Which run weights it right is a Monte Carlo question; pymetrix's sampler is checked against exact answers (the mode-jump row above) | 0.4 s.d.; 0.06; 0.6; 1.3 |
| Smets and Wouters (2007) log posterior away from the modes | Dynare 6.0's evaluate_posterior_kernel (reference run by the dynare-reference workflow, case sw2007_points) at sixteen points: the published mode, Dynare's own mode, ten draws from pymetrix's long run in the crhopinf tail (down to 0.745), and two from each mode's region |
1e-6 (measured: 2e-8) |
| Dynare estimation (fs2000) | Dynare 6.0's own output for its fs2000 example (reference run by the dynare-reference workflow): log posterior at the mode, the mode (in standard errors), standard errors at the mode, Laplace log data density; posterior means, standard deviations and modified harmonic mean by Metropolis-Hastings (a slow test, nightly) |
1e-3; 0.05 s.e.; 10%; 0.05; four combined Monte Carlo standard errors (about 0.25 sd for the means), 0.3 |
| Dynare's inverse gamma prior (type 1) | integrates to 1, with the stated mean and standard deviation, by quadrature; draws through the gamma distribution of 1/sigma^2 | 1e-6; 1% |
| Log-linear Dynare models | the same model written in logs by hand: identical log posterior | 1e-6 |
Correlated shocks (corr, shock_corr) |
a New Keynesian model with corr ey, ei = 0.4: the log likelihood against statsmodels' Kalman filter on the same system, the shock covariance against D C D by hand; draws' sample covariance (20,000 and 40,000 draws) against the one given; impulse responses against Q chol(Σ) and moments against the Lyapunov equation with the full covariance; a correlation of 0.5 estimated from 600 simulated periods (with the AR coefficient and both sizes); zero correlations against none |
1e-9; 1e-15; 4 s.e.; 1e-14, 1e-10; 3 s.e.; identical |
Correlated measurement errors (Dynare corr y, c on observables; MeasurementMap(error_corr=...)) |
Dynare 6.0's log likelihood on the same file and data (tests/fixtures/dynare/me_corr_priors.mod, tests/fixtures/dynare-me-corr-priors.json), the correlation fixed in the shocks block and estimated in estimated_params; a Kalman filter written out in the test with H = D C D; the analytic gradient (sizes and correlations of the errors) against five-point differences; a correlation estimated from 1,500 simulated periods within 3 s.e. of the true -0.5 |
1e-6 (Dynare's steady-state filter); 1e-8; 1e-6 relative |
| Prior stability mapping | Dynare 6.0's dynare_sensitivity(stab=1, Nsam=2000) on a New Keynesian model with uniform priors on phi_pi and phi_y (tests/fixtures/dynare-stability-nk.json): each of its 2,000 draws classified as Dynare did, its share of unique solutions (52.3%) and its Smirnov statistic for phi_pi (0.975) from ks_2samp on its draws; the share of determinate draws where the region is known in closed form: the New Keynesian model with phi_pi ~ U(0, 3), phi_y = 0 (2/3, Taylor principle), and with phi_y ~ U(0, 1) too (phi_pi + (1 - beta) phi_y / kappa > 1: 0.525), every draw on the right side of the boundary; an AR(1) explosive for a > 1 (1/2); a model without a steady state for b <= 0 (1/4); each draw's class against LinearModel.solve's Blanchard-Kahn refusal; the Smirnov statistic and p-value against SciPy's ks_2samp called directly |
4 binomial s.e.; exact; 1e-12 |
Dynare's generalised priors and prior_trunc |
Dynare 6.0's log prior densities (priordens) of a beta on (-0.5, 1), a gamma shifted to 0.2, an inverse gamma 1 shifted to 0.1, and its prior_bounds at prior_trunc=0.01 (same fixture); SciPy's beta and gamma with loc and scale; each density integrates to 1 with the mean and s.d. given (quadrature). The shifted inverse gamma 2 differs from Dynare 6.0 on purpose: Dynare's number equals the formula with its scale from the mean before the shift (checked), pymetrix keeps the mean given |
1e-10; 1e-9; 1e-6 |
| Dynare's macro processor (Dynare 6 operations) | Dynare 6.0's own preprocessor (dynare-preprocessor onlymacro) on 145 expressions (tests/fixtures/dynare-macro-6.0.json): set operations on arrays (|, &, -, *, ^) and their precedence, type tests, casts, sum, gamma, erf, normcdf, normpdf, equality of type and value, values written out (15 significant digits, strings unquoted), and the expressions it refuses; @#line writes the same text |
exact (numbers 1e-14) |
| Dynare's macro processor | each directive against text expanded by hand; a three-country New Keynesian model written with @#define, @#for over the countries, @#if on a define and an @#included calibration, against its hand-written twin: the same equations (but for spaces), shocks and correlations, and the same decision rules; the model editor's problems at the lines they come from |
exact; 1e-12 |
| Parameter metadata on models | the New Keynesian template estimated with specs (priors, bounds, a starting value, fixed parameters) against the same information given to estimate; a Dynare file's specs written and read again; the model text written back |
1e-10 |
| Measurement from raw data and back | estimating the New Keynesian template from GDP and CPI levels against estimating from the growth rates worked out beforehand (likelihood and estimates); levels rebuilt beyond the data against the last level compounded by hand with the forecast growth, in the forecast and in every draw; a four-quarter change, x(t) = x(t-4)(1 + obs/100), and a per-capita transform with population given, rebuilt by hand | 1e-6 (likelihood), 1e-12 |
| Reported series | the output gap reported with the smoothed history, the forecast and each draw against 100 times the smoothed, forecast and drawn output; the deterministic trend of an observed series in a draw against the measurement map evaluated on the same path | 1e-12 |
Impulse responses by name (IRF.paths, tests/test_model_irf_dialog.py, tests/test_exercises.py) |
every column "y <- shock" against the slice of values it labels (the New Keynesian template, all shocks and one); the AR(1)'s against size * rho^h; an exercise check reading paths.y <- ei.2 against one reading values.2.0.2 on the fixture pack's NK model |
exact; 1e-14; exact |
| IRIS import (NK and RBC models) | the same models read from Dynare files: impulse responses and state-space matrices; log variables against level responses over the steady state | 1e-10 |
| IRIS reporting equations and descriptions | reported series against the same quantities worked out by hand from given paths (a lag, a log variable in levels, an earlier reported series put in); the model unchanged by them; written to IRIS and read again: the same reported series, labels and parameter and shock-size descriptions | 1e-12 |
| The model editor's solution check | the roots against the eigenvalues of a two-equation New Keynesian model written out by hand as z(t+1) = M z(t), with a rule that satisfies the Taylor principle (unique) and one that does not (indeterminate); an explosive autoregression (no stable solution); the New Keynesian template's roots against its solution's, and a Dynare model's steady state against read_mod's |
1e-12 |
| The model editor's impulse-response preview | the responses drawn for each shock and ticked variable against LinearSolution.irf of the template's solution with its shock sizes and correlations (Cholesky-orthogonalised); none when not unique; with regimes, the base regime's (offscreen Qt) |
1e-12 |
| Regimes and correlations in the model text | a New Keynesian text with a regimes section and corr lines against the same model built in code with Regime(...) and shock_corr: the path through four regimes (temporary, an equation replaced, a surprise), the regime filter's log likelihood on data simulated with correlated shocks, an estimate and its forecast; the text built and written back against itself; seventeen planted problems at their line and column; IRIS's corr_a__b and Dynare's corr written and read again |
1e-12 (path), 1e-9 (likelihood), 1e-8 (estimate, forecast); exact (text, places) |
| Models written as text and in other syntaxes | the New Keynesian model in pymetrix's syntax against the template, and in Dynare's against read_mod; each of the nine pairs of pymetrix's, Dynare's and IRIS's syntax written and read again: impulse responses to every shock over 20 periods and the steady state (measured: 2e-15); IRIS's RBC model with log variables in all three (1e-13); d, dlog and lagged expressions written out; a changed parameter is detected (above 1e-3) |
1e-12 |
| EViews's syntax | a macro model's EViews text against the same Model written in code: equations, parameters and the Newton path (1e-12); its program's equation eq.ls specifications fitted against the pymetrix Equations fitted directly (1e-10); each function read against the expression or arithmetic it stands for on data (1e-12); EViews -> build -> EViews and the templates -> EViews -> pymetrix (paths, steady states and responses); planted problems at their line and column |
1e-12 / 1e-10 |
| FRB/US (the Federal Reserve's public package) | every equation of mods/model.xml (284 standard, 25 model-consistent) against the Fed's Python version of it, residuals on random data (1e-10; 1e-13 found); the standard model compiled (284 equations, no leads) and solved by Newton over the 40 quarters after the history with add factors from LONGBASE: the baseline reproduced (1e-6 relative; 2.1e-8 found); an excerpt of six equations and their data in the repository for every run; the full checks with PYMETRIX_FRBUS and PYMETRIX_FRBUS_DATA |
1e-10 / 1e-6 |
FRB/US simulations, VAR expectations (tests/test_frbus_example.py) |
the baseline tracked with Model.add_factors: LONGBASE reproduced by Newton from blanked values over 40 quarters (1e-6 relative; 2.1e-8 found); Newton against Gauss-Seidel on a funds-rate shock (1e-8; 6e-10 found); the federal-purchases ping of pings.prg against the Fed's own response (Brayton, A New FRB/US Price-Wage Sector, Figure 3, p. 16: output gap about 1.0 per point of GDP on impact, below zero from the third year): 0.5 to 1.5 required, 0.80 found, negative in the third year; a doubled shock against twice the single (5 percent; 0.7 for the output gap, 3 at worst for inflation); the funds-rate shock's output-gap trough (-0.9 to -0.25; -0.50 found); with the funds rate held (dmpex) the fiscal shock does more, the plain Taylor rule undoes its shock at once |
1e-6 / 1e-8 / documented ranges |
| FRB/US simulations, model-consistent expectations | the mcap and mcwp groups (example2.prg's "-mcap+wp") over 240 quarters by stacked Newton, terminal values from LONGBASE: the baseline reproduced from starting values blanked for ten years (1e-6; 8e-9 found), every equation in every period at the solution, with and without a funds-rate shock (largest residual below 1e-8); responses against VAR expectations and the Fed's Figure 5 (p. 18): the output gap's trough -0.19 (VAR -0.50), the 10-year yield 0.15 on impact (VAR 0.33) |
1e-6 / 1e-8 |
FRB/US zero lower bound and thresholds (example3.prg, tests/test_frbus_example.py) |
2003Q3-2009Q2 under VAR expectations with example3.prg's shocks: the funds rate never below the floor of 0.125 (1e-8); without the floor it goes to -5.21, with it the floor binds in 2003Q3-2005Q2 and 2008Q4-2009Q2 and the rate equals the rule elsewhere; every equation holds in every quarter (1e-8); Newton against Gauss-Seidel damped by 0.5 (1e-8); quarter by quarter, dmptlur > 1/2 exactly when unemployment < 7, dmptpi > 1/2 exactly when zpic58 > 3, dmptr = max(dmptmax, its lag), the rate at the floor until the quarter after dmptr turns on (2005Q3; liftoff 2005Q4 against 2005Q3 with the floor alone). The Fed's documentation gives no figures for this example: sanity checks only |
1e-8 |
FRB/US stochastic simulations (stochsim.prg, tests/test_frbus_example.py) |
VAR expectations, the 51 equations of stochastic type other than NO (leo out), their de-meaned errors of 1970Q1-2014Q4 resampled a quarter at a time, the first quarter halved, the floor at 0.25, 200 draws over 12 quarters: with every error zero each draw is the baseline, LONGBASE (1e-8 relative); the same seed and generator give the same draws, another seed or the Mersenne Twister others; each draw's errors in each quarter are exactly one historical quarter's 51; the add factors a draw's solution implies are the tracking ones plus its errors (1e-6); the median within a sixth of the 90 percent band's width of the baseline (0.1 at most for the funds rate, unemployment and inflation in the tutorial's 1000 draws over 24 quarters). The Fed's documentation gives no numbers for this program: sanity checks only | 1e-8 / exact / 1e-6 |
Stochastic simulation from a residual sample (errors= a DataFrame) |
y = 0.5 y[-1] + e, e resampled from 300 de-meaned t(5) residuals, 20,000 draws: the variance after h periods against s2 (1 + 0.25 + ... + 0.25^(h-1)); every error drawn a residual of the sample; zero residuals give the deterministic path; error_scale halves a period's errors exactly; workers=2 gives the same errors and paths |
5% (2.3% found) / exact / 1e-12 |
Optimal control (optimal_control, ocpolicy.prg's method) |
a backward-looking IS curve, Phillips curve, rule and rate change with the loss y^2 + pi^2 + di^2 (discount 0.99): the path chosen over 200 quarters after an inflation shock against optimal_policy's commitment impulse response, first 40 quarters; FRB/US (VAR expectations, 60 quarters of rfftay_aerr, loss over 80): the gradient at the optimum against its size at the baseline, the gradient from the linearised model against central differences of the loss, the loss below the Taylor rule's (10.81 against 11.76). The Fed's documentation gives no results for ocpolicy.prg: sanity checks only |
1e-6 (5e-15 found) / 1e-5 (2e-7 found) / 1e-4 (1e-6 found) |
| FRB/US new policy rule (example4.prg) | the first-difference rule rffgen with model-consistent zgap3 and zpic43 added to the "-mcap+wp" model, a consumption shock over 240 quarters by stacked Newton: the appended rule and rffrule hold along the solution, every equation in every period (1e-8); with the inertial Taylor rule's coefficients the solution equals that under dmpintay (1e-8 relative to the levels; 1.3e-12 in the funds rate, 10-year yield, unemployment, inflation and output gap); funds rate 0.50 after three quarters against 0.20. No published figures: sanity checks only |
1e-8 |
| Compiled period-by-period solvers | Newton and Gauss-Seidel with the compiled equations against the interpreter (fast.ENABLED = False) on a model with a simultaneous block, a log and a max kink, under a shift and an add factor: paths (1e-11) and iteration counts equal; FRB/US's excerpt tracked by Newton, Gauss-Seidel and perfect foresight (1e-9) |
1e-11 |
Solver options (tests/test_solver_options.py) |
the defaults against today's Newton and Gauss-Seidel, copied into the test, on the solver tests' models, partial fixes and holds, the FRB/US excerpt with add factors and the Solve dialog's example (compiled and interpreted): paths, iterations and convergence tables identical; convergence="step" the same iterations with an identity scaled by 1e6; Fallback against the closed form of a linear pair Gauss-Seidel cannot solve in one period (1e-9), other periods as plain Gauss-Seidel (1e-15); Newton's line search on y/sqrt(1+y^2) = x from y = 3 (plain Newton fails) against x/sqrt(1-x^2) (1e-12); refresh="period" against Newton (1e-10) with Jacobian evaluations counted at the period system (8 against 24); ordering="blocks" against the joint solution on a mixed model with holds and partial fixes (1e-10), its blocks against Model.blocks(), and on 200 recursive identities and a nonlinear pair: a fifth of the equation evaluations (counted, not timed) |
0 / 1e-10 |
Solve timing and the solver how-to (tests/test_solve_seconds.py, tests/test_solving_large_models.py) |
Solution.convergence.attrs["seconds"]: one non-negative value a period for every period-by-period solver and ordering; a solver that sleeps 0.2 s in one period shows it in that period alone; the seconds add up to no more than the wall time of the solve; columns and solution as without them; kept through pickling (a project's kept results) and a project saved and opened. The task page src/pymetrix/howto/solve-a-large-backward-looking-model.md runs as written, each option giving the default's solution (1e-9), its recommendation equal to the benchmark's; the benchmark's counts against what joint Newton must do (one Jacobian of every equation an iteration) and the blocks (each recursive equation once a period) |
1e-9 |
| EViews state-space objects | an sspace text (signal with data, [var = ...], @ename/@evar, a lagged state) against the StateSpace written by hand: log likelihood (1e-10); FRB/US's estimation_code.prg read as far as it maps, its refusals at their places (PYMETRIX_FRBUS_SSPACE) |
1e-10 |
Brillet's EViews models (opt-in: the book is copyright and not in the repository; PYMETRIX_BRILLET names a folder with the reader's own copies of its programs, and the tests skip without it) |
the book's very basic model (chapter 5: 17 equations, f*(...) with f given) solved by Newton, its identities holding (1e-10); its estimated small model (section 6.3.7: 20 equations with @pch, @trend, @elem and comparisons with t) read without refusals, its structure, and a Newton solve on synthetic data at which every equation holds (1e-8); its larger model (chapter 11, 83 equations with @pchy) read and compiled; the dated functions against the arithmetic of the data's dates (1e-12) |
1e-10 / 1e-8 |
EViews workfile bundles (pymetrix-eviews, packages/pymetrix-eviews/tests) |
bundles written by hand to the format, independently of the reader (four pages: quarterly, annual, an unbalanced panel and an undated cross-section; weekly, five- and seven-day pages; a Windows-1252 bundle; malformed ones): every value and metadata field read against the literal fixture, the manifests against the JSON Schema (jsonschema), each refusal against its file, line and column or manifest key; compare_estimates against least squares computed with NumPy's normal equations on the fixture's data, in EViews's coefficient order (1e-9; the fixture's own figures, recomputed by the test, 1e-9); File → Import EViews workfile… against the Dataset.read calls, their recorded code, the replayed script (and from the Parquet copies with the plugin's reader removed) and the reopened project. The export program itself is not checked: it has not been run in EViews |
exact; 1e-9 |
EViews programs, phase 1 (pymetrix-eviews, tests/test_program.py, tests/test_program_validation.py) |
two programs written for the tests (tests/fixtures/programs): every series, scalar and matrix they make against values worked out by hand from the text (recursive assignment within a sample, samples by date, offset, condition and name, @pch, d, @mean and @stdev over a conditional sample, fill by column and by row, a derived series, {%x} in a name); the script run as Python and the steps run in a session give equal objects (data, metadata, active sample, scalars, matrices); the session's own script replays; a bundle's saved sample and scalars and a CSV file; each expression function of the audit and each later-phase command left out with its reason; Brillet's chapter 5 program (PYMETRIX_BRILLET) and the FRB/US programs example1-4, pings, stochsim, ocpolicy and master_library (PYMETRIX_FRBUS): a row for every line with text, the count of each status fixed, the scripts compile |
exact; 1e-15 |
EViews programs, phase 2 (pymetrix-eviews, tests/test_program_estimation.py, tests/test_program_validation.py) |
programs written for the tests on seeded data, each estimate against a computation written in the test: least squares and its classic and White (HC1) standard errors by NumPy, an expression specification, the Wald statistic from (Rb - r)'(RVR')^-1(Rb - r), two-stage least squares, @coefs, @stderrs, @tstats, @r2, @aic (per observation from the log likelihood), @dw, c(2) after an estimation, makeresids, fit and forecast from b'x, a logit by Newton's method, the quantile regression's check function at its minimum, a VAR's equations by least squares, SUR with the same regressors as least squares, the ADF statistic as the t on y(-1) in its regression; a model with addinit reproducing the data, a one-period override giving the response 1, 0.5, 0.25... worked out by hand, an excluded variable held at its data, a merged equation's solution as b'x; the bundle fixture's equations re-estimated by the translated program against the EViews estimates it carries (and compare_estimates agreeing); the model reader's refusals at their lines; every option, estimator and test not translated left out with its reason; the script and the steps give equal objects. Brillet's chapter 5 program: the model collected and given to the core reader, which refuses it (f, "a function of", has no value), counts unchanged (4, 1, 18, 0); the FRB/US programs: counts unchanged, their models made by the read_xml_model add-in and the library's subroutines, so their solves are left out saying so. Brillet's printed estimates cannot be compared (the book's data are not available, and its one program in hand estimates nothing); the FRB/US example results are compared in phase 3, below |
1e-8 to 1e-12 relative; 1e-9 against the bundle |
EViews expression functions and dates (pymetrix-eviews, tests/test_program.py, tests/test_program_control.py; tests/test_eviews_syntax.py) |
@round, @floor, @ceiling, @isna, @nan, @iif, @log10, the calendar, @obsnum, @cumsum and the by-group statistics on five quarters worked by hand (@cumsum against EViews's own example 1, 3, 4, NA, 5 → 1, 4, 8, 8, 13), and the elementwise ones against NumPy with missing values; random draws against NumPy's PCG64 with the seeds rndseed·1000 + k; date numbers by hand (1 January 2001 = 365·2000 + 485) and against EViews's example (@dateval("12/1/1999", "dd/mm/yyyy") = 729765), FRB/US's dateshift (2020q1 + 23 quarters = 2025q4), script and steps equal |
exact; 1e-14 |
EViews programs, phase 3 (pymetrix-eviews, tests/test_program_control.py, tests/test_program_validation.py) |
programs written for the tests, every value worked out by hand from the text: for with a step of 3 and of -2, over a list of strings with @wfind, while to the first power of 3 not below 100, exitloop, if on @wcount and @word; subroutines by reference (!n 1 to 3 after two calls), sharing a counter, local, returning early, a string returned; include with its rows under its name, the program's arguments, run again with others; @wlookup, @isobject, @sum of the data, stop, a while loop over its cap; an if on each equation's @r2 against NumPy least squares (1e-12). In every one the script run as Python and the steps give equal objects (loops, ifs and subroutines included), and the steps are flat recorded calls. The FRB/US example1.prg with its included library, the model (read_eviews_xml) and LONGBASE given as tests/test_frbus_example.py does (wfcreate read as LONGBASE; call dateshift translated as written, its end of simulation 2025q4 checked): every model, sample, series and control line translated (only wfclose, the add-in, the database, statusline and the graphs left out); the tracking solution and the funds-rate shock's responses (rff, rg10, lur, pic4 over 2020Q1-2025Q4) against the same simulation written by hand (add factors over the 24 quarters, Scenario(shift=...)); script and steps (1,169 recorded steps) equal. Counts for every FRB/US program and its included libraries fixed, 0 errors; Brillet's unchanged (4, 1, 18, 0) |
1e-8 required, 0 found (bit for bit); 1e-12 |
EViews programs in the app (pymetrix-eviews, tests/test_translation_panel.py, tests/test_dialog.py) |
File → Translate EViews program…: the step's translation equal to translate_program (script and every report row), no data changed, the program and its included one kept in the project, the session's script replaying it; the panel, built offscreen with an AppInterface as the app builds it: a row per line in the report's order (the included program's under its name), each status cell's text the status and its colour the status's, the filters' counts the report's and unticking one hiding exactly its rows, a selected row putting its line at the top of the program's view (the included program's text for its rows) and the script's view at its comment, Copy and Copy script equal to report.to_text(...) and the script, Run as steps through the interface's runner (five recorded steps, none a loop, the last undone), a failing step's row marked and selected with nothing after it run, undoing the translate step removing it from the panel; the same under the Windows font emulation; the command ID fixed |
exact |
R scripts, phase 1 (pymetrix-r, tests/test_validation.py, tests/test_translate.py, tests/test_parse.py), on simulated fixture data (tests/fixtures/make_data.py) |
each translated estimation line run as steps, against what R computes, through its equivalent (no R runs here): lm against statsmodels 0.15.0 OLS; vcovHC HC0, HC1, HC3 and vcovCL(cluster = ~firm) against statsmodels' cov_type (the same formulas, vcovCL's G/(G-1)(n-1)/(n-k)); relevel(factor(region), ref = "west") against patsy's Treatment(reference=); glm binomial and poisson against statsmodels' Logit and Poisson; bptest against het_breuschpagan(robust=True); NeweyWest(lag = 3, prewhite = FALSE) against statsmodels' HAC without its correction and bgtest(order = 2) against acorr_breusch_godfrey (both on the quarterly fixture); plm within, twoways and pooling and feols(vcov = "iid") against least squares with the effects as dummies; feols clustered against fixest's formula written out (K the slopes, the effects nested in the cluster): the difference the note names pinned as pymetrix counting the absorbed effects; tseries' adf.test and urca's ur.df against tseries' regression written out with NumPy; kpss.test/ur.kpss against the KPSS formula; vars::VAR, irf (orthogonalised) and fevd against statsmodels' VAR (residual covariance adjusted for degrees of freedom, as vars); summarise against pandas. The parser against the trees of ?Syntax written by hand (precedence, assignment, formulas, pipes, raw strings, newlines, else, recovery). Every line has one row; the status counts of each fixture fixed; the script and the steps give equal objects; the translation deterministic and equal to the committed expected script and report. Not yet: R's recorded numbers and the workflow that runs R and its parser (design note, section 7) |
1e-8 (least squares, tests); 1e-6 (ML); 1e-10 (statistics); exact (parse, counts, scripts) |
The translation framework (pymetrix.translation, extension API 1.11; tests/test_extension_translation.py) |
the EViews plugin moved onto it with its tests unchanged, the FRB/US status counts and every script-equals-steps check included; a toy language of two statements (examples/translation_toy.py): its report against rows written by hand (statuses, reasons, the blank line without a row), its script's lines, and its series against hand values (t = 1, ..., 5; y = 2t + 1), the script and the steps giving equal objects; a function's result, with an early return, against 2 × 5 + 1 and 2 × (−1); the name allocator's notes; the panel on the toy's translation (a row per line, the language's column, a status's colour, Run as steps) |
exact |
Heterogeneous-agent models (pymetrix-ha, packages/pymetrix-ha/tests), on sequence-jacobian 1.0.0 |
the numbers sequence-jacobian's Krusell-Smith notebook prints (commit eb4ac4c, the notebook's grid agrid; tests/fixtures/krusell_smith_notebook.json): the household Jacobian J['C']['r'] (5 x 5), the firm's dY/dZ and the product J['C']['r'] J['r']['Z'], each to the 8 digits printed, and the largest error at each Newton iteration of the 1% and 10% TFP transitions, as printed (3 digits); sequence-jacobian called directly with its own defaults: steady state and distribution, G, impulse responses (G dZ and solve_impulse_linear), nonlinear and linear transitions; by hand: K = alpha Y / (r + delta), w = (1 - alpha) Y / L, Z = Y / K^alpha, the distribution's mass and its sums of the policies, Walras' law in the untargeted goods market, the stationary distribution as the eigenvector of Young's transition matrix (SciPy's sparse eigensolver), G by the notebook's step-by-step chain rule, and the gap between nonlinear and linear transitions shrinking 100-fold for a shock 10 times smaller; the representative-agent limit: sequence-jacobian's RBC model through HAModel against the same model as a .mod file solved by pymetrix's QZ (40 horizons); the options passed are the library's own defaults, read from its signatures |
8 printed digits; exact (3 digits); 1e-12; 1e-12 (Walras 1e-8); 1e-8; 1e-10; ratio 70 to 130; 1e-8 |
Heterogeneous-agent models, phase 2 (pymetrix-ha: tests/test_hank_one_asset.py, test_hank_two_asset.py, test_app_and_standard_blocks.py, test_representative_agent.py), on sequence-jacobian 1.0.0 |
the numbers the HANK and two-asset notebooks print at their own grids (commit eb4ac4c; tests/fixtures/hank_notebooks.json; with PYMETRIX_HA_NOTEBOOKS=1): the untargeted goods markets, liquid wealth 1.04, and the largest error in each target at every Newton iteration of the 1% and 10% (one-asset) and the 0.25 and 0.025 point (two-asset) monetary shocks; sequence-jacobian called directly on small grids: the one-asset model with the blocks the library ships (examples.hank) and the notebook's grid, the two-asset model against the example it ships (examples.two_asset.dag()): steady states and distributions, G, impulse responses, nonlinear and linear transitions; decompositions: each channel equal to the library's household Jacobian times the input's path from the library's G, the channels and the groups adding up to G's response, the groups' steady-state consumption adding up to C and their masses to the deciles or income states; the distribution's summaries against direct computation (Gini by the mean absolute difference, the top 10% by taking the richest states, the median, the mass at the limit); a model of the standard blocks equal to the Krusell-Smith notebook's; the RBC limit's nonlinear transition against pymetrix's PerfectForesight (terminal steady state) |
as printed (3 digits); 1e-12 (steady states), 1e-10 (G: 3e-14 found; transitions); 1e-12 and 1e-10 (residuals about 1e-15); 1e-12; 1e-10 (mean against A: 1e-7, the forward iteration's tolerance); 1e-10 |
Debt sustainability (the fiscal plugin)¶
The fiscal plugin (pymetrix-fiscal, packages/pymetrix-fiscal/tests) reimplements the published method; no
template's content is used. Its checks:
| What | Reference | Tolerance |
|---|---|---|
The identity (test_fiscal_identity.py) |
Small cases worked by hand: one currency, d(t) = d(t-1)(1 + i)/((1 + g)(1 + pi)) - pb (Escolano 2010); no growth or inflation; a 30 per cent depreciation of 60 per cent foreign-currency debt; and the intra-year exchange-rate effect worked in levels (financed at home: 225.5 over GDP 420; abroad at the average rate: 226, the 0.5 the Debt Dynamics Tool manual's equation (7) gives) | 1e-12 |
An independent calculation (test_fiscal_identity.py) |
Debt in levels from the manual's equation (1): local- and foreign-currency stocks, foreign interest and flows at the average rate, the stock at the end-of-year rate, the stock-flow term by fixed-point iteration. Compared with the plugin's closed form in ratios, equation (8), on six random cases of eight years | 1e-12 relative |
The decompositions (test_fiscal_identity.py) |
SRDSF guidance note Box 3 and 2013 MAC DSA Figure 2 (the manual's equation (3)): each year's components sum to the change in debt, both styles, random cases; zero residual in projections; on history, the residual equals what was added to the data | 1e-12 |
Debt-stabilising primary balance (test_fiscal_identity.py) |
Projecting with it holds the ratio (the manual's Appendix IV.A); the SRDSF's version holds the ratio when the real exchange rate is unchanged, and equals Box 3's last form when foreign inflation is zero. That form omits a factor 1/(1 + foreign inflation) otherwise, so the box's middle form is used | 1e-10, 1e-12 |
Gross financing needs (test_fiscal_identity.py) |
By hand: primary deficit + interest + amortisation + last year's short-term debt + other flows | 1e-12 |
The Debt Dynamics Tool manual's example (test_fiscal_ddt_manual.py) |
Acosta-Ormaechea and Martinez (2021), IMF TNM 2021/005: the inputs printed on p. 15 (2020-2025) and the output table on p. 22. Checked: debt less uncalled guarantees 2021-2025; the real interest rate, real growth, exchange rate, intra-year exchange-rate and other-flows contributions; the effective interest rate; the 2021 debt-stabilising balance (-0.1) | contributions and rates 0.07 (the printed decimal plus the inputs' rounding); debt 0.1 + 0.05 per year (the primary deficit printed to one decimal) |
Stress tests (test_fiscal_stress.py) |
The manual's section VI.A-C, input by input: historical means and sample standard deviations over 10 years (depreciation and the residual over 9) computed directly from the file; each shock moving one driver by the multiple in years 2 and 3 only; the historical scenario's averages plus the average residual; the constant primary balance; each scenario's path equal to a projection of its inputs | 1e-12 |
The layout and data (test_fiscal_profile.py) |
Levels divided by GDP, growth and the deflator from GDP, the effective rate from interest paid, by hand; Excel read as the CSV; the example's unrecorded 2020 flow flagged by the identity's check | 1e-12 |
Not yet checked: an independent implementation (the R package debtkit is the design note's choice; R does not run in these tests), and published country DSAs (phases 3a and 3b).
Finance (the bundled plugin)¶
The finance plugin (pymetrix-finance) computes everything itself on pymetrix's own dependencies. arch,
QuantLib, statsmodels and linearmodels are used only in the tests, where installed, so the checks below skip
without them.
Risk
| Method | Checked against | Agreement |
|---|---|---|
| Normal and Student-t ES | numerical integration of each density's tail | 1e-7 (normal), 1e-6 (t) |
| Cornish-Fisher VaR and ES | equal to the normal's with no skewness or excess kurtosis | 1e-12 (VaR), 2e-3 (ES) |
| Historical VaR and ES | the order statistics | 1e-12 |
| GARCH volatility forecast one period ahead | arch's GARCH(1,1) fit and forecast (independent) | 2% (alpha 0.02, beta 0.03) |
| GJR-GARCH-t VaR and ES | arch's GJR-t fit and variance forecast (independent); the standardised t's quantile and tail mean by simulation (4 million draws) | 5% (parameters), 3% (variance, VaR); 1% |
| GJR variance update | hand calculation | default |
| Kupiec and Christoffersen tests | likelihood ratios from violations and transitions counted by hand | 1e-12, 1e-10 |
| Dynamic quantile test | the regression of the hits on their lags and VaR, by hand | 1e-8 |
| Basel traffic-light zones | the Basel Committee's published table | exact |
| VaR coverage | simulated returns, with and without volatility clustering | violation rate 0.4% to 2% at 1% |
| DCC likelihood | a plain loop over the correlation recursion | 1e-10 |
| DCC and BEKK parameters | recovery from simulated processes (3,000 periods) | 0.02 to 0.05 |
| CCC, DCC and BEKK forecasts | their long-run values: the unconditional variances, Qbar's correlation, the targeted covariance | 1e-3, 1e-4 |
| Asymmetric DCC | nests DCC exactly with g = 0; the stationarity bound against the eigenvalues of Qbar^-1 Nbar; g and b recovered from a simulated process | default; 0.06 |
| Portfolio VaR from a multivariate GARCH | the normal VaR of w'Hw | default |
| Risk contributions (normal) | Euler's additivity; marginal VaR and ES by finite differences of the portfolio's VaR and ES | 1e-12; 1e-6 |
| Risk contributions (historical) | component ES by hand from the tail periods; additivity | default |
| Copula densities | statsmodels' Gaussian, t, Clayton and Gumbel copulas (independent); integrate to one (numerical double integration); Gaussian and t against scipy's multivariate densities | 1e-12; 2e-3; default |
| Copula parameters | recovery from simulated copulas (4,000 draws); the Clayton and Gumbel samplers' Kendall's tau | 0.04 (correlations), 1.5 (t degrees of freedom), 10% (theta); 0.03 |
| t copula tail dependence | simulation (2 million draws) | 0.04 |
| Copula portfolio VaR and ES | Gaussian copula with normal margins against the closed-form normal VaR (400,000 draws) | 1% |
| Copula families' densities and CDFs (Clayton, Gumbel, Frank, Joe in 2, 3 and 5 dimensions; Frank negative; t and Gaussian CDFs; rotations) | R's copula package 1.1-7 (dCopula, pCopula), values written into the test | 1e-9 (t CDF 1e-8) |
| BB1, BB7, survival and rotated copulas | R's VineCopula 2.6.1: density, CDF, h-function and its inverse, Kendall's tau, tail dependence | 1e-8 |
| Copula densities, CDFs and h-functions (every bivariate family) | integrate to one (2-D quadrature); mixed derivative of the CDF (finite differences); h against the CDF's derivative; h-inverse round trip; three-series densities against the CDF's third derivative | 2e-3; 1e-4; 1e-6; 1e-8; 2e-4 |
| Kendall's tau of the copula families | closed forms (Clayton, Gumbel, BB1), Frank's Debye function by its series, Joe's series, BB7's Beta-function form, the general 1 + 4 int phi/phi'; sample tau of 200,000 draws | 1e-8 to 1e-10; 3 standard errors |
| Copula tail dependence | the limit of C(q, q)/q from the CDF at q = 1e-7; joint exceedances of 400,000 draws at q = 0.01 | 2e-3; 4 binomial standard errors |
| Copula samplers | Marshall-Olkin against conditional inversion (tau, margins, CDF at points); four-series pairwise tau and CDF; Sibuya frequencies | 3 standard errors; 4 binomial standard errors |
| Copula estimates | recovery from 2,000 draws with known margins (every family, four-series Archimedean); R's fitCopula (Gumbel, Frank, Joe, by ML and itau) and gofCopula's S_n | 3 standard errors; 1e-6, 1e-7 |
| Copula goodness of fit | size on null data (60 replications; 200 with PYMETRIX_SLOW, two families); power against a wrong family | binomial band; p < 0.01 |
| Hansen's skewed t | density integrates to one, mean 0, variance 1; CDF against the integral of the density; quantiles invert the CDF; the standardised t at lambda = 0 | 1e-8, 1e-7, 1e-6; 1e-9; 1e-12 |
| Copula margins (IFM, joint, GARCH-t) | recovery of skewed-t margins and the copula from 4,000 draws; joint likelihood at least IFM's; GARCH-t degrees of freedom | 5% (scale), 0.06 (lambda), 3 standard errors |
| Vine pair copulas' h-functions | R's VineCopula 2.6.1 BiCopHfunc (hfunc1 and hfunc2, every pair family incl. rotations; values written into the test); inverse round trip | 1e-9; 1e-8 |
| Vine copula log likelihood | R's RVineLogLik of a five-series R-vine at given parameters (Gaussian, t, Clayton, Gumbel, Frank, BB1, BB7, survival, 90/270 rotations); Gaussian D-, C- and R-vines with partial correlations against the Gaussian copula | 1e-8; 1e-10 |
| Vine structure selection | R's RVineStructureSelect (R-vine, C-vine, BIC truncated at 2): trees and families, parameters, log likelihood | exact; 1e-3; 1e-3 |
| Vine simulation and estimation | R's RVineSim (100,000 draws): pairwise Kendall's tau, uniform margins; first-tree tau of the pair copulas; sequential estimates from 3,000 draws of a known vine; joint ML at least sequential | 3 standard errors (batch means); KS p > 0.001; 3 standard errors |
| Time-varying copulas (Patton) | filtered path against a loop written in the test (all five families); the likelihood against the constant densities period by period; alpha = beta = 0 against the Gaussian copula and its ML; parameters recovered from simulated paths (Gaussian 3,000, t 1,500 periods) | 1e-12; 1e-10; 1e-12, 1e-6; 3 standard errors |
| Gaussian and t copula CDFs, more than two series | R's mvtnorm pmvnorm and pmvt (GenzBretz, abseps 1e-9); scipy's multivariate normal CDF (four series); the bivariate quadrature | 2e-5 (1,024 points), 2e-6 (65,536); 1e-4; 5e-5 |
| Copula goodness of fit, more than two series | S_n against R (C.n and pmvnorm/pmvt); size on null data (30 replications; 200 with PYMETRIX_SLOW); power against Clayton data | relative 2e-3; binomial band; p < 0.05 |
| BB6, BB8, Tawn (types 1 and 2) and the rotated BB1, BB6, BB7, BB8 and Tawn copulas | R's VineCopula 2.6.1 BiCopPDF, BiCopCDF, BiCopHfunc (hfunc1, hfunc2) at seven points, BiCopPar2TailDep (values written into the test); Kendall's tau against R's integral of VineCopula's integrand at rel.tol 1e-13 and BiCopPar2Tau (default tolerance); RVineLogLik of a four-series vine with these pairs | 1e-8 (1e-6 at a corner where R's BB6 loses digits; ours checked in long double); 1e-9, 2e-7; 1e-9 |
| BB6, BB8 and Tawn: densities, CDFs, h-functions, simulation, estimation | integrate to one (adaptive quadrature); mixed derivative of the CDF; h against its derivative; inverse h; Kendall's tau of 20,000 draws; ML recovery from 4,000 draws | 1e-6; 1e-5; 1e-6; 1e-9; 3 standard errors (batch means); 3 standard errors |
| Copula goodness of fit, multiplier bootstrap (Kojadinovic and Yan) | R's copula 1.1-7 gofCopula(..., simulation = "mult", method = "Sn"): S_n (Clayton, Gumbel, Frank, Joe by MPL; Clayton and Gumbel in three dimensions; Clayton, Gumbel and Gaussian by itau) and the p-value (4,000 replicates each); size on null data (60 replications; 400 with PYMETRIX_SLOW, two families: Clayton 26/400, Gumbel 6/400, conservative at n = 200); power; against the parametric bootstrap | relative 1e-3 (agree to 1e-6); 0.05; binomial band (Gumbel: upper only); p < 0.01; 0.15 |
| Vine copula goodness of fit (Rosenblatt transform, ECP2) | R's VineCopula RVinePIT, RVineLogLik and RVineGofTest(method = "ECP2") statistic for a fitted four-series vine; the transform inverts the simulation; size on null data with the parametric bootstrap refitting the vine (30 replications; 100 with PYMETRIX_SLOW); power against Clayton-vine data fitted by Gaussian pairs | 1e-8, 1e-9, relative 1e-3 (agree to 1e-13); 1e-9; binomial band; p < 0.05 |
| DCC copula (Gaussian and t, several series) | filtered correlations against a loop written in the test and mgarch's dcc_path; a = b = 0 against the constant Gaussian copula fit and the t copula density; parameter recovery from simulated paths (Gaussian 2,000, t 1,500 periods); forecasts against Engle and Sheppard's formula; portfolio VaR against a direct simulation | 1e-12; 1e-10; 3 standard errors; 1e-12; 3% |
| Copula portfolio VaR through fitted margins | a direct simulation written in the test (Clayton by conditional inversion, scipy's t): the model at its true parameters, and the fitted one | 4 Monte Carlo standard errors; 6% |
Returns, portfolios and strategies
| Method | Checked against | Agreement |
|---|---|---|
| Returns from prices | numpy's log differences and ratios | default |
| Performance measures (Sharpe, Sortino, Calmar, drawdown, alpha, beta, information ratio) | each from its definition by hand; drawdown by a plain loop; beta by numpy's polyfit; Lo's (2002) Sharpe standard error | 1e-12 (1e-8 for alpha) |
| GRS test | one asset: the squared t statistic of alpha with classical standard errors; several: the maximum-Sharpe-ratio identity | 1e-8 |
| Factor betas and rolling betas | numpy least squares | default |
| Minimum-variance, tangency and target-return weights | their closed forms (unconstrained) | 1e-5 |
| Long-only minimum variance | a grid search over the simplex | no worse than the grid |
| Strategy backtests | equal weights rebalanced every period: the assets' mean return; buy and hold: its value by hand; costs: cost times turnover counted by hand; no look-ahead: the public optimiser on each window | 1e-12 to 1e-15; 1e-5 |
| Risk parity | equal (or budgeted) risk shares; two assets: inverse volatility | 1e-8 |
| Black-Litterman | He and Litterman (1999), published: the seven-country equilibrium returns and the posterior with their first view; the two textbook forms of the posterior mean; no views: the implied returns, which give back the market weights; a certain view held exactly; the result object against the old (mean, covariance) tuple, bit for bit, and a two-asset posterior worked by hand (with Theil's mixed-estimation form) in test_finance_black_litterman.py |
0.05 percentage points (published to one decimal); 1e-9; exact, 1e-15 |
| Event studies: market model and Patell standardisation | numpy's polyfit; Patell's textbook prediction-error formula by a plain loop | 1e-12, 1e-9 |
| Event-study tests (cross-sectional, Patell, BMP, Corrado rank) | size under the null by simulation (200 replications of 21 events) | rejection rate 1.5% to 9.5% at 5% |
Volatility from intraday data
| Method | Checked against | Agreement |
|---|---|---|
| Realised variance, bipower variation, tripower quarticity, BNS jump statistic | their formulas by a plain loop | 1e-12 |
| Realised measures | a simulated diffusion with known daily integrated variance: RV and BV estimate it without jumps; with jumps RV adds their square and BV takes in a small part | 3%, 4%; 15%, less than a fifth |
| BNS jump test | size without jumps (1,500 days of 288 returns) and power with large jumps | 2% to 8% at 5%; 90% found |
| HAR (levels and logs) | least squares on hand-made weekly and monthly averages; forecasts by iterating by hand | 1e-8 |
Options, curves and credit
| Method | Checked against | Agreement |
|---|---|---|
| Black-Scholes-Merton prices | Hull, Options, Futures, and Other Derivatives, Example 15.6; put-call parity with dividends | 0.005; 1e-10 |
| Binomial tree | Hull's Example 21.1 (five-step American put, 4.49); convergence to Black-Scholes (4,000 steps); an American call without dividends equal to the European | 0.005; 2e-3; 1e-10 |
| Greeks | central finite differences of Black-Scholes; an American call's tree Greeks against the closed forms | 1e-6 (gamma 1e-4); 2% |
| Implied volatility | the volatility each price was made with, calls and puts | 1e-8 |
| Heston prices | QuantLib's AnalyticHestonEngine at three expiries and five strikes (independent); Black-Scholes in the zero vol-of-vol limit; put-call parity | 1e-7; 1e-5; default |
| SABR implied volatility | QuantLib's sabrVolatility, beta 1 and 0.5 (independent) |
1e-10 |
| SVI butterfly function | the risk-neutral density from numerical second derivatives of call prices | 1e-4 |
| SVI, SABR and Heston calibration | recovery of the parameters that made their own quotes; SVI's calendar check flagging a falling total variance | 1e-4 (Heston), 1e-5 (SABR), 1e-4 in volatility (SVI) |
| Nelson-Siegel and Svensson factors and decays | exact recovery from noise-free curves; the loadings' limits; Svensson with no second hump equal to Nelson-Siegel | 1e-6 to 1e-10 |
| Diebold-Li factor forecasts | statsmodels' AutoReg; three steps by hand | 1e-8 |
| Forward rates, discount factors, bonds | forwards averaging to the yield (numerical integration); zero-coupon price, duration and convexity; the par coupon pricing at 100; Fisher-Weil duration by finite differences | 1e-9; default; 1e-9; 1e-6 |
| Dynamic Nelson-Siegel likelihood | statsmodels' Kalman filter with the same matrices, with missing yields (independent) | 1e-9 |
| Dynamic Nelson-Siegel estimates | recovery from a simulated model (300 months) | decay 0.03, AR 0.08, shock and error s.d. 20 to 25% |
| Merton model | equity and its volatility round-tripped through Black-Scholes; KMV iteration against a simulated firm's asset path and volatility | 1e-9; 2% |
| CDS intensities | QuantLib's PiecewiseFlatHazardRate from SpreadCdsHelpers (independent): survival to 1 to 10 years; each CDS repriced at zero by the bootstrapped curve; the credit triangle exactly on a flat curve without discounting | 5e-4 (IMM dates and day counts against a quarterly grid); 1e-12; 1e-6 |
The finance tutorial (finance-tutorial.md) runs as written on the example datasets. The
Fama-French returns are downloaded on first use, so the tests run it on a simulated stand-in served in the data
library's own file layout (no network); with PYMETRIX_FRENCH set to a downloaded french.parquet, its claims about
the real data are tested too: momentum's Sharpe ratio and skew, the GRS rejection, minimum variance beating maximum
Sharpe out of sample, and the VaR backtest comparison (checked on the library's September 2026 release). The download
itself (tests/test_finance_french_download.py): the dataset built from the five files equals the stand-in's
simulated returns over 100 exactly, the first load fetches once and caches, later loads fetch nothing, and offline the
first load fails with a message that names the library and the cache folder.
Not yet independently checked¶
These are native code whose tests check behaviour (direction, consistency, recovery) but not a number against an outside reference. They are good first tasks for anyone validating against another package.
- Equation tests: Sargan, Durbin-Wu-Hausman and Hansen J for native estimators; McLeod-Li; multi-restriction Wald.
- Forecasts: dynamic forecasts of an OLS equation with a lagged dependent variable; native GJR-GARCH-t forecasts.
- VARs: bootstrap impulse-response bands.
- Bayesian VARs: sum-of-coefficients and initial-observation priors; hyperparameter optimisation; posterior bands; forecasts.
- State space: models with priors (posterior mode); forecasts and simulation.
- Bayesian estimation of models: the Metropolis-Hastings comparison with Dynare's fs2000 posterior is a
slowtest (about five minutes; nightly and on release). Both sides are Monte Carlo estimates, so its limits are four of their combined standard errors, measured from the run. Dynare's recorded reference is short (2 x 10,000 kept draws), so its own error is about 0.05 posterior standard deviations a mean and more for the tails. In December 2026 the depreciation rate (del, skewed, near its bound of 0) sat 0.12 sd above it with a 13% wider spread, consistently across seeds. Long runs on both sides settled it: pymetrix 4 x 100,000 draws, mean 0.00252, 90% HPD [0.00048, 0.00457]; Dynare 6.0 4 x 100,000 (half kept), mean 0.0025, [0.0005, 0.0045], against the short reference's 0.00237, [0.00061, 0.00436]. Every other mean agrees to the long Dynare run's printed digits (alpha 0.4044 and 0.4045, rho 0.8453 and 0.8461), and the modified harmonic mean is 1299.212 against 1299.225. - Systems: iterated 3SLS, restricted SUR, nonlinear SUR, the diagonal-covariance test.
- Dynamic panels: two-step Windmeijer s.e. (Monte Carlo only); AR(1) and AR(2) tests; Hansen J; system GMM.
- ARDL: the bounds test (statsmodels computes it; only its verdicts are tested); order selection.
- Panel unit roots and cointegration: Hadri with a long-run variance; Breitung, Pedroni, Kao and Westerlund against
another package's output (Stata's
xtunitroot breitungandxtcointtest, or EViews), none of which is at hand. - MIDAS: parametric estimates and nowcasts, against another MIDAS implementation.
- Disaggregation: Chow-Lin by maximum likelihood, Fernández, Litterman and additive Denton, against
another package, for example R's
tempdisagg(the checks are against formulas written in the tests); the reconciliation against another package's (R'stsbalancing, or Di Fonzo and Marini's own examples). - Model solving: Dynare's and IRIS's own output for imported models.
- Seasonal adjustment: X-13 on Windows and macOS builds of the program (checked here against x13binary's Linux build of 1.1 Build 61). TRAMO-SEATS on macOS's Java, which only the weekly full run reaches.
- Finance (checked by formulas, hand calculation or simulation, but not against another package): the event-study test statistics (their size only; R's estudy2 would be a reference); SVI calibration; the KMV iteration; the copula estimates of the Gaussian and t, the BB1 and BB7 estimates and the goodness-of-fit p-values (the densities, CDFs and Archimedean fits are checked against statsmodels and R's copula and VineCopula); the McNeil-Frey shortfall test; the dynamic Nelson-Siegel estimates (its likelihood is checked).
Contributing a check¶
Run the same estimation in another package, record the output and the package version, and add
a test (see CONTRIBUTING.md). Mark the test with @pytest.mark.reference("Estimator",
ref="...", what="...", tol="...") and rerun python scripts/make_validation_register.py, so that it joins
the register. Validators are credited here.