% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/dcce.R
\name{dcce}
\alias{dcce}
\title{Dynamic Common Correlated Effects Estimation}
\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,
  ...
)
}
\arguments{
\item{data}{A data.frame containing the panel data.}

\item{unit_index}{Character: name of the unit (cross-section) variable.}

\item{time_index}{Character: name of the time variable.}

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

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

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

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

\item{pooled_vars}{A one-sided formula specifying which coefficients to
constrain equal across units (pooled estimation). Default \code{NULL} (all
heterogeneous).}

\item{include_constant}{Logical: include unit-specific intercepts? Default
\code{TRUE}.}

\item{unit_trend}{Logical: include unit-specific linear trends? Default
\code{FALSE}.}

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

\item{long_run_vars}{A one-sided formula specifying long-run variables
(reserved for CSDL/CSARDL models). Default \code{NULL}.}

\item{long_run_model}{Character: long-run model specification (reserved).
Default \code{NULL}.}

\item{csdl_xlags}{Integer: number of lags of \eqn{\Delta x} to include as
short-run controls when \code{model = "csdl"}. Default 3.}

\item{absorb}{Either \code{NULL} (default), a character vector of column
names, or a one-sided formula like \code{~ industry + region} specifying
high-dimensional fixed effects to project out of \eqn{y} and
\eqn{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; \code{absorb} is for \emph{additional} categorical effects on top
of the cross-section.}

\item{spatial_weights}{Optional \eqn{N \times N} numeric matrix of
spatial weights. When supplied, the global cross-sectional averages
of classical CCE are replaced with \strong{local}, unit-specific
weighted averages \eqn{\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.).}

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

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

\item{run_cd_test}{Logical: run the Pesaran CD test on residuals? Default
\code{FALSE}.}

\item{full_sample}{Logical: use the full (unbalanced) sample? Default
\code{FALSE}.}

\item{verbose}{Logical: print progress messages? Default \code{FALSE}.}

\item{...}{Additional arguments passed to model-specific estimators.}
}
\value{
An object of class \code{dcce_fit} (and a model-specific subclass).
}
\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.
}
\examples{
# 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)
}
