MyNixOS website logo
Description

Panel Cointegration Tests Based on Westerlund (2007).

Implements a functional approximation of the four panel cointegration tests developed by Westerlund (2007) <doi:10.1111/j.1468-0084.2007.00477.x>. The tests are based on structural rather than residual dynamics and allow for heterogeneity in both the long-run cointegrating relationship and the short-run dynamics. The package includes logic for automated lag and lead selection via AIC/BIC, Bartlett kernel long-run variance estimation, and a bootstrap procedure to handle cross-sectional dependence. It also includes a bootstrapping distribution visualization function for diagnostic purposes.

Westerlund: Panel Cointegration Testing in R

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

Key Features

The package replicates the logic of the Westerlund (2007) methodology, including:

  • Four Test Statistics: Computes $G_t$, $G_a$, $P_t$, and $P_a$.
  • Flexible Dynamics: Allows for unit-specific lag and lead lengths.
  • Automated Selection: Built-in AIC/BIC selection logic for optimal lag and lead lengths.
  • Bootstrap Procedure: Robust p-values to handle cross-sectional dependence.
  • Kernel Estimation: Bartlett kernel long-run variance estimation.
  • Gap Handling: Strict time-series continuity checks to ensure valid econometric results.

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)

## Qucik Start

library(Westerlund)

Ensure data is sorted by ID and Time

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 )

View the results table

print(results)


## 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.
Metadata

Version

0.1.2

License

Unknown

Platforms (78)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    uefi
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-uefi
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-linux
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-uefi
  • x86_64-windows