Learn R Programming

paneltests (version 1.0.5)

xtpretest: Comprehensive Panel Data Pre-Testing Suite

Description

Performs a full battery of panel data pre-tests: Hsiao (2014) homogeneity F-tests, robust (HC1) versions, Swamy (1970) parameter heterogeneity test, cross-sectional dependence (Pesaran 2004), and panel summary statistics.

Usage

xtpretest(
  data,
  formula,
  index,
  tests = "ALL",
  level = 0.05
)

Value

A list (invisibly) with components:

summary

Panel summary statistics.

hsiao

Hsiao homogeneity F-test results.

robust

Robust HC1 F-test results.

swamy

Swamy heterogeneity test results.

csd

Cross-sectional dependence test results.

recommendation

Character. Suggested estimator.

Arguments

data

A data.frame in long format containing all variables.

formula

A two-sided formula of the form y ~ x1 + x2 + ... specifying the dependent and independent variables.

index

Character vector of length 2: c("panel_id", "time_id").

tests

Character vector. Which modules to run. Possible values: "summary", "hsiao", "robust", "heterogeneity", "csd". Default "ALL" runs everything.

level

Numeric. Significance level for decisions (default 0.05).

References

Hsiao, C. (2014). Analysis of Panel Data (3rd ed.). Cambridge University Press. tools:::Rd_expr_doi("10.1017/CBO9781139839327")

Swamy, P. A. V. B. (1970). Efficient inference in a random coefficient regression model. Econometrica, 38(2), 311-323. tools:::Rd_expr_doi("10.2307/1909405")

Pesaran, M. H. (2004). General diagnostic tests for cross section dependence in panels. Cambridge Working Paper in Economics, No. 0435. tools:::Rd_expr_doi("10.2139/ssrn.572504")

Examples

Run this code
set.seed(10)
n <- 5; t <- 10
df <- data.frame(
  id   = rep(1:n, each = t),
  time = rep(1:t, times = n),
  y    = rnorm(n * t),
  x1   = rnorm(n * t)
)
res <- xtpretest(df, y ~ x1, index = c("id", "time"),
                 tests = c("hsiao", "csd"))

Run the code above in your browser using DataLab