Learn R Programming

dcce (version 0.4.2)

pcd_test: Cross-Sectional Dependence Tests

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).

Usage

pcd_test(x, ...)

# S3 method for dcce_fit pcd_test( x, ..., test = c("pesaran", "cdw", "cdwplus", "pea", "cdstar"), n_reps = 500L, n_pca = 1L )

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

# S3 method for matrix pcd_test( x, ..., test = c("pesaran", "cdw", "pea", "cdstar"), n_reps = 500L, n_pca = 1L )

# S3 method for default pcd_test( x, ..., data = NULL, unit_index = NULL, time_index = NULL, test = c("pesaran", "cdw", "cdwplus", "pea", "cdstar"), n_reps = 500L, n_pca = 1L )

Value

An object of class dcce_cd containing:

statistics

A data.frame with columns test, statistic, p_value.

N

Number of cross-sectional units.

T_bar

Average time dimension.

rho_ij

Matrix of pairwise correlations (if retained).

Arguments

x

Either a numeric vector of residuals (stacked by unit), a dcce_fit object, a numeric matrix (N x T) of residuals, or a data.frame containing the panel structure.

...

Arguments passed to methods.

test

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

n_reps

Integer: number of Rademacher draws for CDw. Default 500.

n_pca

Integer: number of principal components for CD* bias correction. Default 1.

unit_index

Character: name of the unit variable in data.

time_index

Character: name of the time variable in data.

data

A data.frame containing the panel structure. Required if x is a vector.

Examples

Run this code
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)

Run the code above in your browser using DataLab