union_test()tests for a unit root when it is not known whether a trend belongs or how large the initial condition is (Harvey, Leybourne and Taylor, 2012): ADF and DF-GLS, each with a constant and with a constant and trend, rejecting when any rejects, with a critical value enlarged so that the union as a whole has the nominal size.- Critical values and p-value come from the package's own finite-sample response surface for the union statistic, in the sample size and the number of lags (250,000 replications per sample size; the papers give asymptotic constants only). Out of sample its size at 5% is 4.7%-5.3%.
summary()shows the four component tests, each with its own critical values and p-value; the note says which one drives the statistic.- Why it matters: the sequential strategy of
ur_strategy()rejects a driftless random walk about 13% of the time at the 5% level (three 5% tests in sequence); the union keeps 5%. With a large initial condition DF-GLS has no power and the union keeps most of ADF's; with a trend the tests with a constant only have no power and the union keeps about half. See the vignette anddata-raw/union_validate.R. - The surface is shared in
inst/fixtures/union_response_surface.json.
- p-values are exactly the level at the tabulated critical values (ported
from cointegrationtools 0.1.1, audit M03). Rounding in the interpolation
(and
1 - 0.90for the upper-tail φ tests, and the numerical roots behind the KPSS critical values) could give, e.g., p = 0.04999999 at the 5% critical value, where the decision is "do not reject". Decisions were never affected: they are taken from the critical values, andlevelis always a tabulated level, so a p-value at the 0.001 bound never decides. ?select_lagsdocuments the MAIC trade-off: it keeps the size under negative moving-average errors but often chooses lags nearkmaxfor series far from a unit root, which costs power (simulation figures in the help page). MAIC remains the default; its penalty was checked against an independent computation.
adf(),pp(),ur_strategy()andrecursive_adf()take the critical values and p-values of τ1, τ2 and τ3 (and Z_τ) from the package's own finite-sample response surfaces in the sample size and the number of lags, estimated by Monte Carlo like those of DF-GLS and φ (400,000 replications per sample size, k = 0, ..., 21). Before, critical values were MacKinnon's (2010) and p-values MacKinnon's (1996) throughurca::punitroot(), both computed without lags.- Critical values and p-value now come from one surface, so the p-value is
exactly 0.05 at the 5% critical value. Without lags the critical values
agree with MacKinnon's to 0.001-0.005 (0.008 with a trend at N = 24), and
the calibration note of every result shows MacKinnon's values for
comparison. Out of sample the empirical size at 5% is between 4.7% and 5.4%
(
data-raw/tau_validate.R). - As for the other surfaces, outside the simulated design (k > 21, or a
sample too short for k) the boundary is used with a warning; in strategies
these warnings name the step (
tau3: ...), once. - urca moves from Imports to Suggests (used only by tests comparing with it); the package's only non-base dependency is generics.
- The surfaces are shared with other implementations in
inst/fixtures/tau_response_surfaces.json. - The simulation kernel (
data-raw/tau_kernel.cpp) also computes Engle-Granger residual-based statistics, for the cointegration package.
kpss(): the variance fields (gamma0,long_run_varianceinother_statistics) are in the units of the series again. Since 0.3.1 they were those of the series divided by its largest absolute value. They areNAwhen the number cannot be represented (units beyond about 1e154).kpss(): a genuine series on a large level (e.g. 1e14 + noise) is no longer refused as constant, and its statistic is computed to full precision: the residuals are now taken from the series scaled by a power of two (exact) and centred in two passes, and the series is refused only when the residuals are within 4 rounding steps of zero (constant series and exact trends leave at most 1.2; series with noise of 8 rounding steps leave at least 13).boot_ur()andsimulate_df()accept any seed thatset.seed()accepts (e.g.seed = 20261118); 0.3.1's bound of 1,000,000 was meant for lag orders and frequencies, not seeds.- A
tswith an absurd frequency (e.g..Machine$integer.max) no longer makesadf()fail through its residual check:recursive_adf()andresidual_check()stop with a clear message (passfrequency =), and test results say the residual check was not done. recursive_adf()with fixedlagsno longer claims a look-ahead: only lags selected on the full sample use later observations.plot()ofsimulate_df()results accepts graphical arguments (main,breaks, ...) like the other plots.- Long-run variances with a zero bandwidth (e.g. Andrews' rule when the AR(1) plug-in is exactly zero) are the zero-bandwidth limit, gamma0, for every kernel; the QS kernel used to divide by zero.
criterionaccepts unambiguous abbreviations again ("AI"is AIC), now in any case; 0.3.2 had dropped them when it made the matching case-insensitive.data-raw/README.mddocuments every calibration pipeline (φ, normalized bias, Ng-Perron/ERS tables, τ) and the platform requirements for regenerating them.
Fixes found while writing the unit-root Labs (14 November 2026).
- Subsetting a
recursive_adf()result works withprint(): keeping all the columns (e.g.rr[rr$reject, ]) keeps the result and its settings; selecting columns (e.g.rr[, c("end", "statistic")]) gives a plain data frame. Before, the second case kept the class but lost the settings, andprint()failed ("argument is of length zero"). criterionis accepted in any case ("aic","Maic"...) inadf(),select_lags(),dfgls(),ng_perron(),ers_pt(),ur_strategy(),recursive_adf()andboot_ur().- Printed samples show dates when the series has them:
"Effective sample: N = 780, 1961-01 to 2025-12 (t = 13, ..., 792)", in
tests, strategies and
select_lags()(monthly "1961-01", quarterly "1990 Q3", annual "1902"). Plain vectors show the indices, as before.select_lags()andur_strategy()results now keep theseriesrecord.
Fixes from the audit of 0.3.0 (14 November 2026).
recursive_adf(reselect = TRUE)ignoredmax_lagsin the windows (it was only used for the full-sample choice), so windows could use more lags than requested.max_lagsnow caps every window (or the window's largest feasible order, if smaller).kpss()is invariant to the units of the series, as it should be: a series multiplied by 1e-12 was wrongly refused as "constant" (the check had an absolute floor), and very small or very large units could underflow. The statistic is now computed on the series divided by its largest absolute value; constant series and exact linear trends are still refused.recursive_adf()describes its critical values as nominal pointwise references, and says when the lag order was chosen on the full sample (look-ahead: the lag order of an early window depends on later data).residual_check():white_noiseisNA(notTRUE) when no Breusch-Godfrey test could be computed, and the printed result says the check is unavailable.- Whole-number arguments (lags,
max_lags,frequency, window sizes,B) above 1,000,000 are refused with a clear message, instead of overflowing later (e.g.dfgls(y, lags = .Machine$integer.max)). plot()ofrecursive_adf()andresidual_check()results acceptsmain,xlab,ylab,ylim,typeand other graphical arguments, which override the defaults (they used to clash with them).boot_ur(): the reported sample (t = k + 2, ..., T) was checked against bootUR's source; KPSS help text repeated part of a sentence (fixed).
Diagnostics (spec D19, D20), prepared for the unit-root Labs of the course. The roadmap is renumbered: the bootstrap engine (D18) becomes v0.4, the Monte Carlo tools v0.5 and the robust tests v0.6.
-
New
recursive_adf(): ADF statistics on samples with a fixed start and a moving end (window = "recursive") or on rolling windows (window = "rolling"), against the critical value for each window's sample size, withprint()andplot(). Default sizes depend on the frequency: first sample max(5s, 30) and width max(10s, 40) observations. Lags are selected once on the full sample and kept fixed (reselect = TRUEselects them in each window). The critical values are pointwise, and the output says so: the minimum over windows has a different distribution (Banerjee, Lumsdaine and Stock 1992). -
The residual check is also reported where students look (spec D19):
summary()of a test gives the Breusch-Godfrey F p-values; a result whose residuals fail carries a warning suggesting a largerlags; the history ofur_strategy()has abg_p_valuecolumn (printed as "Resid. p") for each step's regression, the strategy warns about any regression that fails, andresidual_check()on a strategy gives the full check of each regression. The number of lags is never raised automatically: that would be a lag-selection rule with unknown consequences for the size of the test. -
New
residual_check(): do the lagged differences of a test leave white-noise residuals (spec D19)? Foradf(),dfgls(),ng_perron(),ers_pt()and the terminal test ofur_strategy(), it reports the correlogram of the test regression's residuals (AC, PAC, Ljung-Box Q with h - k degrees of freedom, marked approximate) and Breusch-Godfrey tests (F form, the main one, and LM = Obs*R-squared, as in EViews), withprint()andplot()(ACF and PACF with +/- 1.96/sqrt(N) bands). Lags follow the frequency of the data: 3s + 3 (39 monthly, 15 quarterly, 6 annual), capped at N/4; Breusch-Godfrey at orders s and 3s + 3. Agrees withlmtest::bgtest()andstats::Box.test().pp()andkpss()are not checked: their residuals are autocorrelated by design. -
Results keep what the residual checks need (spec D19):
regressionnow holds the residuals and the regressor matrix of the test regression foradf(),dfgls(),ng_perron(),ers_pt()and the regression steps ofur_strategy(); and a newseriesfield records the series' name, its frequency (observations per year, fromts, zoo/xts, tsibble or a data frame with a date column;NAfor a plain vector) and the time point of each observation. -
dfgls()is computed by the package instead ofurca::ur.ers(), with the same GLS detrending and lag handling asng_perron()anders_pt(). The statistic is unchanged (it agrees with urca to 1e-12 and with an independent implementation of the published formulas);enginenow says "internal". urca is now used only for MacKinnon's τ p-values.
Fixes from the audit of 0.2.0 (4 November 2026).
- p-values from the package's own calibrations (DF-GLS, φ, Z_alpha, Ng-Perron, ERS) could be wrong far in the tail: the local cubic used to interpolate between simulated quantiles was extrapolated beyond them and could turn back, giving p = 1 for clearly stationary data that the test rejected (e.g. Ng-Perron MZ_t at T = 250). The distribution function is now interpolated linearly in qnorm(p) between the 117 simulated quantiles (monotone, exact at them). Beyond the simulated range the p-value is reported as the bound 0.001 or 0.999, printed "< 0.001" or "> 0.999", with a note in the result. Inside the range, p-values change only in the third or fourth decimal. The shared DF-GLS JSON file and its Python reader use the same rule.
kpss()no longer fails for very large statistics (e.g. a trending series withbandwidth = 0, where the numerical integration did not converge): beyond the 0.001 and 0.999 quantiles of the limit the p-value is reported as the bound, as for the other calibrations. A constant series (or an exact linear trend withtrend = "ct") now stops with a clear error, instead of a statistic made of rounding noise or an integration error. The source is described as the limiting distribution "computed numerically" rather than "exact".dfgls(),ng_perron()anders_pt()require two residual degrees of freedom in the test regression, like the other tests (before,dfgls()accepted one, e.g.dfgls(c(1, 3, 2), lags = 0)).new_ur_test()rejects whole-number fields beyond the integer range (e.g.lags = 2^40), which were stored asNA.ur_strategy()no longer hides calibration substitutions: when a φ step lies outside the simulated design (e.g.lags = 25, where k = 21 is used), itscalibrationnames the settings actually used, the history has a newwarningscolumn, and the strategy collects the warnings of every visited step inwarnings, printed with the result and counted byglance()(n_warnings).- Documentation: KPSS probabilities are described as computed numerically
from the limiting distribution (not "exact"); p-values and critical values
"agree closely" rather than "always"; the README lists what is computed by
urca and bootUR and the main approximations (asymptotic KPSS,
Dickey-Fuller distributions for Phillips-Perron, fixed-lag calibrations
versus selected lags);
boot_ur()documents its owntrendandmax_lags;new_ur_test()documents the bootstrap exception. - The Enders GDP tests also read their settings and expected values from the
shared fixture
inst/fixtures/enders_rgdp.json, and check the data file. - Note for code written for 0.1.x:
pp()andkpss()gained akernelargument beforebandwidthin 0.2.0, so a positional call such aspp(y, "c", "long")now passes"long"as the kernel (and stops with an error). Name the argument:pp(y, "c", bandwidth = "long").
- The φ statistics of
adf()andur_strategy()now take their critical values and p-values from the package's own finite-sample response surfaces in the sample size and the number of lags (decision D16), replacing the Dickey-Fuller (1981) tables. Without lags they agree with the tables (e.g. φ3 at T = 100: 8.76/6.48/5.47 against 8.73/6.49/5.47); with lags they also account for k. φ statistics now have p-values (shown bysummary(),tidy()and the strategy history). pp()'s Z_alpha now has critical values and a p-value, from the finite-sample distribution of the Dickey-Fuller normalized bias (D16).- New
ng_perron()(MZ_alpha, MZ_t, MSB, MP_T) anders_pt()(ERS point-optimal P_T), on GLS-detrended data with lags chosen as fordfgls()(decision D15). Critical values and p-values come from the package's own simulation over T and k: the simulated quantiles are tabulated and interpolated in 1/T, because at small T with many lags their tails explode (e.g. the 5% quantile of MZ_alpha at T = 25 with 6 lags is about -800) and no smooth surface follows them. Out of sample, the 5% tests reject between 4.0% and 5.8% of the time under the null. With a trend, the limits differ from Ng and Perron's (2001) Table 1 (5% MZ_alpha -16.6 against -17.3, MZ_t -2.85 against -2.91); an independent simulation and urca's DF-GLS agree with the package. - When the lag order is large for the sample size,
ng_perron()anders_pt()warn that the null distribution is very heavy-tailed (5% critical value of MZ_alpha more than twice its no-lag value) and the test can hardly reject;adf()warns that its φ critical values are accurate only to about 5% at T <= 30 with 7 or more lags. - New
boot_ur(): bootstrap ADF and union-of-rejections tests through the bootUR package (in Suggests; decision D17). The result is aur_testwhose decision uses the bootstrap p-value. - New long-run-variance module (decision D13) for
pp()andkpss(): Bartlett, Parzen and Quadratic Spectral kernels (kernel =), and automatic bandwidthsbandwidth = "andrews"(Andrews, 1991) and"newey-west"(Newey and West, 1994), besides Schwert's rules and fixed values. Defaults are unchanged. kpss()is computed internally, no longer by urca, and now reports a p-value. Its critical values and p-value come from the exact limiting distribution (decision D14); Kwiatkowski et al.'s simulated table, used before, differs in the third decimal (e.g. 0.146 instead of 0.148 at 5% with a trend).pp()also reports the normalized-bias statistic Z_alpha (inother_statistics).- Results of
pp()andkpss()describe the long-run variance used ("Bartlett kernel, 4 autocovariances (short rule, ...)"). - The DF-GLS response surfaces are also available as a language-neutral
file,
inst/fixtures/dfgls_response_surfaces.json, with reference values, so that the Python package can share the same calibration.
adf(),pp(),kpss()anddfgls()returned their result invisibly since 0.1.0, so calling them at the console (or in the vignette) printed nothing. Results are returned visibly again; a test guards against this.
These follow decisions D1, D3 and D7-D10 of the specification
(spec/specification.qmd).
- After lag selection,
adf()now re-estimates the test regression on all the observations available for the chosen order (final_sample = "maximal", the new default), as the Python package, ARCH, bootUR and EViews do.final_sample = "common"keeps the previous behaviour. Results with selected lags can therefore change slightly; results with fixedlagsdo not. ur_strategy()follows the same rule (all its regressions share one sample) and gains afinal_sampleargument.- The default
kmaxis capped for very short series (T <= 21) so that every candidate regression keeps two residual degrees of freedom; a note reports the cap. Amax_lagsabove the feasible maximum is an error. adf()reports MacKinnon's (1996) finite-sample p-value (viaurca::punitroot()); the decision is still taken from the critical value, and the two agree to four decimals at the tabulated levels.dfgls()selects the number of lags automatically whenlagsis not given: MAIC (or another criterion) on the OLS-detrended series, as recommended by Perron and Qu (2007).- New
tidy()andglance()methods for tests and strategies (generics from the lightweightgenericspackage; broom is not needed). - New tests against 120-digit reference calculations shared with the Python
package (
inst/fixtures/python/).
- The history of
ur_strategy()now reports a p-value for each step (MacKinnon, 1996, for the tau tests; Student t for the conditional and auxiliary t tests; none for the phi tables). plot()ofsimulate_df()results is readable at small sizes, and the vignette draws its figures larger.- The vignette covers p-values, automatic lag selection in
dfgls(), the per-step p-values of strategies, andtidy()/glance().
- The statistics of
kpss()anddfgls()(computed by urca) are now tested against independent implementations of the published formulas. - Found two problems in the urca backend, both fixed below:
dfgls()critical values were too liberal in finite samples, and urca's Phillips-Perron Z_tau departs from the published formula in small samples. dfgls()critical values and p-values now come from the package's own finite-sample response surfaces (decision D11), estimated from a Monte Carlo simulation over sample size and lag order (code indata-raw/). urca's critical values, used before, rejected a true unit root 8% of the time at the 5% level with T = 100 and a constant; the new ones give 4.8-5.3% in out-of-sample checks.pp()is now computed internally (decision D12), following Phillips and Perron (1988) and Hamilton (1994, eq. 17.6.8); urca'sur.pp()is no longer used. Values differ from earlier versions by O(1/T) (about 0.1 at T = 30, 0.02 at T = 264).pp()now reports a p-value (MacKinnon, 1996) and the long-run variance it used.
- Inputs with more than two dimensions, and matrix-valued data-frame columns, are rejected instead of being flattened into one apparent series.
max_lags,lagsand fixedbandwidthvalues must be single non-negative whole numbers; values such as 2.9 or -0.5 are errors instead of being silently truncated.levelis checked when a test is called, with a message listing the available levels (0.01, 0.05, 0.10; KPSS also 0.025).ur_strategy()checks thatallow_no_constantisTRUEorFALSE.- Every regression needs at least two residual degrees of freedom, as the specification requires.
validate_ur_test()now enforces the whole result contract, including the stored decision, canonical trend codes, integer fields, finite accompanying statistics and their critical values. The constructor no longer truncates non-wholelags,nobsorsample.print()on a test result now shows the source of the critical values.- Maintainer email set; specification and README roadmap made consistent
(Hamilton's Case 3 in v0.4;
tidy()/glance()marked as planned).