*! version 1.1.0 23feb2026

Title

rardl -- Rolling-Window and Recursive ARDL Cointegration Analysis

Syntax

rardl depvar indepvars [if] [in],
type(string)
[options]

* type(string) analysis type: rolling, recursive, radf, rgranger, or simulate

Model specification
maxlag(#) maximum lag length for ARDL/VAR; default is 4

ic(string) information criterion for lag selection: aic, bic, or hqic; default is bic

case(#) PSS model case (1-5); default is 3

level(#) significance level: 1, 5, or 10; default is 5

Rolling-window options
wsize(numlist) window size(s) in observations; default is 60 120 180 240

allmodels estimate all 5 PSS models simultaneously

Recursive options
initobs(#) initial sample size for expanding window; default is 60

allcases estimate all PSS cases (2, 3, 5)

transform(string) level, log, or both; default is level

Recursive ADF options
adfcase(string) 2 (intercept), 3 (intercept+trend), or all; default is all

transform(string) level, log, diff, dlog, or all; default is all

Monte Carlo simulation
nsim(#) number of Monte Carlo replications; default is 50000

seed(#) random number seed for reproducibility

nosimulate skip simulation, use asymptotic critical values from PSS (2001)

Display and output
graph produce publication-quality graphs

notable suppress all table output

* type() is required.

Data must be tsset before using rardl.

Description

rardl implements the Rolling-Window ARDL bounds testing approach of
Shahbaz, Khan & Mubarak (2023) and the Recursive ARDL, ADF, and Granger
causality tests of Khan, Shahbaz & Napari (2023). These methods evaluate
subsample stability and time-varying cointegration.

The core idea is to apply the Pesaran, Shin & Smith (2001) ARDL bounds test
not just once on the full sample, but repeatedly across overlapping
sub-samples (rolling windows) or expanding sub-samples (recursive). This
reveals when and how the long-run equilibrium relationship
changes over time.

The package provides five analysis types:

rolling - Rolling-window ARDL bounds test. Applies
the ARDL ECM (Error Correction Model) over fixed-size rolling windows.
For each window, it estimates the model:

D.y = c + alpha*L.y + beta*L.X + Sum(gamma_i*L_i.D.y, i=1..p) + Sum(delta_j*L_j.D.X, j=0..q) + e

Lag orders p (for D.y) and q (for D.X) are selected
separately via IC-based grid search over all ARDL(p,q) combinations.
The ARDL column in the output shows the selected (p,q) per window.
The F-statistic tests H0: alpha = beta = 0 (no long-run
relationship). Three tables are reported: Long-Run (ECM, LR beta,
bounds F-test), Short-Run (SR delta, SR F-test), and
Critical Value Comparison (asymptotic vs simulated CVs with
I(0)/I(1) zone classification).

recursive - Recursive ARDL bounds test. Starts with
initobs observations and sequentially expands to the full sample,
re-estimating the ARDL(p,q) model at each step with separate lag selection.
Produces long-run, short-run, and CV comparison tables mapping the
evolution of relationships.

radf - Recursive Augmented Dickey-Fuller unit root
test. Applies expanding-window ADF tests to evaluate whether unit root
conclusions are stable across sample sizes. Tests multiple transformations
(level, log, differenced, diff-log) with automatic verdicts: "Consistent
Stationarity", "Consistent Non-stationarity", or "Mixed".

rgranger - Recursive Granger causality test. Tests
both directions of Granger causality (y1 -> y2 and y2 -> y1) using
expanding windows. A bivariate VAR is estimated at each sample size, and
the Granger F-statistic is normalized by critical values.

simulate - Standalone Monte Carlo simulation for
finite-sample critical values. Generates I(0) and I(1) critical bounds
for all 5 PSS model specifications at 1%, 5%, and 10% significance
levels. Based on the PSS (2001) DGP with independent random walks.
Includes a PSS vs Simulated comparison table showing percentage
differences between asymptotic and finite-sample CVs for each model,
sample size, and significance level.

Options

Model specification

maxlag(#) specifies the maximum number of lags considered
during automatic ARDL(p,q) lag selection. Separate optimal lags are
selected for the dependent variable (p = 1..maxlag) and independent
variables (q = 0..maxlag) using IC-based grid search over all (p,q)
combinations. Default is 4.

ic(string) specifies the information criterion used for
automatic lag length selection: aic (Akaike), bic (Bayesian/
Schwarz, the default), or hqic (Hannan-Quinn).

case(#) specifies the PSS model case (deterministic
specification):

Case 1: No intercept, no trend

Case 2: Restricted intercept, no trend

Case 3: Unrestricted intercept, no trend (default)

Case 4: Unrestricted intercept, restricted trend

Case 5: Unrestricted intercept, unrestricted trend

level(#) sets the significance level for hypothesis testing.
Allowed values are 1, 5, or 10; default is 5.

Rolling-window options

wsize(numlist) specifies one or more window sizes (in
observations) for the rolling-window test. Multiple sizes can be specified
to compare results across different window widths. Default is 60 120 180
240.

allmodels requests estimation for all 5 PSS model cases
simultaneously, rather than just the case specified in case().

Recursive options

initobs(#) sets the initial sample size for the expanding
window. The recursive procedure starts estimation with this many
observations and adds one observation at a time until the full sample is
reached. Default is 60. Must be larger than the number of parameters.

allcases requests estimation for all default cases (2, 3, 5)
simultaneously.

transform(string) specifies the data transformation:
level (default) uses the raw variable, log takes natural
logarithms, both runs both level and log specifications.

Recursive ADF options

adfcase(string) specifies the ADF regression specification:
2 includes an intercept, 3 includes intercept and trend,
all runs both. Default is all.

transform(string) specifies the variable transformation for
ADF testing: level (raw), log (natural log), diff (first
difference), dlog (differenced log), or all (all four
transformations). Default is all.

Monte Carlo simulation

nsim(#) sets the number of Monte Carlo replications. Larger
values produce more precise critical values but take longer. Default is
50000. For quick testing, use 500-5000.

seed(#) sets the random number seed for reproducible
simulation results.

nosimulate skips Monte Carlo simulation and uses asymptotic
critical values from PSS (2001) Table CI instead. This is much faster but
may be imprecise for small samples (<80).

Display and output

graph produces publication-quality graphs showing the
evolution of test statistics over time. For rolling/recursive ARDL, two
graphs are created: z-statistic and p-value plots with significance
thresholds. For RADF, z-ADF plots with unit-root threshold. For Granger,
z-GC plots per direction.

notable suppresses all table output. Useful when only graphs
or stored results are needed.

Analysis Types in Detail

rolling — Rolling-Window ARDL

The rolling-window ARDL bounds test (RARDL) slides a fixed-size window
across the time series and computes the PSS bounds F-test at each
position. This captures time-varying cointegration. Key parameters:

• The normalized z-statistic: z_bt = F / UCV

• Cointegration detected when z_bt > 1

• ECM coefficient (alpha) shows speed of adjustment

• Long-run coefficient (beta) shows L.X effect

• Short-run coefficient (delta) shows D.X effect

Output includes two organized tables per model/window:

Long-Run Results table: Period, ECM(alpha), LR(beta), F-bounds, UCV,
z-bt, Decision (*** = cointegration)

Short-Run Results table: Period, SR(delta), SR F-stat, p-value,
Decision (*** = significant), ECM(alpha), LR Decision

recursive — Recursive ARDL

The recursive ARDL uses an expanding window starting from initobs.
The main advantage over rolling windows is that it avoids window size
selection and uses all available information. The output structure is
identical to rolling, with separate Long-Run and Short-Run tables.

radf — Recursive ADF

Applies the ADF unit root test with expanding windows. For each variable
and transformation, a detailed table shows:

End Period, t-statistic, Critical Value, z-ADF, Decision

Verdicts are assigned based on the proportion of rejections:

• >=95% reject: "Consistent Stationarity"

• >=80% reject: "Stationarity w/ exceptions"

• 50-80%: "Mixed evidence"

• 20-50%: "Non-stationarity w/ exceptions"

• <5%: "Consistent Non-stationarity"

rgranger — Recursive Granger Causality

Tests both directions of Granger causality using expanding windows.
For variables y1 and y2, a bivariate VAR is estimated at each sample
size, and the Wald/F-test for Granger non-causality is computed.

Output shows a bidirectional table:

Period, F(y2 -> y1), z-GC, Decision, F(y1 -> y2), z-GC, Decision

Where z-GC = F / CV(alpha). The *** marker indicates rejection of the
no-causality null (i.e., Granger causality is detected).

simulate — Monte Carlo Critical Values

Generates finite-sample critical bounds for the ARDL F-test. The DGP
follows Pesaran et al. (2001): y is a random walk, X variables are
either I(0) (AR(1) with phi=0.5) or I(1) (random walk). Critical
bounds are the 90th, 95th, and 99th percentiles of the simulated
F-statistics.

Output is a table for each of the 5 PSS models showing I(0) and I(1)
bounds at 1%, 5%, and 10% significance levels for each sample size.

Output Description

Summary statistics

Each test type first displays a summary showing:

• Number of windows/tests performed

• Proportion showing cointegration/stationarity/causality

• First and last dates of significance

• Overall verdict

Detailed tables

Below each summary, a sampled table of approximately 20 rows is
displayed, covering the full estimation period at regular intervals.
The table always includes the first and last observations.

Graphs

When graph is specified, the following plots are produced:

z-statistic plot: Shows the evolution of z = F/UCV with a
dashed red threshold line at z = 1. Green shaded areas indicate
cointegration periods (z > 1).

p-value plot (rolling only): Shows rolling p-values with
horizontal dashed lines at 1%, 5%, and 10% significance.

z-ADF plot (radf): Shows z_ADF with threshold at 1 and
shaded rejection/non-rejection regions.

z-GC plot (rgranger): Shows Granger causality z-statistic
per direction with threshold at 1.

All graphs are automatically exported as PNG files (1400px width) in the
current working directory.

Interpretation Guide

This section explains how to read and interpret rardl output with
concrete examples. Each subsection corresponds to a test type.

Interpreting the Long-Run Table (rolling / recursive)

The Long-Run table tests for cointegration (long-run equilibrium
relationship) at each window or expanding sample. Consider this output:

Long-Run Results (Cointegration)

Period ECM(a) LR(b) F-bounds UCV z-bt Dec

1990m6 -0.0259 0.0413 3.134 5.730 0.547

2010m4 -0.2685 0.4518 4.532 5.730 0.791

2015m12 -0.0333 0.7214 7.095 5.730 1.238 ***

How to read each column:

• ECM(a) = Error Correction coefficient (alpha): speed of adjustment
toward equilibrium. Should be negative and significant for valid
cointegration. Values near 0 suggest no adjustment; values near -1 suggest
rapid correction. Example: ECM = -0.2685 means 26.85% of disequilibrium is
corrected each period.

• LR(b) = Long-run coefficient (beta) on L.X: the estimated
long-run elasticity. A 1-unit increase in X is associated with a beta-unit
change in Y in the long run. Example: LR(b) = 0.4518 means a $1 rise in
silver is associated with a $0.45 rise in oil in long-run equilibrium.

• F-bounds = PSS bounds F-statistic testing H0: alpha = beta = 0
(no level relationship). Larger values suggest stronger evidence of
cointegration.

• UCV = Upper critical value at the specified significance level.
When F > UCV, we reject H0 and conclude cointegration regardless of whether
regressors are I(0) or I(1).

• z-bt = Normalized statistic = F / UCV. When z-bt > 1,
F exceeds the upper bound (cointegration confirmed). Values between
LCV/UCV and 1 are inconclusive.

• Dec = Decision: *** indicates cointegration (z-bt > 1).

Interpretation of the row for 2015m12: The bounds F-test (7.095) exceeds
the UCV (5.730), giving z-bt = 1.238 > 1. This indicates cointegration during
the window ending December 2015. The ECM coefficient (-0.033) is negative,
suggesting adjustment toward equilibrium (though slow). The LR beta (0.721)
indicates a positive long-run relationship.

Interpretation of the row for 1990m6: F = 3.134 < UCV = 5.730, so
z-bt = 0.547 < 1. No cointegration in this window. Even though ECM is
negative, the bounds test fails to confirm a statistically significant
level relationship.

Interpreting the Short-Run Table (rolling / recursive)

The Short-Run table tests for short-run dynamics — whether changes
in X have an immediate effect on changes in Y:

Short-Run Results (Dynamics)

Period SR(d) SR F p-val Dec ECM(a) LR Dec

1990m6 0.1823 5.421 0.0016 *** -0.0259

2010m4 0.3150 2.873 0.0418 *** -0.2685

2015m12 0.0213 0.341 0.7952 -0.0333 ***

• SR(d) = Short-run coefficient (delta) on D.X: the immediate
impact of a change in X on the change in Y. Example: SR(d) = 0.315 means a
$1 change in silver leads to an immediate $0.315 change in oil.

• SR F-stat = Joint F-test for all differenced X terms (D.X and
its lags). A significant SR F-test means short-run dynamics exist.

• p-val = P-value of the SR F-test. Values < 0.05 are
significant at 5%.

• LR Dec = Cross-reference showing whether cointegration was also
found in this window (from the Long-Run table).

Key insight — comparing LR and SR: A window can show significant
short-run dynamics WITHOUT long-run cointegration (1990m6: SR *** but no
LR ***), or long-run cointegration WITHOUT significant short-run effects
(2015m12: LR *** but no SR ***). The ideal case is when both are
significant, confirming both the equilibrium relationship and the
transmission mechanism.

Interpreting RADF (Recursive ADF) output

The RADF table shows whether a variable's stationarity status is
stable across different sample sizes:

Period t-stat CV(5%) z-ADF Decision

1976m4 -2.8325 -2.8741 0.9855 Fail

1987m8 -1.5858 -2.8683 0.5529 Fail

• t-stat = ADF t-statistic. More negative = stronger evidence
against unit root.

• CV(5%) = Critical value at 5%. Reject unit root when t-stat < CV
(i.e., more negative).

• z-ADF = |t-stat / CV|. When z-ADF > 1, the t-stat exceeds the
critical value (reject unit root = variable is stationary).

• Decision = "Reject" (stationary) or "Fail" (unit root).

Verdict interpretation: If the verdict is "Consistent
Non-stationarity" (0% rejection), the variable contains a unit root
across all sample sizes — standard for asset prices. If "Consistent
Stationarity" (>95% rejection), the variable is I(0). "Mixed evidence"
suggests a structural break may have changed the integration order.

Interpreting Granger Causality output

The Granger causality table shows both causal directions:

Period F(gold) z-GC Dec F(oil) z-GC Dec

-> oil -> gold

1976m4 1.076 0.277 6.306 1.621 ***

2013m2 0.039 0.010 0.126 0.033

• F(gold) -> oil: F-statistic testing whether lagged gold values
help predict oil. *** means gold Granger-causes oil.

• F(oil) -> gold: F-statistic for the reverse direction.

• z-GC = F / CV. When z-GC > 1, causality is significant.

How to interpret: In 1976m4, oil Granger-causes gold (z = 1.621 > 1)
but gold does NOT Granger-cause oil (z = 0.277 < 1). This is
unidirectional causality from oil to gold. By 2013m2, neither direction
shows causality (no causal relationship in this period).

Possible patterns:

• Both *** = Bidirectional (feedback) causality

• One *** = Unidirectional causality

• Neither *** = No Granger causality

• Pattern changes over time = time-varying causal structure

Interpreting Verdicts

The overall verdict summarizes the proportion of windows/iterations
showing significance:

Verdict Percentage Meaning

Cointegration >= 95% Robust LR relationship

Coint. w/ rare exceptions >= 80% Mostly stable

Coint. w/ exceptions >= 50% Evidence exists

Inconsistent 20-50% Unreliable

No coint. w/ rare exceptions 5-20% Mostly absent

No cointegration < 5% No evidence

For academic papers, the most informative strategy is to combine
rolling and recursive approaches: concordant results strengthen the
conclusion. If the rolling test shows cointegration in a certain period
and the recursive test also shows structural change around that time,
the evidence is robust.

Writing up results

Example write-up for a paper:

"The rolling-window ARDL bounds test with a 60-month window reveals
that the long-run relationship between oil and silver is unstable.
Cointegration is detected in only 8% of windows, concentrated around
2015-2016. The ECM coefficient ranges from -0.268 to 0.091, indicating
varying speeds of adjustment. Short-run dynamics are more persistent,
with the SR F-test significant in 42% of windows, suggesting temporary
pass-through effects even in the absence of a stable equilibrium.
The recursive Granger causality test reveals unidirectional causality
from oil to gold during 1976-1985, which disappears in recent periods."

Examples

Setup: Load monthly commodity price data (oil, silver, gold) and declare time series.

. import excel "commodity_data.xlsx", firstrow clear

. gen t = tm(1960m1) + _n - 1

. format t %tm

. tsset t, monthly

Example 1: Recursive ADF unit root test

Test stationarity of oil across all transformations:

. rardl oil, type(radf) initobs(60) transform(all) adfcase(all) maxlag(4) graph

This produces tables and graphs for each combination of
transformation (level, log, diff, dlog) and ADF case (2, 3), with
automatic verdicts.

Example 2: Monte Carlo simulation

Generate critical values for common sample sizes:

. rardl oil gold, type(simulate) wsize(60 120 180 240) nsim(5000) seed(12345)

Displays I(0)/I(1) critical bounds for all 5 PSS models at 1%, 5%,
and 10% significance. Use nsim(50000) for publication-quality
results.

Example 3: Rolling-window ARDL with asymptotic CVs

Quick rolling test using PSS (2001) asymptotic critical values:

. rardl oil silver, type(rolling) case(3) wsize(60 120) maxlag(4) nosimulate graph

Displays Long-Run and Short-Run tables for each window size, plus
z-statistic and p-value graphs.

Example 4: Rolling-window ARDL with simulated CVs

Full rolling test with Monte Carlo simulated critical values:

. rardl oil silver, type(rolling) case(3) wsize(60 120) nsim(5000) seed(42) graph

Example 5: Recursive ARDL

Recursive test with level and log transformations:

. rardl oil silver, type(recursive) initobs(60) case(3) transform(both) nosimulate graph

Produces separate Long-Run and Short-Run tables for each
transformation, showing how cointegration evolves as the sample
expands.

Example 6: Recursive Granger causality

Test both directions of Granger causality:

. rardl oil gold, type(rgranger) initobs(60) maxlag(4) transform(both) graph

Displays bidirectional F-statistics, z-GC, and decisions per period.
Separate results for level and log prices.

Example 7: All PSS models

Compare all 5 PSS model specifications:

. rardl oil silver, type(rolling) wsize(120) allmodels nosimulate graph

Stored results

rardl stores the following in r():

Scalars

r(maxlag) maximum lag length

r(level) significance level

Macros

r(cmd) rardl

r(type) analysis type

r(depvar) dependent variable name

r(cmdline) full command line

r(ic) information criterion used

Each sub-command stores additional matrices:

rolling stored results

r(roll_mM_wW) result matrix for Model M, Window W.
Columns: start_obs, end_obs, F_stat, pval, z_bt, ecm_coef, lr_beta, sr_delta, sr_fstat.

recursive stored results

r(rec_cC_lev) result matrix for Case C, level transformation.
Columns: end_obs, F_stat, UCV, z_bt, ecm_coef, lr_beta, sr_delta, sr_fstat.

r(rec_cC_log) same for log transformation.

r(verdict_cC_lev) overall verdict string.

radf stored results

r(zadf_var_tr_cC) ZADF matrix. Columns: end_obs, t_stat, cv, z_adf.

rgranger stored results

r(gc_21_tr) Granger causality matrix for direction 2->1.
Columns: end_obs, F_stat, CV, z_gc.

r(gc_12_tr) same for direction 1->2.

simulate stored results

r(cv_modelM) critical value matrix for Model M.
Columns: T, LB_1pct, UB_1pct, LB_5pct, UB_5pct, LB_10pct, UB_10pct.

r(nsim) number of replications.

r(nregs) number of regressors.

Author

Dr. Merwan Roudane

Email: merwanroudane920@gmail.com

References

Khan, A.U.I., Shahbaz, M., & Napari, A. (2023).
Subsample stability, change detection and dynamics of oil and metal markets:
A recursive approach.
Resources Policy, 83, 103601.

Pesaran, M.H., Shin, Y., & Smith, R.J. (2001).
Bounds testing approaches to the analysis of level relationships.
Journal of Applied Econometrics, 16(3), 289-326.

Shahbaz, M., Khan, A.I., & Mubarak, M.S. (2023).
Rolling-window bounds testing approach to analyze the relationship between
oil prices and metal prices.
The Quarterly Review of Economics and Finance, 87, 388-395.

Also see

Help: ardl, dfuller, var, vargranger