% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pcd_test.R
\name{pcd_test}
\alias{pcd_test}
\alias{pcd_test.dcce_fit}
\alias{pcd_test.data.frame}
\alias{pcd_test.matrix}
\alias{pcd_test.default}
\title{Cross-Sectional Dependence Tests}
\usage{
pcd_test(x, ...)

\method{pcd_test}{dcce_fit}(
  x,
  ...,
  test = c("pesaran", "cdw", "cdwplus", "pea", "cdstar"),
  n_reps = 500L,
  n_pca = 1L
)

\method{pcd_test}{data.frame}(
  x,
  ...,
  unit_index = NULL,
  time_index = NULL,
  test = c("pesaran", "cdw", "pea", "cdstar"),
  n_reps = 500L,
  n_pca = 1L
)

\method{pcd_test}{matrix}(
  x,
  ...,
  test = c("pesaran", "cdw", "pea", "cdstar"),
  n_reps = 500L,
  n_pca = 1L
)

\method{pcd_test}{default}(
  x,
  ...,
  data = NULL,
  unit_index = NULL,
  time_index = NULL,
  test = c("pesaran", "cdw", "cdwplus", "pea", "cdstar"),
  n_reps = 500L,
  n_pca = 1L
)
}
\arguments{
\item{x}{Either a numeric vector of residuals (stacked by unit),
a \code{dcce_fit} object, a numeric matrix (N x T) of residuals,
or a data.frame containing the panel structure.}

\item{...}{Arguments passed to methods.}

\item{test}{Character vector specifying which tests to compute.
One or more of \code{"pesaran"}, \code{"cdw"}, \code{"cdwplus"}, \code{"pea"}, \code{"cdstar"}.
Default uses all five. See Pesaran (2015), Juodis & Reese (2022),
Baltagi, Feng & Kao (2012), Fan et al. (2015), Pesaran & Xie (2021).}

\item{n_reps}{Integer: number of Rademacher draws for CDw. Default 500.}

\item{n_pca}{Integer: number of principal components for CD* bias
correction. Default 1.}

\item{unit_index}{Character: name of the unit variable in \code{data}.}

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

\item{data}{A data.frame containing the panel structure. Required if
\code{x} is a vector.}
}
\value{
An object of class \code{dcce_cd} containing:
\describe{
\item{statistics}{A data.frame with columns \code{test}, \code{statistic}, \code{p_value}.}
\item{N}{Number of cross-sectional units.}
\item{T_bar}{Average time dimension.}
\item{rho_ij}{Matrix of pairwise correlations (if retained).}
}
}
\description{
Computes cross-sectional dependence test statistics for panel data residuals.
Implements the Pesaran (2015) CD test, CDw (Juodis & Reese 2022),
PEA (Fan et al. 2015), and CD* (Pesaran & Xie 2021).
}
\examples{
set.seed(42)
df <- data.frame(
  id = rep(1:10, each = 20),
  t  = rep(1:20, 10),
  e  = rnorm(200)
)
cd <- pcd_test(df$e, data = df, unit_index = "id", time_index = "t",
               test = "pesaran")
print(cd)
}
