dcce

Dynamic Common Correlated Effects Estimation for Panel Data

dcce is an R package implementing the family of Common Correlated Effects (CCE) estimators for heterogeneous coefficient panel data models with cross-sectional dependence. It is an R port of Jan Ditzen’s xtdcce2 Stata package and provides the standard estimators of Pesaran (2006), Chudik & Pesaran (2015), and related contributions, together with a comprehensive cross-sectional dependence (CD) test suite.


Features

Estimators

Estimator Reference Notes
Mean Group (MG) Pesaran & Smith (1995) heterogeneous slopes
Common Correlated Effects (CCE-MG) Pesaran (2006) static, with CSAs
Dynamic CCE (DCCE) Chudik & Pesaran (2015) dynamic panel + CSA lags
Regularized CCE (rCCE) Juodis (2022) PCA-regularized CSA factor
CS-DL (long-run) Chudik et al. (2016) direct LR via level of x
CS-ARDL (short + long run) Chudik et al. (2016) full SR / adjustment / LR blocks via delta method
Pooled Mean Group (PMG) Shin, Pesaran & Smith (1999) inverse-variance pooled LR

All three long-run estimators produce a three-block output: short-run coefficients, the adjustment (speed of return to equilibrium), and long-run elasticities with delta-method standard errors.

Cross-sectional dependence tests

Test Reference Description
CD Pesaran (2015) benchmark Pesaran CD
CDw Juodis & Reese (2022) Rademacher-weighted
CDw+ Baltagi, Feng & Kao (2012) bias-adjusted LM with weighting
PEA Fan, Liao & Yao (2015) power-enhanced for sparse alternatives
CD* Pesaran & Xie (2021) bias-corrected for strong factors

Other diagnostics

Tool Reference
Pesaran CIPS panel unit root test Pesaran (2007)
Swamy / Pesaran-Yamagata slope heterogeneity test Swamy (1970); Pesaran & Yamagata (2008)
Hausman-style MG vs Pooled test
Exponent of cross-sectional dependence Bailey, Kapetanios & Pesaran (2016, 2019)
IC for CSA selection Margaritella & Westerlund (2023)
Rank condition classifier De Vos, Everaert & Sarafidis (2024)
Cross-section / wild bootstrap inference

Extensions

Tool Description
dcce_rolling() Rolling-window estimation with coefficient path tibble and plot method
absorb argument High-dimensional fixed-effect absorption via alternating projections
spatial_weights argument Spatial CCE with user-supplied weight matrix
structural_break_test() Chow / sup-Wald tests, breakdate estimation, sequential Bai-Perron (R port of Stata xtbreak)

S3 methods and ergonomics


Installation

The package is in active development and not yet on CRAN. Install the development version from GitHub:

# install.packages("remotes")
remotes::install_github("Mustapha-Wasseja/dcce")

To build the vignette during installation:

remotes::install_github("Mustapha-Wasseja/dcce", build_vignettes = TRUE)

System requirements


Quick start

library(dcce)

# Load the bundled Penn World Tables 8 dataset (93 countries, 1960-2007)
data(pwt8)

# Fit a Dynamic CCE growth regression with 3 lags of CSAs
fit <- dcce(
  data               = pwt8,
  unit_index         = "country",
  time_index         = "year",
  formula            = d_log_rgdpo ~ L(log_rgdpo, 1) + log_hc + log_ck + log_ngd,
  model              = "dcce",
  cross_section_vars = ~ log_rgdpo + log_hc + log_ck + log_ngd,
  cross_section_lags = 3
)

print(fit)

# Verify that DCCE has removed cross-sectional dependence
pcd_test(fit, test = "pesaran")

# Tidy output (broom compatible)
tidy(fit)
glance(fit)

For a complete walkthrough including motivation, theory, all estimators, and the Ditzen (2018) replication, see the package vignette:

vignette("dcce-introduction", package = "dcce")

Verify your installation

The fastest way to confirm the package works on your system is to run a few of the worked examples on the bundled datasets:

library(dcce)

# Example 1: Mean Group on the simulated dataset
data(dcce_sim)
fit_mg <- dcce(
  data = dcce_sim, unit_index = "unit", time_index = "time",
  formula = y ~ L(y, 1) + x,
  model = "mg", cross_section_vars = NULL
)
coef(fit_mg)

# Example 2: DCCE with CD test on residuals
data(pwt8)
fit_dcce <- dcce(
  data = pwt8, unit_index = "country", time_index = "year",
  formula = d_log_rgdpo ~ L(log_rgdpo, 1) + log_hc + log_ck + log_ngd,
  model = "dcce",
  cross_section_vars = ~ log_rgdpo + log_hc + log_ck + log_ngd,
  cross_section_lags = 3
)
pcd_test(fit_dcce, test = "pesaran")  # Should be insignificant after DCCE

# Example 3: Bootstrap inference
set.seed(42)
boot <- bootstrap(fit_dcce, type = "crosssection", reps = 199)
print(boot)

Note: broom::bootstrap conflict

If you load broom in the same session, broom::bootstrap will mask dcce::bootstrap (they share a name but have completely different signatures). Two workarounds, pick either:

# Option A: use the namespace prefix
dcce::bootstrap(fit, type = "crosssection", reps = 199)

# Option B: use the conflict-free alias exported by dcce
dcce_bootstrap(fit, type = "crosssection", reps = 199)

dcce_bootstrap() is identical to dcce::bootstrap() and cannot be masked by any other package.

Optional: validate against plm

If you have plm installed, the package’s static CCE estimator matches plm::pmg(..., model = "cmg") to three decimal places on the Produc dataset. This is checked automatically by the bundled tests/testthat/test-produc-validation.R file.


Usage notes

Formula operators. The package extends standard R formulas with three panel-aware operators:

Cross-section variables. Use cross_section_vars = ~ . to include all regressors plus the dependent variable as CSAs (the default), or provide an explicit one-sided formula such as ~ log_rgdpo + log_hc.

CSA lags. For dynamic models the Chudik-Pesaran rule p_T = floor(T^(1/3)) is the standard recommendation (cross_section_lags = 3 for T ≈ 30-50).


References

License

GPL (>= 3)

Citation

If you use dcce in published work, please cite the package and the relevant methodological references above.

citation("dcce")

Issues

Bug reports and feature requests are welcome at https://github.com/Mustapha-Wasseja/dcce/issues.