The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Westerlund: Panel Cointegration Testing in R

Westerlund is an R package implementing the four error-correction-based panel cointegration tests developed by Westerlund (2007). The test evaluates the null hypothesis of no cointegration by testing whether the error-correction term in a conditional panel ECM is equal to zero. Rejection of the null provides evidence of a long-run equilibrium relationship between the variables.

The implementation is designed to reproduce the logic of the Stata xtwest command while providing an R-native interface, reusable result objects, plotting, and summary methods.

Key Features

The package provides:

Installation

You can install the development version of Westerlund from GitHub using the devtools package:

# Install devtools if you haven't already
# install.packages("devtools")

# Install Westerlund
devtools::install_github("bosco-hung/Westerlund/R", build_vignettes = TRUE)

Quick Start

library(Westerlund)

results <- westerlund_test(
  data = my_data,
  yvar = "ln_gdp",
  xvars = c("ln_energy", "ln_capital"),
  idvar = "country",
  timevar = "year",
  constant = TRUE,
  trend = FALSE,
  lags = c(1, 3),      # AIC search between 1 and 3 lags
  leads = c(0, 2),     # AIC search between 0 and 2 leads
  bootstrap = 100,     # Run 100 bootstrap replications
  lrwindow = 3,        # Bartlett kernel window size
  seed = 123           # Reproducible bootstrap
)

# Main results
print(results)

# Extended summary
summary(results)

# Bootstrap distributions and critical values
plot(
  results,
  conf_level = 0.05,
  show_robust_p = TRUE
)

If no lag specification is supplied, lags = 1 is used. If leads = NULL, the lead order defaults to zero.

For individual-unit ECM output, set:

results <- westerlund_test(
  data = my_data,
  yvar = "ln_gdp",
  xvars = "ln_energy",
  idvar = "country",
  timevar = "year",
  constant = TRUE,
  indiv.ecm = TRUE
)

results$unit_data
results$indiv_reg

References

Westerlund, J. (2007). Testing for Error Correction in Panel Data. Oxford Bulletin of Economics and Statistics, 69(6), 709-748.

Persyn, D., & Westerlund, J. (2008). Error-Correction-Based Cointegration Tests for Panel Data. Stata Journal, 8(2), 232-241.

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.