Formats, standardizes, and prints the Westerlund (2007) ECM-based panel cointegration test results for the null hypothesis of no cointegration. Given raw statistics \(G_t\), \(G_a\), \(P_t\), and \(P_a\), the function computes standardized Z-statistics using tabulated (or hard-coded) asymptotic moments and reports left-tail asymptotic p-values. If a bootstrap distribution is supplied, it also computes bootstrap (robust) p-values for the raw statistics.
DisplayWesterlund(
stats,
bootstats = NULL,
nobs,
nox,
constant = FALSE,
trend = FALSE,
meanlag = -1,
meanlead = -1,
realmeanlag = -1,
realmeanlead = -1,
auto = 0,
westerlund = FALSE,
aic = TRUE,
verbose = FALSE
)A list containing at minimum:
gt, ga, pt, pa: raw test statistics,
gt_z, ga_z, pt_z, pa_z: standardized Z-statistics,
gt_pval, ga_pval, pt_pval, pa_pval: left-tail asymptotic p-values.
If bootstats is provided, the list also includes:
gt_pvalboot, ga_pvalboot, pt_pvalboot, pa_pvalboot: bootstrap (robust) p-values for the raw statistics.
A numeric vector of length 4 or a 1x4 numeric matrix containing the raw test statistics in the order c(Gt, Ga, Pt, Pa).
Optional. A numeric matrix with bootstrap replications of the raw statistics, with 4 columns in the order [Gt, Ga, Pt, Pa]. If provided, robust (bootstrap) p-values are computed and displayed.
Integer. Number of valid cross-sectional units (series) used in the test.
Integer. Number of covariates in the long-run relationship (length of xvars in upstream calls). Used to select asymptotic moments for standardization in the non-westerlund case.
Logical. Indicates whether a constant was included in the cointegrating relationship. Affects the deterministic-case row used for asymptotic moment lookup.
Logical. Indicates whether a trend was included. If TRUE, constant is assumed to be TRUE and the deterministic-case row for moment lookup changes accordingly.
Integer. Mean selected lag length (rounded down to integer) reported in the header when auto is non-zero.
Integer. Mean selected lead length (rounded down to integer) reported in the header when auto is non-zero.
Numeric. Unrounded mean selected lag length (for display when auto is non-zero).
Numeric. Unrounded mean selected lead length (for display when auto is non-zero).
Logical/integer. If non-zero, the header prints the average AIC-selected lag and lead lengths based on realmeanlag and realmeanlead.
Logical. If TRUE, uses the hard-coded Westerlund-specific moment constants for standardization (separate constants for trend vs no-trend). If FALSE, uses lookup tables indexed by deterministic case and number of covariates.
Logical. If TRUE, AIC was used for lag/lead selection; If FALSE, BIC was used.
Logical. If TRUE, prints additional output.
This section explains how to use DisplayWesterlund() and how its output
connects to the broader testing workflow.
DisplayWesterlund() fit?Typically, the workflow is:
Compute observed raw statistics via WesterlundPlain.
Optionally compute a bootstrap distribution via WesterlundBootstrap.
Call DisplayWesterlund() to standardize, print, and return p-values.
The user-facing westerlund_test wraps these steps and collects the
returned scalars.
statsstats can be either a numeric vector c(Gt, Ga, Pt, Pa) or a 1x4 matrix with [1,] corresponding to Gt, Ga, Pt, Pa.
The function converts raw statistics to Z-statistics using hard-coded asymptotic
means and variances. P-values are computed as pnorm(Z), i.e., a left-tail test.
If bootstats is provided, robust p-values are computed by comparing the
observed raw statistic to its bootstrap distribution, using a finite-sample
correction:
\((r+1)/(B+1)\) where \(r\) is the number of bootstrap draws less than or
equal to the observed statistic.
## Example 1: Asymptotic-only display (no bootstrap)
stats <- c(Gt = -2.1, Ga = -9.5, Pt = -1.8, Pa = -6.2)res1 <- DisplayWesterlund( stats = stats, bootstats = NULL, nobs = 18, nox = 2, constant = TRUE, trend = FALSE, auto = 0, westerlund = FALSE )
## Example 2: With bootstrap distribution (robust p-values) set.seed(123) bootstats <- cbind( rnorm(399, mean = -1.8, sd = 0.9), rnorm(399, mean = -8.0, sd = 3.0), rnorm(399, mean = -1.5, sd = 1.0), rnorm(399, mean = -5.0, sd = 3.5) )
res2 <- DisplayWesterlund( stats = stats, bootstats = bootstats, nobs = 18, nox = 2, constant = TRUE, trend = FALSE, auto = 1, realmeanlag = 1.35, realmeanlead = 0.40, westerlund = FALSE )
What this function does.
DisplayWesterlund() takes raw Westerlund ECM test statistics and produces:
standardized Z-statistics for \(G_t\), \(G_a\), \(P_t\), \(P_a\),
left-tail asymptotic p-values using pnorm(),
optionally, bootstrap (robust) p-values when bootstats is provided,
a console table summarizing the results.
Standardization and deterministic cases. The function selects a deterministic-case index:
Row 1: no constant, no trend,
Row 2: constant, no trend,
Row 3: constant and trend,
implemented as row_idx = (as.integer(constant) + as.integer(trend)) + 1.
In the non-westerlund case, asymptotic means and variances are taken from
hard-coded lookup matrices indexed by row_idx and nox. Z-statistics are computed using:
$$
Z = \frac{\sqrt{N}S - \sqrt{N}\mu}{\sqrt{\sigma^2}}
$$
for mean-group statistics and analogous formulas for pooled statistics as
implemented in the code, where \(N =\) nobs and \(S\) is the raw statistic.
In the westerlund=TRUE case, the function uses a separate set of
hard-coded mean/variance constants, with different values depending on whether
trend is included.
Asymptotic p-values.
All asymptotic p-values are computed as left-tail probabilities:
pnorm(Z).
Bootstrap p-values (robust p-values).
If bootstats is supplied, bootstrap p-values are computed for each raw
statistic using a left-tail empirical rule:
$$
\hat{p} = \frac{r + 1}{B + 1}, \qquad r = \sum_{b=1}^{B} \mathbb{I}(S_b \le S_{\text{obs}}),
$$
after dropping non-finite bootstrap draws. This is a common finite-sample
correction used in Stata-style bootstrap code.
Return values. In addition to printing, the function returns a list containing the raw statistics, Z-statistics, asymptotic p-values, and (if applicable) bootstrap p-values.
Westerlund, J. (2007). Testing for error correction in panel data. Oxford Bulletin of Economics and Statistics, 69(6), 709--748.
westerlund_test,
WesterlundPlain,
WesterlundBootstrap