| Title: | Bootstrap Slope Heterogeneity Test for Panel Data |
|---|---|
| Description: | Implements the bootstrap slope heterogeneity test for panel data of Blomquist and Westerlund (2016) <doi:10.1007/s00181-015-0978-z>. Tests the null hypothesis that slope coefficients are homogeneous across cross-sectional units using a block bootstrap of the Swamy-type statistic, with the unit-specific variance estimator of the paper or that of Pesaran and Yamagata (2008) <doi:10.1016/j.jeconom.2007.05.010>, whose Delta and adjusted Delta statistics are reported with asymptotic p-values. Supports partialling out of control variables and cross-sectional averages. |
| Authors: | Muhammad Alkhalaf [aut, cre, cph] (ORCID: <https://orcid.org/0009-0002-2677-9246>), Tore Bersvendsen [ctb] |
| Maintainer: | Muhammad Alkhalaf <[email protected]> |
| License: | GPL-3 |
| Version: | 1.1.0 |
| Built: | 2026-11-01 08:30:27 UTC |
| Source: | https://github.com/muhammedalkhalaf/xtbhst |
Produces diagnostic plots for the bootstrap slope heterogeneity test.
## S3 method for class 'xtbhst' plot(x, which = c(1L, 2L), ask = NULL, ...)## S3 method for class 'xtbhst' plot(x, which = c(1L, 2L), ask = NULL, ...)
x |
An object of class |
which |
Integer vector specifying which plots to produce:
1 = Bootstrap distribution of the statistic S,
2 = Bootstrap distribution of S on the Delta scale (the fixed
rescaling |
ask |
Logical. If |
... |
Additional arguments passed to plotting functions. |
Invisibly returns NULL.
Print method for xtbhst objects
## S3 method for class 'xtbhst' print(x, digits = 4L, ...)## S3 method for class 'xtbhst' print(x, digits = 4L, ...)
x |
An object of class |
digits |
Number of digits to display (default: 4). |
... |
Additional arguments (ignored). |
Invisibly returns the input object.
Summary method for xtbhst objects
## S3 method for class 'xtbhst' summary(object, digits = 4L, ...)## S3 method for class 'xtbhst' summary(object, digits = 4L, ...)
object |
An object of class |
digits |
Number of digits to display (default: 4). |
... |
Additional arguments (ignored). |
Invisibly returns a list with summary statistics.
Implements the panel bootstrap test of slope homogeneity of Blomquist and Westerlund (2016). The null hypothesis is that the slope coefficients are equal across all cross-sectional units.
xtbhst( formula, data, id, time, reps = 999L, blocklength = NULL, variance = c("bw", "py"), partial = NULL, csa = NULL, csa_lags = 0L, constant = TRUE, seed = NULL )xtbhst( formula, data, id, time, reps = 999L, blocklength = NULL, variance = c("bw", "py"), partial = NULL, csa = NULL, csa_lags = 0L, constant = TRUE, seed = NULL )
formula |
A formula of the form |
data |
A data frame containing the panel data. |
id |
A character string specifying the name of the cross-sectional identifier variable. |
time |
A character string specifying the name of the time variable. |
reps |
Integer. Number of bootstrap replications (default: 999). |
blocklength |
Integer. Block length for the block bootstrap. If
|
variance |
Character. Which unit-specific error variance estimate
to use in the weights of the weighted fixed-effects estimator and in
the test statistic. |
partial |
Optional formula specifying variables to be partialled out
unit by unit. For example, |
csa |
Optional formula specifying variables for which cross-sectional averages should be computed and partialled out, in the spirit of Pesaran (2006). See Details. |
csa_lags |
Integer. Number of lags of the cross-sectional averages to include (default: 0). |
constant |
Logical. If |
seed |
Optional integer seed for reproducibility. |
Let be the least-squares estimate of the slopes of
unit after partialling out the constant (and any further
variables given in partial and csa), let denote
the corresponding projection matrix, and let
be the weighted fixed-effects estimator. The test statistic of Blomquist and Westerlund (2016, Section 3.1) is
Two estimators of are available:
variance = "bw", where are
the residuals of the unit-specific least-squares regression. This
is the estimator used by Blomquist and Westerlund (2016).
variance = "py", where
is the pooled fixed-effects estimator. This is
the estimator used by Pesaran and Yamagata (2008). When further
variables are partialled out, the degrees of freedom are
, which reduces to in the
standard case.
The same choice is used for the weights of , in
and in every bootstrap statistic .
The bootstrap follows Algorithm BOOT of Blomquist and Westerlund
(2016): the unit-specific least-squares residuals are resampled in
blocks of length blocklength along the time dimension (keeping
the cross-section intact), pseudo-data are generated under the null
hypothesis with slopes , and is
computed exactly as . The reported bootstrap p-value is the
proportion of that are at least as large as .
For reference, the standardized statistics of Pesaran and Yamagata (2008) are also reported with their asymptotic standard normal p-values:
These are always computed from evaluated with the Pesaran and
Yamagata (2008) variance estimator (returned as
S_py), whatever the value of variance, so that they are
the statistics of that paper with their asymptotic null distribution;
variance governs only and the bootstrap. Because
and are fixed rescalings of
S_py, a bootstrap p-value for them would coincide with the
bootstrap p-value of when variance = "py"; only the
asymptotic p-values are therefore reported for them. is NA when
.
Rows of data with missing values in any of the variables used
(the model, partial, csa, id and time) are
dropped before the panel structure is checked. The remaining panel must
be strongly balanced: every unit must be observed in exactly the same
set of time periods, and every (id, time) pair must occur once.
Partialling out cross-sectional averages (csa, csa_lags)
is an extension not covered by Blomquist and Westerlund (2016). With
csa_lags > 0 the first csa_lags periods are dropped for
all units, so that the estimation sample is a common sample of
T - csa_lags periods. If the dependent variable appears
in csa, its cross-sectional averages are recomputed from the
bootstrap pseudo-data in each replication (observed values are used
for lagged averages that fall before the estimation sample). The
dependent variable must then be a plain column of data.
An object of class "xtbhst" containing:
The Swamy-type statistic that is bootstrapped,
computed with the variance estimator selected by variance.
The same statistic computed with the variance estimator
of Pesaran and Yamagata (2008); it underlies delta and
delta_adj. Equal to S when variance = "py".
Bootstrap p-value: the proportion of bootstrap statistics
that are at least as large as .
The Delta statistic of Pesaran and Yamagata (2008),
computed from S_py whatever the value of variance.
The adjusted Delta statistic of Pesaran and
Yamagata (2008), or NA if .
Asymptotic (standard normal, upper tail)
p-value of delta.
Asymptotic (standard normal, upper tail)
p-value of delta_adj.
Vector of bootstrap statistics .
S_stars on the Delta scale, that is
sqrt(N) (S_stars/N - K)/sqrt(2K).
The block length used in the bootstrap.
Number of bootstrap replications.
The variance estimator used ("bw" or
"py").
Number of cross-sectional units.
Number of time periods in the estimation sample (after
dropping the first csa_lags periods).
Number of regressors.
Number of partialled-out variables (including the constant).
Vector of unit-specific error variance estimates.
Matrix of individual slope estimates (N x K).
Vector of weighted fixed-effects (pooled) estimates.
Number of rows of data dropped because of
missing values.
The matched call.
Blomquist, J. and Westerlund, J. (2016). Panel bootstrap tests of slope homogeneity. Empirical Economics, 50(4), 1359-1381. doi:10.1007/s00181-015-0978-z
Pesaran, M. H. and Yamagata, T. (2008). Testing slope homogeneity in large panels. Journal of Econometrics, 142(1), 50-93. doi:10.1016/j.jeconom.2007.05.010
Pesaran, M. H. (2006). Estimation and inference in large heterogeneous panels with a multifactor error structure. Econometrica, 74(4), 967-1012. doi:10.1111/j.1468-0262.2006.00692.x
# Generate example panel data set.seed(123) N <- 20 # cross-sectional units T_periods <- 30 # time periods # Homogeneous slopes (H0 is true) data_hom <- data.frame( id = rep(1:N, each = T_periods), time = rep(1:T_periods, N), x = rnorm(N * T_periods) ) data_hom$y <- 1 + 0.5 * data_hom$x + rnorm(N * T_periods) # Test for slope heterogeneity result <- xtbhst(y ~ x, data = data_hom, id = "id", time = "time", reps = 199, seed = 42) print(result) summary(result) # Pesaran and Yamagata (2008) variance estimator result_py <- xtbhst(y ~ x, data = data_hom, id = "id", time = "time", reps = 199, seed = 42, variance = "py")# Generate example panel data set.seed(123) N <- 20 # cross-sectional units T_periods <- 30 # time periods # Homogeneous slopes (H0 is true) data_hom <- data.frame( id = rep(1:N, each = T_periods), time = rep(1:T_periods, N), x = rnorm(N * T_periods) ) data_hom$y <- 1 + 0.5 * data_hom$x + rnorm(N * T_periods) # Test for slope heterogeneity result <- xtbhst(y ~ x, data = data_hom, id = "id", time = "time", reps = 199, seed = 42) print(result) summary(result) # Pesaran and Yamagata (2008) variance estimator result_py <- xtbhst(y ~ x, data = data_hom, id = "id", time = "time", reps = 199, seed = 42, variance = "py")