Package 'qadf'

Title: Quantile Augmented Dickey-Fuller Unit Root Test
Description: Implements the Quantile Augmented Dickey-Fuller (QADF) unit root test following Koenker and Xiao (2004) <doi:10.1198/016214504000000296>. The test extends the standard ADF test to different quantiles of the conditional distribution, allowing for unit root behavior that varies across the distribution. Includes the QKS (Quantile Kolmogorov-Smirnov) supremum test statistic for overall unit root inference, critical values from Hansen (1995), bootstrap p-values, half-life calculations, and visualization tools. Useful for testing purchasing power parity, asymmetric adjustment, and regime-dependent persistence.
Authors: Muhammad Abdullah Alkhalaf [aut, cre] (ORCID: <https://orcid.org/0009-0002-2677-9246>), Merwan Roudane [ctb] (Original Stata implementation)
Maintainer: Muhammad Abdullah Alkhalaf <[email protected]>
License: GPL-3 + file LICENSE
Version: 1.0.0
Built: 2026-05-28 07:23:09 UTC
Source: https://github.com/muhammedalkhalaf/qadf

Help Index


Quantile Augmented Dickey-Fuller Unit Root Test

Description

Performs the Quantile ADF unit root test following Koenker & Xiao (2004). Tests for unit root across the conditional distribution using quantile regression.

Usage

qadf(y, model = c("c", "ct", "nc"), pmax = 4, 
     ic = c("AIC", "BIC", "t-stat"), 
     tau = seq(0.1, 0.9, 0.1))

## S3 method for class 'qadf'
print(x, ...)
## S3 method for class 'qadf'
summary(object, ...)
## S3 method for class 'qadf'
plot(x, ...)

Arguments

y

A numeric vector or time series.

model

Character. Deterministic component: "c" for constant (default), "ct" for constant and trend, "nc" for no constant.

pmax

Integer. Maximum number of lags for augmentation. Default is 4.

ic

Character. Information criterion for lag selection: "AIC", "BIC", or "t-stat".

tau

Numeric vector. Quantiles to test. Default is seq(0.1, 0.9, 0.1).

x, object

An object of class "qadf".

...

Additional arguments (currently ignored).

Details

The Quantile ADF test extends the standard ADF test to different quantiles of the conditional distribution. This allows testing for unit root behavior that may vary across the distribution (e.g., different persistence in expansions vs recessions).

The test statistic at quantile tau is:

tn(τ)=fzy1PXy1(ρ^(τ)1)t_n(\tau) = f_z \sqrt{y'_{-1} P_X y_{-1}} (\hat{\rho}(\tau) - 1)

Critical values are interpolated from Hansen (1995) response surfaces.

The QKS (Quantile Kolmogorov-Smirnov) statistic is:

QKS=supτtn(τ)QKS = \sup_{\tau} |t_n(\tau)|

Value

An object of class "qadf" containing:

results

Data frame with test results for each quantile

qks

QKS statistic (supremum of absolute t-statistics)

qks_cv

Critical values for QKS statistic

model

Model specification

lags

Selected lag order

n

Sample size

y

Original series

References

Koenker, R., & Xiao, Z. (2004). Unit root quantile autoregression inference. Journal of the American Statistical Association, 99(467), 775-787. doi:10.1198/016214504000000296

Hansen, B. E. (1995). Rethinking the univariate approach to unit root testing. Econometric Theory, 11(5), 1148-1171.

Examples

# Generate a random walk
set.seed(123)
y <- cumsum(rnorm(200))

# Basic QADF test
result <- qadf(y)
print(result)

# Test specific quantiles
result <- qadf(y, tau = c(0.1, 0.5, 0.9))

# With trend
result <- qadf(y, model = "ct")
summary(result)

Bootstrap QADF Test

Description

Computes bootstrap p-value for the QKS statistic from a QADF test.

Usage

qadf_bootstrap(object, nboot = 199, seed = NULL)

Arguments

object

A "qadf" object from qadf.

nboot

Number of bootstrap replications. Default 199.

seed

Random seed for reproducibility.

Details

The bootstrap procedure follows Koenker and Xiao (2004):

  1. Fit AR(p) model to first differences

  2. Resample centered residuals

  3. Generate bootstrap series under unit root null

  4. Calculate QKS statistic for each bootstrap sample

  5. P-value is proportion of bootstrap QKS >= observed QKS

Value

Updated "qadf" object with additional elements:

qks_pvalue

Bootstrap p-value for the QKS statistic

qks_boot

Vector of bootstrap QKS statistics

nboot

Number of successful bootstrap replications

References

Koenker, R., & Xiao, Z. (2004). Unit root quantile autoregression inference. Journal of the American Statistical Association, 99(467), 775-787.

See Also

qadf

Examples

set.seed(123)
y <- cumsum(rnorm(200))
result <- qadf(y)
result <- qadf_bootstrap(result, nboot = 99)
print(result)