Learn R Programming

dcce (version 0.4.2)

dcce: Dynamic Common Correlated Effects Estimation

Description

Estimates heterogeneous coefficient panel data models with cross-sectional dependence using Mean Group (MG), Common Correlated Effects (CCE), Dynamic CCE (DCCE), and related estimators.

Usage

dcce(
  data,
  unit_index,
  time_index,
  formula,
  model = c("dcce", "cce", "ccep", "mg", "amg", "rcce", "ife", "pmg", "csdl", "csardl"),
  cross_section_vars = ~.,
  cross_section_lags = 0L,
  pooled_vars = NULL,
  include_constant = TRUE,
  unit_trend = FALSE,
  bias_correction = c("none", "jackknife", "recursive", "half_panel_jackknife"),
  long_run_vars = NULL,
  long_run_model = NULL,
  csdl_xlags = 3L,
  absorb = NULL,
  spatial_weights = NULL,
  fast = TRUE,
  n_cores = 1L,
  run_cd_test = FALSE,
  full_sample = FALSE,
  verbose = FALSE,
  ...
)

Value

An object of class dcce_fit (and a model-specific subclass).

Arguments

data

A data.frame containing the panel data.

unit_index

Character: name of the unit (cross-section) variable.

time_index

Character: name of the time variable.

formula

A formula of the form y ~ x1 + x2. Supports L(), D(), and Lrange() operators for lags, differences, and lag ranges.

model

Character: estimator to use. One of "dcce", "cce", "ccep", "mg", "amg", "rcce", "ife", "pmg", "csdl", "csardl". Default "dcce". "ccep" is the Pooled CCE of Pesaran (2006) which constrains slopes to be identical across units. "ife" is the iterative PC estimator of Bai (2009).

cross_section_vars

A one-sided formula specifying variables for cross-sectional averages, e.g. ~ x1 + x2. Use ~ . for all RHS variables plus the dependent variable. Use NULL for no CSAs (plain MG).

cross_section_lags

Integer or named integer vector: number of lags of CSAs. Default 0. A single integer applies to all CSA variables.

pooled_vars

A one-sided formula specifying which coefficients to constrain equal across units (pooled estimation). Default NULL (all heterogeneous).

include_constant

Logical: include unit-specific intercepts? Default TRUE.

unit_trend

Logical: include unit-specific linear trends? Default FALSE.

bias_correction

Character: bias correction method. One of "none", "jackknife", "recursive", "half_panel_jackknife". The "half_panel_jackknife" implements the Chudik & Pesaran (2015) time-series half-panel jackknife that corrects the Nickell bias in dynamic CCE. Default "none".

long_run_vars

A one-sided formula specifying long-run variables (reserved for CSDL/CSARDL models). Default NULL.

long_run_model

Character: long-run model specification (reserved). Default NULL.

csdl_xlags

Integer: number of lags of \(\Delta x\) to include as short-run controls when model = "csdl". Default 3.

absorb

Either NULL (default), a character vector of column names, or a one-sided formula like ~ industry + region specifying high-dimensional fixed effects to project out of \(y\) and \(X\) before the main unit loop runs. A single factor uses the within transformation; multiple factors use the alternating projections of Guimaraes & Portugal (2010) / Correia (2016). The unit fixed effects used by CCE estimators are still kept via unit intercepts; absorb is for additional categorical effects on top of the cross-section.

spatial_weights

Optional \(N \times N\) numeric matrix of spatial weights. When supplied, the global cross-sectional averages of classical CCE are replaced with local, unit-specific weighted averages \(\bar y^W_{i,t} = \sum_j w_{ij} y_{j,t}\). The matrix must be square with rows and columns matching the unit identifiers (row/column names are used for alignment if present); it is row-normalised automatically and the diagonal is zeroed. This enables spatial CCE estimation that respects the topology of cross-sectional dependence (geographical contiguity, trade links, etc.).

fast

Logical: use the compiled C++ (RcppArmadillo) unit-OLS fast path? Default TRUE. Falls back to pure R automatically if the compiled routines are not available.

n_cores

Integer: number of cores for parallel unit estimation. Only effective on Unix/macOS via parallel::mclapply; on Windows the argument is silently ignored. Default 1L (sequential).

run_cd_test

Logical: run the Pesaran CD test on residuals? Default FALSE.

full_sample

Logical: use the full (unbalanced) sample? Default FALSE.

verbose

Logical: print progress messages? Default FALSE.

...

Additional arguments passed to model-specific estimators.

Examples

Run this code
# Simple Mean Group estimation
df <- data.frame(
  id = rep(1:10, each = 20),
  t  = rep(1:20, 10),
  y  = rnorm(200),
  x  = rnorm(200)
)
fit <- dcce(df, unit_index = "id", time_index = "t",
            formula = y ~ x, model = "mg", cross_section_vars = NULL)
coef(fit)

Run the code above in your browser using DataLab