Type: Package
Title: Cross-Sectionally Augmented Panel Quantile ARDL
Version: 1.0.2
Date: 2026-03-09
Description: Implements the Cross-Sectionally Augmented Panel Quantile Autoregressive Distributed Lag (CS-PQARDL) model and the Quantile Common Correlated Effects Mean Group (QCCEMG) estimator for panel data with cross-sectional dependence. The package handles unobserved common factors through cross-sectional averages following Pesaran (2006) <doi:10.1111/j.1468-0262.2006.00692.x> and Chudik and Pesaran (2015) <doi:10.1016/j.jeconom.2015.03.007>. Quantile regression for dynamic panels follows Harding, Lamarche, and Pesaran (2018) <doi:10.1016/j.jeconom.2018.07.010>. The ARDL approach to cointegration testing is based on Pesaran, Shin, and Smith (2001) <doi:10.1002/jae.616>.
License: GPL-3
Encoding: UTF-8
RoxygenNote: 7.3.3
Depends: R (≥ 4.0.0)
Imports: quantreg (≥ 5.97), stats
Suggests: testthat (≥ 3.0.0)
Config/testthat/edition: 3
URL: https://github.com/muhammedalkhalaf/xtcspqardl
BugReports: https://github.com/muhammedalkhalaf/xtcspqardl/issues
NeedsCompilation: no
Packaged: 2026-03-09 04:19:28 UTC; acad_
Author: Muhammad Alkhalaf ORCID iD [aut, cre, cph], Merwan Roudane [ctb] (Original Stata implementation)
Maintainer: Muhammad Alkhalaf <muhammedalkhalaf@gmail.com>
Repository: CRAN
Date/Publication: 2026-03-12 20:20:02 UTC

xtcspqardl: Cross-Sectionally Augmented Panel Quantile ARDL

Description

Implements the Cross-Sectionally Augmented Panel Quantile Autoregressive Distributed Lag (CS-PQARDL) model and the Quantile Common Correlated Effects Mean Group (QCCEMG) estimator for panel data with cross-sectional dependence.

Main Functions

Estimators

The package provides three main estimators:

QCCEMG (Quantile CCE Mean Group): Estimates unit-by-unit quantile regressions augmented with cross-sectional averages, then aggregates using the mean group estimator. This follows Harding, Lamarche, and Pesaran (2018).

QCCEPMG (Quantile CCE Pooled Mean Group): Similar to QCCEMG but pools the long-run coefficients across units while allowing heterogeneous short-run dynamics.

CS-PQARDL (CS Panel Quantile ARDL): Extends the ARDL approach to cointegration (Pesaran, Shin & Smith, 2001) to quantile regression with CCE augmentation for handling cross-sectional dependence.

Cross-Sectional Dependence

The package handles cross-sectional dependence through the Common Correlated Effects (CCE) approach of Pesaran (2006). Cross-sectional averages of all variables are computed and included as proxies for unobserved common factors.

Following Chudik and Pesaran (2015), lagged cross-sectional averages are included with default lag order floor(T^{1/3}).

References

Chudik, A. and Pesaran, M.H. (2015). Common Correlated Effects Estimation of Heterogeneous Dynamic Panel Data Models with Weakly Exogenous Regressors. Journal of Econometrics, 188(2), 393-420. doi:10.1016/j.jeconom.2015.03.007

Harding, M., Lamarche, C., and Pesaran, M.H. (2018). Common Correlated Effects Estimation of Heterogeneous Dynamic Panel Quantile Regression Models. Journal of Applied Econometrics, 35(3), 294-314. doi:10.1016/j.jeconom.2018.07.010

Pesaran, M.H. (2006). Estimation and Inference in Large Heterogeneous Panels with a Multifactor Error Structure. Econometrica, 74(4), 967-1012. doi:10.1111/j.1468-0262.2006.00692.x

Pesaran, M.H., Shin, Y., and Smith, R.J. (2001). Bounds Testing Approaches to the Analysis of Level Relationships. Journal of Applied Econometrics, 16(3), 289-326. doi:10.1002/jae.616

Author(s)

Maintainer: Muhammad Alkhalaf muhammedalkhalaf@gmail.com (ORCID) [copyright holder]

Other contributors:

See Also

Useful links:


Extract coefficients from xtcspqardl object

Description

Extract coefficients from xtcspqardl object

Usage

## S3 method for class 'xtcspqardl'
coef(object, tau = NULL, type = "short_run", ...)

Arguments

object

An object of class "xtcspqardl".

tau

Optional quantile(s) to extract. If NULL, returns all.

type

Character; "short_run" or "long_run".

...

Additional arguments (ignored).

Value

Named numeric vector or list of coefficients.


Compute Cross-Sectional Averages

Description

Computes cross-sectional averages (CSA) of all variables at each time period, following the CCE approach of Pesaran (2006).

Usage

compute_csa(data, id, time, depvar, indepvars, cr_lags = 0)

Arguments

data

Data frame with panel data.

id

Character string naming the cross-sectional identifier.

time

Character string naming the time variable.

depvar

Character string naming the dependent variable.

indepvars

Character vector of independent variable names.

cr_lags

Integer number of lags for CSA (Chudik & Pesaran, 2015).

Details

Cross-sectional averages are computed as:

\bar{z}_t = \frac{1}{N} \sum_{i=1}^{N} z_{it}

for each variable z in \{y, x_1, x_2, ...\}.

Following Chudik and Pesaran (2015), lagged CSA are included with default lag order floor(T^{1/3}).

Value

A list containing:

data

Data frame with CSA columns added.

csa_vars

Character vector of CSA variable names.

References

Chudik, A. and Pesaran, M.H. (2015). Common Correlated Effects Estimation of Heterogeneous Dynamic Panel Data Models with Weakly Exogenous Regressors. Journal of Econometrics, 188(2), 393-420. doi:10.1016/j.jeconom.2015.03.007

Pesaran, M.H. (2006). Estimation and Inference in Large Heterogeneous Panels with a Multifactor Error Structure. Econometrica, 74(4), 967-1012. doi:10.1111/j.1468-0262.2006.00692.x


CS-PQARDL Estimation

Description

Estimates Cross-Sectionally Augmented Panel Quantile ARDL model.

Usage

estimate_cspqardl(
  data,
  id,
  time,
  depvar,
  sr_vars,
  lr_vars,
  csa_vars,
  tau,
  p,
  q,
  constant,
  model
)

Arguments

data

Data frame with CSA-augmented panel data.

id

Panel identifier variable name.

time

Time variable name.

depvar

Dependent variable name.

sr_vars

Short-run variable names.

lr_vars

Long-run variable names.

csa_vars

CSA variable names.

tau

Numeric vector of quantiles.

p

Lag order for dependent variable.

q

Lag order(s) for regressors.

constant

Include constant.

model

PMG, MG, or DFE.

Value

List with estimation results.

References

Pesaran, M.H., Shin, Y., and Smith, R.J. (2001). Bounds Testing Approaches to the Analysis of Level Relationships. Journal of Applied Econometrics, 16(3), 289-326. doi:10.1002/jae.616


QCCEMG Estimation

Description

Estimates Quantile CCE Mean Group (QCCEMG) or Pooled Mean Group (QCCEPMG) following Harding, Lamarche, and Pesaran (2018).

Usage

estimate_qccemg(
  data,
  id,
  time,
  depvar,
  indepvars,
  csa_vars,
  tau,
  constant = TRUE,
  pooled = FALSE
)

Arguments

data

Data frame with CSA-augmented panel data.

id

Panel identifier variable name.

time

Time variable name.

depvar

Dependent variable name.

indepvars

Character vector of independent variable names.

csa_vars

Character vector of CSA variable names.

tau

Numeric vector of quantiles.

constant

Logical; include constant term.

pooled

Logical; if TRUE, use QCCEPMG (pooled).

Value

List with estimation results.

References

Harding, M., Lamarche, C., and Pesaran, M.H. (2018). Common Correlated Effects Estimation of Heterogeneous Dynamic Panel Quantile Regression Models. Journal of Applied Econometrics, 35(3), 294-314. doi:10.1016/j.jeconom.2018.07.010


Fitted values from xtcspqardl model

Description

Fitted values from xtcspqardl model

Usage

## S3 method for class 'xtcspqardl'
fitted(object, ...)

Arguments

object

An object of class "xtcspqardl".

...

Additional arguments (ignored).

Value

This function is not yet implemented for xtcspqardl objects.


Compute first difference within panel

Description

Compute first difference within panel

Usage

panel_diff(x, id)

Arguments

x

Numeric vector.

id

Panel identifier vector.

Value

Numeric vector with first differences.


Compute lagged variable within panel

Description

Compute lagged variable within panel

Usage

panel_lag(x, id, lag = 1)

Arguments

x

Numeric vector.

id

Panel identifier vector.

lag

Number of lags.

Value

Numeric vector with lagged values.


Parse formula for xtcspqardl

Description

Parse formula for xtcspqardl

Usage

parse_formula(formula)

Arguments

formula

Formula object

Value

List with depvar, sr_vars, lr_vars


Print method for summary.xtcspqardl

Description

Print method for summary.xtcspqardl

Usage

## S3 method for class 'summary.xtcspqardl'
print(x, digits = 4, signif.stars = TRUE, ...)

Arguments

x

An object of class "summary.xtcspqardl".

digits

Number of significant digits.

signif.stars

Logical; print significance stars.

...

Additional arguments (ignored).

Value

Invisibly returns the input object.


Print method for xtcspqardl objects

Description

Print method for xtcspqardl objects

Usage

## S3 method for class 'xtcspqardl'
print(x, ...)

Arguments

x

An object of class "xtcspqardl".

...

Additional arguments (ignored).

Value

Invisibly returns the input object.


Description

Print coefficient table with significance stars

Usage

print_coef_table(tbl, digits = 4, signif.stars = TRUE)

Arguments

tbl

Data frame with coefficient table.

digits

Number of digits.

signif.stars

Show significance stars.


Residuals from xtcspqardl model

Description

Residuals from xtcspqardl model

Usage

## S3 method for class 'xtcspqardl'
residuals(object, ...)

Arguments

object

An object of class "xtcspqardl".

...

Additional arguments (ignored).

Value

This function is not yet implemented for xtcspqardl objects.


Summary method for xtcspqardl objects

Description

Summary method for xtcspqardl objects

Usage

## S3 method for class 'xtcspqardl'
summary(object, ...)

Arguments

object

An object of class "xtcspqardl".

...

Additional arguments (ignored).

Value

An object of class "summary.xtcspqardl".


Extract variance-covariance matrix from xtcspqardl object

Description

Extract variance-covariance matrix from xtcspqardl object

Usage

## S3 method for class 'xtcspqardl'
vcov(object, tau = NULL, ...)

Arguments

object

An object of class "xtcspqardl".

tau

Optional quantile to extract. If NULL, returns all.

...

Additional arguments (ignored).

Value

Variance-covariance matrix or list of matrices.


Cross-Sectionally Augmented Panel Quantile ARDL

Description

Estimates the Cross-Sectionally Augmented Panel Quantile ARDL (CS-PQARDL) model or the Quantile Common Correlated Effects Mean Group (QCCEMG/QCCEPMG) estimator for panel data with cross-sectional dependence.

Usage

xtcspqardl(
  formula,
  data,
  id,
  time,
  tau = 0.5,
  estimator = c("qccemg", "qccepmg", "cspqardl"),
  p = 1L,
  q = 1L,
  cr_lags = NULL,
  constant = TRUE,
  model = c("pmg", "mg", "dfe")
)

Arguments

formula

A formula of the form y ~ x1 + x2 | z1 + z2 where variables before | are short-run regressors and variables after | are long-run regressors (for CS-PQARDL). For QCCEMG, use

y ~ x1 + x2.

data

A data frame containing panel data.

id

Character string naming the cross-sectional unit identifier.

time

Character string naming the time variable.

tau

Numeric vector of quantiles to estimate (between 0 and 1).

estimator

Character string specifying the estimator: "qccemg" for Quantile CCE Mean Group (default), "qccepmg" for Quantile CCE Pooled Mean Group, "cspqardl" for CS Panel Quantile ARDL.

p

Integer specifying the number of lags for the dependent variable (default 1, for CS-PQARDL).

q

Integer or vector specifying the number of lags for each regressor (default 1, for CS-PQARDL).

cr_lags

Integer specifying the number of lags for cross-sectional averages. Default is floor(T^(1/3)) following Chudik and Pesaran (2015).

constant

Logical; if TRUE (default), include a constant term.

model

Character string for CS-PQARDL pooling: "pmg" for Pooled Mean Group (default), "mg" for Mean Group, "dfe" for Dynamic Fixed Effects.

Details

The package implements two main estimators for panel quantile regression with cross-sectional dependence:

QCCEMG (Quantile CCE Mean Group): Estimates unit-by-unit quantile regressions augmented with cross-sectional averages, then aggregates using mean group estimator. The model is:

y_{it} = \lambda_i y_{i,t-1} + \beta_i' x_{it} + \delta_i' \bar{z}_t + u_{it}

where \bar{z}_t contains cross-sectional averages of y and x.

CS-PQARDL (CS Panel Quantile ARDL): Extends the ARDL approach to cointegration (Pesaran, Shin & Smith, 2001) to quantile regression with CCE augmentation. Estimates error-correction form with long-run relationships.

Cross-sectional dependence is handled through the CCE approach (Pesaran, 2006), which augments regressions with cross-sectional averages of all variables. Lagged CSA follow Chudik & Pesaran (2015) with default floor(T^{1/3}) lags.

Value

An object of class "xtcspqardl" containing:

coefficients

Mean group coefficients across panels.

se

Standard errors using mean group variance.

vcov

Variance-covariance matrix.

individual

List of unit-specific estimates.

long_run

Long-run coefficient estimates.

speed_adj

Speed of adjustment coefficients.

half_life

Half-life of adjustment.

tau

Quantiles estimated.

call

The matched call.

formula

The formula used.

n_panels

Number of panels.

n_obs

Total observations.

avg_T

Average time periods per panel.

References

Chudik, A. and Pesaran, M.H. (2015). Common Correlated Effects Estimation of Heterogeneous Dynamic Panel Data Models with Weakly Exogenous Regressors. Journal of Econometrics, 188(2), 393-420. doi:10.1016/j.jeconom.2015.03.007

Harding, M., Lamarche, C., and Pesaran, M.H. (2018). Common Correlated Effects Estimation of Heterogeneous Dynamic Panel Quantile Regression Models. Journal of Applied Econometrics, 35(3), 294-314. doi:10.1016/j.jeconom.2018.07.010

Pesaran, M.H. (2006). Estimation and Inference in Large Heterogeneous Panels with a Multifactor Error Structure. Econometrica, 74(4), 967-1012. doi:10.1111/j.1468-0262.2006.00692.x

Pesaran, M.H., Shin, Y., and Smith, R.J. (2001). Bounds Testing Approaches to the Analysis of Level Relationships. Journal of Applied Econometrics, 16(3), 289-326. doi:10.1002/jae.616

Examples


# Generate example panel data
set.seed(123)
N <- 20  # panels
T <- 50  # time periods
data <- data.frame(
  id = rep(1:N, each = T),
  time = rep(1:T, N),
  x = rnorm(N * T),
  y = rnorm(N * T)
)
# Add dynamics
for (i in 1:N) {
  idx <- ((i-1)*T + 2):(i*T)
  data$y[idx] <- 0.5 * data$y[idx-1] + 0.3 * data$x[idx] + rnorm(T-1, sd=0.5)
}

# QCCEMG estimation
fit <- xtcspqardl(y ~ x, data = data, id = "id", time = "time",
                  tau = c(0.25, 0.50, 0.75), estimator = "qccemg")
summary(fit)