Skip to content

ENH: Fit the ADF t-test critical values to the same simulations as the p-values - #1017

Merged
bashtage merged 5 commits into
mainfrom
a90-adf-t-cv
Nov 11, 2026
Merged

bashtage merged 5 commits into
mainfrom
a90-adf-t-cv

Conversation

@bashtage

Copy link
Copy Markdown
Owner

Fits the critical values of the ADF t-test with one unit root to the simulations from #997, as adf_z_simlation_process.py does for the ADF z-test. The p-value is now fit to the asymptotic quantiles from the same regressions. As a result, the p-values of the asymptotic critical values are 1%, 5% and 10%.

Important

The tables come from 7,816 of the 8,000 files (n 1,966, c 1,954, ct 1,947, ctt 1,949) that were in Dropbox/adf-t on 2026-11-11, while the run was still writing. When the run is complete, rerun adf_t_simulation_process.py and update:

  • the table commit;
  • SIMULATED_QUANTILES and SIMULATED_CRITICAL_VALUES in test_adf_t_pvalue.py;
  • the numbers in the release note.

Why the critical values alone aren't enough

On main, the p-value is fit to the quantiles with T=2000. An asymptotic critical value is the constant of a regression on powers of 1/nobs, the limit as T → ∞. So the p-values of the asymptotic critical values aren't 1%, 5% and 10%, and fitting adf_t_cv_approx alone wouldn't change that. The ADF z-test has the same problem.

These are the p-values of the asymptotic 1%, 5% and 10% critical values:

n c ct ctt
ADF t, main 0.01004, 0.05000, 0.09992 0.01009, 0.05020, 0.10018 0.01015, 0.05029, 0.10030 0.01021, 0.05040, 0.10043
ADF z, main (unchanged here) 0.00991, 0.04980, 0.09966 0.00986, 0.04964, 0.09951 0.00975, 0.04933, 0.09907 0.00966, 0.04906, 0.09866
ADF t, this PR 0.009998, 0.050002, 0.100008 0.010001, 0.050001, 0.099987 0.009999, 0.050005, 0.100001 0.010000, 0.050003, 0.100003

The processing now does the following for each trend:

  1. Response surfaces: it regresses each of the 124 simulated quantiles on 1, 1/nobs, 1/nobs² and 1/nobs³. Here nobs = T − 1, the number of observations in the ADF regression, which is what ADF and PhillipsPerron pass to mackinnoncrit.
  2. Critical values: the regressions of the 1%, 5% and 10% quantiles become adf_t_cv_approx.
  3. P-value: the constants of all 124 regressions are the asymptotic quantiles, and the p-value is fit to them. MacKinnon (1994) fit his p-value functions to asymptotic quantiles in the same way.

estimate_cv_regression sets insignificant coefficients to 0 and keeps the others as they are. With n, that fits the 5% critical values worse than MacKinnon's: up to 22 standard errors off at small samples, against 4. The new estimate_response_surface instead drops the highest power of 1/nobs while it's insignificant, then fits the regression again.

Results

These compare 8.x (MacKinnon 1994 and 2010), main (#1008) and this PR. Errors are measured against the simulated asymptotic quantiles.

n c ct ctt
Largest error at the 1%, 5% and 10% quantiles 0.00008 / 0.00006 / 0.000008 0.00006 / 0.00020 / 0.000013 0.00006 / 0.00030 / 0.000005 0.00005 / 0.00043 / 0.000003
Largest relative error, p ≤ 0.15 3.3% / 0.82% / 0.05% 1.1% / 2.4% / 0.03% 5.3% / 3.7% / 0.02% 4.4% / 4.5% / 0.02%
Same, in standard errors of the simulation 45 / 25 / 2.5 19 / 58 / 2.6 79 / 94 / 5.1 61 / 122 / 5.6
Largest error, p > 0.15 0.0039 / 0.0059 / 0.0063 0.0034 / 0.0031 / 0.0041 0.0023 / 0.0018 / 0.0021 0.0011 / 0.0018 / 0.0012
Largest change in p from 8.x, p ≤ 0.15 0.00019 0.00007 0.00020 0.00006
Largest change in p from 8.x 0.0027 0.0043 0.0026 0.0019
Largest change in p from main, p ≤ 0.15 0.00010 0.00021 0.00031 0.00044
Largest change in critical values from MacKinnon (2010) 0.0007 (nobs 19) 0.0005 (nobs 19) 0.0007 (nobs 23) 0.0008 (nobs 19)
Same, nobs ≥ 100 0.00009 0.00007 0.00025 0.00006
  • Main's tail bias: ENH: Use smooth ADF t-test p-values from the new simulations #1008 measured its fit against the T=2000 quantiles. Against the asymptotic quantiles, main's left tail is off by 1% to 4.5%, more than MacKinnon's with c and ctt. This PR fixes that.
  • The body: the error with n and c is a little larger than MacKinnon's. That's the limit of a cubic above the cut-off, as in ENH: Use smooth ADF t-test p-values from the new simulations #1008.
  • Critical values: the regressions are within 2.5 standard errors of the average simulated quantile at every nobs from 19 to 1999. With n, 1/nobs³ is dropped at all three sizes.
  • Docstring examples: the ADF examples change from 0.0273 to 0.0271, and from 0.0825 to 0.0822 with trend="ct".

Checks

  • Data: all 7,816 files load as 124 × 31 arrays. They are finite and increase with the probability, and no two are identical.
  • Processing:
    • A monotone fit is found with the smallest tail step, 1e-12, for every trend.
    • A second run writes the same file.
    • adf_z_simlation_process.py, run after it, reproduces the file byte for byte, so it keeps the new section.
  • Tests:
    • The unit root tests and test_lower_case_options.py pass (8,280).
    • The full suite passes with --skip-slow (31,562 passed, 812 skipped).
    • The docstring examples of arch.unitroot pass.
    • black, isort, ruff and flake8 pass, and mypy finds no new errors.

Changes

  • Processing: estimate_response_surface in shared.py, used by adf_t_simulation_process.py, which now also writes adf_t_cv_approx. The script reads tau_2010 from the file it updates, for the comparison it prints. Importing it from arch.unitroot fails until the file has adf_t_cv_approx.
  • Tables: dickey_fuller.py regenerated.
  • mackinnoncrit: with dist_type="adf-t" and one unit root, it uses adf_t_cv_approx. With more than one unit root, it still uses MacKinnon (2010). The docstrings of mackinnoncrit and ADF and the two ADF examples are updated.
  • Tests:
    • New checks that the p-values of the asymptotic critical values are 1%, 5% and 10%.
    • New checks of the critical values against the simulated quantiles with nobs 24, 99 and ∞, and that more than one unit root uses MacKinnon (2010).
    • The p-value reference quantiles are now asymptotic, and test_adf_no_options and test_adf_critical_value are updated.
  • Release note: the ENH: Use smooth ADF t-test p-values from the new simulations #1008 entry is revised.

Not changed

  • The ADF z-test: it has the same inconsistency, shown in the table above.
    • Its processing uses estimate_cv_regression, and on main the 1/T³ terms of the 5% and 10% values with n and c are 0.
    • Its response surfaces are in the series length T, while ADF and PhillipsPerron pass nobs = T − 1.
    • The same changes would apply to adf_z_simlation_process.py.
  • More than one unit root: MacKinnon (1994) p-values and MacKinnon (2010) critical values.

🤖 Generated with Claude Code

Regress every simulated quantile of the ADF t-statistic on a constant and
powers of 1/nobs, where nobs = T - 1 is the number of observations in the
regression, as ADF and PhillipsPerron pass to mackinnoncrit. The
regressions of the 1%, 5% and 10% quantiles are the critical values,
adf_t_cv_approx, as for the ADF z-test. The p-value is fit to the
constants, the asymptotic quantiles, in place of the quantiles with
T=2000, so the p-values of the asymptotic critical values are their
sizes.

estimate_response_surface refits after dropping the highest power of
1/nobs while it is insignificant, where estimate_cv_regression sets
insignificant coefficients to 0 without refitting. tau_2010 is read from
the file that is updated, since importing it from arch.unitroot needs the
values that the script writes.
Run adf_t_simulation_process.py on 7,816 simulation files (n 1,966,
c 1,954, ct 1,947, ctt 1,949; 250,000 draws each). Adds adf_t_cv_approx
and refits the p-value to the asymptotic quantiles.
mackinnoncrit uses adf_t_cv_approx for the ADF t-test with one unit root,
so the critical values of ADF and PhillipsPerron come from the same
simulations as the p-values. With more than one unit root it still uses
MacKinnon (2010). Update the ADF and mackinnoncrit docstrings and the ADF
examples (0.0273 -> 0.0271, 0.0825 -> 0.0822 with trend="ct").
Check that the p-values of the asymptotic critical values are 1%, 5% and
10%, that the critical values match the simulated quantiles with 24, 99
and infinitely many observations, and that more than one unit root uses
MacKinnon (2010). The p-value reference quantiles are now the asymptotic
quantiles, and test_adf_no_options expects 0.027104.
The critical values with one unit root are now fit to the same
simulations as the p-values, and the p-value to the asymptotic quantiles.
Update the numbers for the 7,816 simulation files.
@codecov

codecov Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.44%. Comparing base (8a47786) to head (3b28fd9).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1017   +/-   ##
=======================================
  Coverage   99.44%   99.44%           
=======================================
  Files         153      153           
  Lines       34229    34259   +30     
  Branches     2591     2594    +3     
=======================================
+ Hits        34039    34069   +30     
  Misses        114      114           
  Partials       76       76           
Flag Coverage Δ
adder 99.38% <100.00%> (+<0.01%) ⬆️
subtractor 99.38% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bashtage
bashtage marked this pull request as ready for review November 11, 2026 13:27
@bashtage
bashtage merged commit 67045ff into main Nov 11, 2026
28 checks passed
@bashtage
bashtage deleted the a90-adf-t-cv branch November 14, 2026 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant