Skip to contents

PanelWithin: within transformation. PanelResiduals: pooled, within or unit-by-unit OLS residuals. PanelVarianceComponents: quadratic-form (Wallace-Hussain or Amemiya) error-component variances for a balanced panel. CrossSectionDependence: Pesaran CD, Breusch-Pagan LM, scaled and bias-corrected scaled LM tests and mean (absolute) residual correlations. UnobservedEffectsTest: Wooldridge's test for unobserved effects. BaltagiLiTest: Baltagi-Li LM test for AR(1)/MA(1) errors in the random-effects model (maximum likelihood by the Breusch iteration). PanelSerialTest: Breusch-Godfrey/Wooldridge test on within residuals. ConleyVcov: Conley spatial HAC covariance of OLS coefficients (uniform or Bartlett kernel on haversine distances, or the fixest approximations). Rows must be sorted by unit and time. Identical to the Python arm morie.fn.paneldiag.

Usage

PanelWithin(x, unit)

PanelResiduals(y, X, unit, model = "pooling")

PanelVarianceComponents(resid, unit, df_correction = 0)

CrossSectionDependence(resid, unit, time, test = "cd", w = NULL)

UnobservedEffectsTest(resid, unit)

BaltagiLiTest(y, X, unit, alternative = "twosided")

PanelSerialTest(y, X, unit, order = NULL, type = "Chisq")

ConleyVcov(
  X,
  resid,
  lat,
  lon,
  cutoff,
  kernel = "uniform",
  distance = "haversine",
  intercept = TRUE,
  adjust = TRUE
)

Arguments

x

Vector or matrix to demean.

unit

Unit identifiers.

y

Response vector.

X

Regressor matrix (without intercept).

model

"pooling", "within" or "heterogeneous".

resid

Residual vector.

df_correction

Degrees of freedom subtracted from N(T-1).

time

Period identifiers.

test

"cd", "lm", "sclm", "bcsclm", "rho" or "absrho".

w

Optional proximity matrix restricting the unit pairs.

alternative

"twosided" or "onesided".

order

Serial-correlation order (default: shortest unit length).

type

"Chisq" or "F".

lat, lon

Coordinates in decimal degrees.

cutoff

Distance cutoff in km.

kernel

"uniform" or "bartlett".

distance

"haversine", "fixest_triangular" or "fixest_spherical".

intercept

Add an intercept column to X.

adjust

Multiply by n / (n - k).

Value

A vector, matrix or list of statistics.

References

Pesaran, M. H. (2004). General diagnostic tests for cross section dependence in panels. CESifo Working Paper 1229.

Baltagi, B. H. and Li, Q. (1995). Testing AR(1) against MA(1) disturbances in an error component model. Journal of Econometrics 68, 133-151.

Wooldridge, J. M. (2010). Econometric Analysis of Cross Section and Panel Data, 2nd edn. MIT Press.

Conley, T. G. (1999). GMM estimation with cross sectional dependence. Journal of Econometrics 92, 1-45.

Examples

PanelWithin(c(1, 3, 2, 6), c("a", "a", "b", "b"))
#> [1] -1  1 -2  2
e <- c(1, -1, 2, 1, -1, 3, -2, 1, 0)
CrossSectionDependence(e, rep(1:3, each = 3), rep(1:3, 3))$statistic
#> [1] 0.1546537