| DisplayWesterlund | R Documentation |
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
)
stats |
A numeric vector of length 4 or a |
bootstats |
Optional. A numeric matrix with bootstrap replications of the raw statistics, with 4 columns in the order |
nobs |
Integer. Number of valid cross-sectional units (series) used in the test. |
nox |
Integer. Number of covariates in the long-run relationship (length of |
constant |
Logical. Indicates whether a constant was included in the cointegrating relationship. Affects the deterministic-case row used for asymptotic moment lookup. |
trend |
Logical. Indicates whether a trend was included. If |
meanlag |
Integer. Mean selected lag length (rounded down to integer) reported in the header when |
meanlead |
Integer. Mean selected lead length (rounded down to integer) reported in the header when |
realmeanlag |
Numeric. Unrounded mean selected lag length (for display when |
realmeanlead |
Numeric. Unrounded mean selected lead length (for display when |
auto |
Logical/integer. If non-zero, the header prints the average AIC-selected lag and lead lengths based on |
westerlund |
Logical. If |
aic |
Logical. If |
verbose |
Logical. If |
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.
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.
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 )
Westerlund, J. (2007). Testing for error correction in panel data. Oxford Bulletin of Economics and Statistics, 69(6), 709–748.
westerlund_test,
WesterlundPlain,
WesterlundBootstrap
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.