Learn R Programming

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

EstimatorReferenceNotes
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

TestReferenceDescription
CDPesaran (2015)benchmark Pesaran CD
CDwJuodis & Reese (2022)Rademacher-weighted
CDw+Baltagi, Feng & Kao (2012)bias-adjusted LM with weighting
PEAFan, Liao & Yao (2015)power-enhanced for sparse alternatives
CD*Pesaran & Xie (2021)bias-corrected for strong factors

Other diagnostics

ToolReference
Pesaran CIPS panel unit root testPesaran (2007)
Swamy / Pesaran-Yamagata slope heterogeneity testSwamy (1970); Pesaran & Yamagata (2008)
Hausman-style MG vs Pooled test
Exponent of cross-sectional dependenceBailey, Kapetanios & Pesaran (2016, 2019)
IC for CSA selectionMargaritella & Westerlund (2023)
Rank condition classifierDe Vos, Everaert & Sarafidis (2024)
Cross-section / wild bootstrap inference

Extensions

ToolDescription
dcce_rolling()Rolling-window estimation with coefficient path tibble and plot method
absorb argumentHigh-dimensional fixed-effect absorption via alternating projections
spatial_weights argumentSpatial 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

  • broom-compatible tidy() and glance() (tidy includes short-run, adjustment, and long-run rows for LR estimators)
  • confint() with type = c("mg", "lr", "adjustment")
  • plot() for unit-level coefficient histograms and residual diagnostics
  • update() for refitting with modified arguments
  • coef(fit, type = "unit") for unit-level coefficient extraction
  • Native support for L(), D(), and Lrange() operators in formulas (xtdcce2-compatible syntax)
  • Unbalanced panel handling

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

  • R >= 4.1.0
  • Imports: stats, Matrix, collapse (>= 2.0.0), sandwich, generics, rlang (>= 1.1.0), cli (>= 3.0.0), tibble
  • Suggests: broom, ggplot2, lifecycle, plm, testthat (>= 3.0.0), knitr, rmarkdown

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:

  • L(x, k) — k-th lag of x within each unit
  • D(x, k) — k-th difference of x within each unit
  • Lrange(x, k0, k1) — lags k0 through k1 (used in CS-ARDL)

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

  • Bai, J. (2009). Panel data models with interactive fixed effects. Econometrica, 77(4), 1229–1279.
  • Bailey, N., Kapetanios, G., & Pesaran, M. H. (2016). Exponent of cross-sectional dependence: estimation and inference. Journal of Applied Econometrics, 31(6), 929–960.
  • Chudik, A., & 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.
  • Chudik, A., Mohaddes, K., Pesaran, M. H., & Raissi, M. (2016). Long-run effects in large heterogeneous panel data models with cross-sectionally correlated errors. In Essays in Honor of Aman Ullah, 36, 85–135.
  • De Vos, I., Everaert, G., & Sarafidis, V. (2024). A method to evaluate the rank condition for CCE estimators. Econometric Reviews, 43(2–4).
  • Ditzen, J. (2018). Estimating dynamic common-correlated effects in Stata. The Stata Journal, 18(3), 585–617.
  • Dumitrescu, E.-I., & Hurlin, C. (2012). Testing for Granger non-causality in heterogeneous panels. Economic Modelling, 29(4), 1450–1460.
  • Eberhardt, M., & Teal, F. (2010). Productivity analysis in global manufacturing production. Economics Series Working Papers 515, University of Oxford.
  • Fan, J., Liao, Y., & Yao, J. (2015). Power enhancement in high-dimensional cross-sectional tests. Econometrica, 83(4), 1497–1541.
  • Im, K. S., Pesaran, M. H., & Shin, Y. (2003). Testing for unit roots in heterogeneous panels. Journal of Econometrics, 115(1), 53–74.
  • Juodis, A., & Reese, S. (2022). The incidental parameters problem in testing for remaining cross-section correlation. Journal of Business & Economic Statistics, 40(3), 1191–1203.
  • Kao, C. (1999). Spurious regression and residual-based tests for cointegration in panel data. Journal of Econometrics, 90(1), 1–44.
  • Margaritella, L., & Westerlund, J. (2023). Using information criteria to select averages in CCE. The Econometrics Journal, 26(3), 405–421.
  • Pedroni, P. (2004). Panel cointegration: asymptotic and finite sample properties of pooled time series tests. Econometric Theory, 20(3), 597–625.
  • Pesaran, M. H. (2006). Estimation and inference in large heterogeneous panels with a multifactor error structure. Econometrica, 74(4), 967–1012.
  • Pesaran, M. H. (2007). A simple panel unit root test in the presence of cross-section dependence. Journal of Applied Econometrics, 22(2), 265–312.
  • Pesaran, M. H. (2015). Testing weak cross-sectional dependence in large panels. Econometric Reviews, 34(6–10), 1089–1117.
  • Pesaran, M. H., & Smith, R. (1995). Estimating long-run relationships from dynamic heterogeneous panels. Journal of Econometrics, 68(1), 79–113.
  • Shin, Y., Pesaran, M. H., & Smith, R. (1999). An autoregressive distributed-lag modelling approach to cointegration analysis. In Econometrics and Economic Theory in the 20th Century, 371–413.
  • Westerlund, J. (2007). Testing for error correction in panel data. Oxford Bulletin of Economics and Statistics, 69(6), 709–748.

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.

Copy Link

Version

Install

install.packages('dcce')

Version

0.4.2

License

GPL (>= 3)

Maintainer

Mustapha Wasseja

Last Published

May 5th, 2026

Functions in dcce (0.4.2)

dcce

Dynamic Common Correlated Effects Estimation
dcce_fit_methods

S3 Methods for dcce_fit Objects
dcce_rolling

Rolling-Window Panel Estimation
.absorb_demean_multi

Alternating projections for multi-factor demeaning
.check_balance

Check panel balance
.andrews_sup_wald_cv

Andrews (1993) sup-Wald critical values
.absorb_demean_one

Within transform: demean numeric columns by a single factor
.cd_weighted

CDw (Juodis & Reese 2022) weighted statistic
.cd_weighted_plus

Bias-adjusted weighted CD (CDw+) statistic
.andrews_sup_wald_pvalue

Approximate p-value from Andrews critical values
.csdl_postprocess

Post-process a CS-DL fit to label long-run coefficients
.csardl_postprocess

Post-process a CS-ARDL fit to attach LR / adjustment information
.absorb_resolve

Resolve absorb argument to a list of grouping vectors
.csardl_mg_lr

Aggregate unit-level long-run and adjustment results to the MG level
.cd_star

CD* (Pesaran & Xie 2021) bias-corrected statistic
.ife_select_factors

Select number of factors via BIC3 (Bai & Ng 2002)
.absorb_apply

Apply absorb projection to a panel
.dcce_cpp_available

Check whether the compiled C++ unit-OLS routines are available
.make_segments

Split a time vector into segments based on break dates
.ahn_horenstein_er

Ahn-Horenstein ER criterion
.bkp_variable

BKP (2016) variable method for alpha
.make_panel

Prepare a panel data frame
.bkp_residual

BKP (2019) residual method for alpha
.pmg_postprocess

Post-process a PMG fit
.jackknife_bias_correction

Half-panel jackknife bias correction
dcce_sim

Simulated Dynamic Panel Dataset
.ahn_horenstein_gr

Ahn-Horenstein GR criterion
dcce_workflow

Automatic Diagnostic Workflow for Panel Data with CSD
dcce_sim_truth

True Parameters for the Simulated Panel Dataset
glance.dcce_fit

Glance at a dcce_fit object
.pooled_vcov_pesaran

Pesaran (2006) non-parametric pooled variance
.validate_cd_tests

Validate CD test names
.panel_ur_core

Core IPS / LLC computation
.get_csa_colnames

Get CSA column names
.pairwise_correlations

Compute pairwise correlations of residuals
.unit_ols

Unit-level OLS
granger_test

Dumitrescu-Hurlin Panel Granger Causality Test
.half_panel_jackknife

Half-Panel Jackknife Bias Correction
.cd_pesaran

Pesaran (2015) CD statistic
.build_suggested_call

Internal: build a suggested dcce() call string
.cd_pea

PEA (Fan et al. 2015) power-enhanced statistic
.amg_common_dynamic_process

Compute the Common Dynamic Process from a pooled FD regression
.build_global_csa

Build cross-sectional averages from a wider sample
.amg_attach_cdp_level

Attach the cumulative CDP to a panel as a new column
.build_unit_X

Build the regressor matrix for a single unit
.build_spatial_csa

Build spatial (local) cross-sectional averages
.resolve_cr_vars

Resolve cross-sectional average variables
.pcd_test_core

Core computation for pcd_test
.delta_method

Delta Method
.check_csa_rank

Check rank of augmented CSA matrix
pcd_test

Cross-Sectional Dependence Tests
print.dcce_cointegration_extra

Print a dcce_cointegration_extra object
panel_utils

Panel Data Utilities
.cips_core

Core CIPS computation
print.dcce_csd

Print method for dcce_csd objects
.westerlund_pvalue

Approximate asymptotic p-value for a Westerlund statistic
.run_unit_loop

Run unit-level OLS over a list of (y, X) pairs
.westerlund_aggregate

Aggregate unit-level ECM statistics into Westerlund Ga/Gt/Pa/Pt
.estimate_half

Estimate MG on a subset of time periods
.register_marginaleffects_methods

Register marginaleffects S3 methods at package load
.print_coef_table

Internal: print a single coefficient table
.eval_formula_term

Evaluate a formula term
.pedroni_core

Pedroni group-mean statistics
.diff_panel

Panel-aware differencing
.mg_aggregate

Mean Group aggregation
.mg_variance

Mean Group variance
plot.dcce_rolling

Plot a dcce_rolling coefficient path
.build_csa

Build cross-sectional averages
.compute_irf

Compute IRF from AR coefficients and impulse coefficient
.csardl_unit_lr

Recover unit-level long-run coefficients and adjustment speed
.build_cluster_csa

Build cluster-level cross-sectional averages
.csdl_augment

Augment a CS-DL panel with first-difference lags of the regressors
.pmg_pool_lr

Pool unit-level long-run coefficients via inverse-variance weighting
.pinv

Moore-Penrose pseudoinverse
irf

Impulse Response Functions for Dynamic Panel Models
ife_estimator

Interactive Fixed Effects (IFE) Estimator
.fit_ife

Post-process a dcce_fit into an IFE fit
.parse_dcce_formula

Parse dcce formula
fitted.dcce_fit

Extract fitted values from a dcce_fit object
print.dcce_cips

Print a dcce_cips object
.structural_break_at

Fit pre/post regimes at a given break date and return a Wald statistic
.svd_csa

SVD of CSA matrix
hausman_test

Hausman-type Test: MG vs Pooled
panel_coint_test

Pedroni and Kao Panel Cointegration Tests
panel_ur_test

IPS and LLC Panel Unit Root Tests
.validate_westerlund_tests

Validate Westerlund test names
.extract_base_vars

Extract base variable names
.csardl_classify_terms

Classify ARDL regressor terms
.partial_out

Partial out CSAs from regressors
.var_to_matrix

Internal: convert a single variable column of a panel to a (N x T) matrix
.westerlund_unit_regressions

Run error-correction regressions per unit
print.dcce_fit

Print a dcce_fit object
print.dcce_cointegration

Print method for dcce_cointegration
print.dcce_rolling

Print a dcce_rolling object
.kao_core

Kao ADF statistic
ic

Information Criteria for CSA Selection
rcce_estimator

Regularized CCE Estimator Internals
residuals.dcce_fit

Extract residuals from a dcce_fit object
predict.dcce_fit

Predict from a dcce_fit object
pmg_estimator

Pooled Mean Group (PMG) Estimator Internals
print.dcce_boot

Print method for dcce_boot objects
print.dcce_break

Print a dcce_break object
print.dcce_cd

Print method for dcce_cd objects
print.dcce_granger

Print a dcce_granger object
rank_condition

Rank Condition Classifier
pwt8

Penn World Tables Growth Panel Dataset
vcov.dcce_fit

Extract variance-covariance matrix from a dcce_fit object
structural_break_test

Structural Break Tests for Panels with Cross-Sectional Dependence
spatial_cce_internals

Spatial Common Correlated Effects
.lag_panel

Panel-aware lag
.resid_vector_to_matrix

Convert stacked residual vector to matrix
marginaleffects_compat

marginaleffects Compatibility for dcce_fit Objects
print.dcce_swamy

Print a dcce_swamy object
summary.dcce_fit

Summary for a dcce_fit object
swamy_test

Swamy Slope Heterogeneity Test
.resid_list_to_matrix

Convert residual list to matrix
.seq_bai_perron

Sequential Bai-Perron: recursively search pre/post segments
.spatial_validate_W

Validate and normalise a spatial weight matrix
plot.dcce_fit

Plot method for dcce_fit objects
print.dcce_hausman

Print a dcce_hausman object
plot.dcce_irf

Plot a dcce_irf object
mg_estimator

Mean Group Estimator Internals
print.dcce_workflow

Print a dcce_workflow object
print.dcce_irf

Print a dcce_irf object
print.dcce_unit_root

Print a dcce_unit_root object
tidy.dcce_fit

Tidy a dcce_fit object
update.dcce_fit

Update a dcce_fit object
cips_test

Pesaran CIPS Panel Unit Root Test
coef.dcce_fit

Extract coefficients from a dcce_fit object
cointegration_test

Westerlund (2007) Panel Cointegration Tests
bootstrap

Bootstrap Inference for DCCE Models
absorb_internals

High-Dimensional Fixed Effect Absorption
L

Lag operator for dcce formulas
D

Difference operator for dcce formulas
Lrange

Lag range operator for dcce formulas
dcce_bootstrap

Bootstrap alias that avoids the broom conflict
confint.dcce_fit

Confidence intervals for a dcce_fit object
csd_exp

Exponent of Cross-Sectional Dependence
amg_estimator

Augmented Mean Group (AMG) Estimator Internals
csardl_estimator

CS-ARDL Estimator Internals
csdl_estimator

CS-DL Estimator Internals
cce_estimator

Static CCE Estimator Internals
csa_utils

Cross-Sectional Average (CSA) Utilities
dcce-package

dcce: Dynamic Common Correlated Effects Estimation for Panel Data
dcce_estimator

Dynamic CCE Estimator Internals