| Title: | Bootstrap Slope Heterogeneity Test for Panel Data |
| Version: | 1.0.1 |
| Description: | Implements the bootstrap slope heterogeneity test for panel data based on Blomquist and Westerlund (2015) <doi:10.1007/s00181-015-0978-z>. Tests the null hypothesis that slope coefficients are homogeneous across cross-sectional units. Provides both standard and adjusted Delta statistics with bootstrap p-values. Supports partialling out of control variables and cross-sectional averages for dealing with cross-sectional dependence. |
| License: | GPL-3 |
| URL: | https://github.com/muhammedalkhalaf/xtbhst |
| BugReports: | https://github.com/muhammedalkhalaf/xtbhst/issues |
| Encoding: | UTF-8 |
| RoxygenNote: | 7.3.3 |
| Depends: | R (≥ 3.5.0) |
| Imports: | stats, graphics, grDevices |
| Suggests: | testthat (≥ 3.0.0), plm |
| Config/testthat/edition: | 3 |
| NeedsCompilation: | no |
| Packaged: | 2026-03-09 17:14:06 UTC; acad_ |
| Author: | Muhammad Alkhalaf |
| Maintainer: | Muhammad Alkhalaf <muhammedalkhalaf@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-03-13 13:30:02 UTC |
xtbhst: Bootstrap Slope Heterogeneity Test for Panel Data
Description
Implements the bootstrap slope heterogeneity test for panel data based on Blomquist and Westerlund (2015). The test examines whether slope coefficients are homogeneous across cross-sectional units in a panel regression.
Main Function
xtbhstPerforms the bootstrap slope heterogeneity test.
Methods
print.xtbhstPrint test results.
summary.xtbhstDetailed summary of test results.
plot.xtbhstDiagnostic plots for the bootstrap test.
Test Details
The null hypothesis is that all cross-sectional units share the same slope coefficients (H0: homogeneous slopes). Rejection indicates significant slope heterogeneity, suggesting that pooled or fixed effects estimators may be inappropriate.
The test is based on the Delta statistic:
\Delta = \sqrt{N} \frac{\tilde{S}/N - K}{\sqrt{2K}}
where \tilde{S} measures the weighted sum of squared deviations
of individual slope estimates from the weighted pooled estimate.
The bootstrap procedure uses a block bootstrap to preserve serial correlation in the residuals.
Cross-Sectional Dependence
The package supports handling cross-sectional dependence through cross-sectional averages (CSA), following the approach of Pesaran (2006). Users can specify variables for which CSA should be computed and partialled out.
Author(s)
Maintainer:
Other contributors:
Tore Bersvendsen [contributor]
Jan Ditzen [contributor]
References
Blomquist, J., & Westerlund, J. (2015). Panel bootstrap tests of slope homogeneity. Empirical Economics, 48(1), 1191-1204. doi:10.1007/s00181-015-0978-z
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
Swamy, P. A. V. B. (1970). Efficient inference in a random coefficient regression model. Econometrica, 38(2), 311-323. doi:10.2307/1913012
See Also
Useful links:
Report bugs at https://github.com/muhammedalkhalaf/xtbhst/issues
Plot method for xtbhst objects
Description
Produces diagnostic plots for the bootstrap slope heterogeneity test.
Usage
## S3 method for class 'xtbhst'
plot(x, which = c(1L, 2L), ask = NULL, ...)
Arguments
x |
An object of class |
which |
Integer vector specifying which plots to produce:
1 = Bootstrap distribution of Delta,
2 = Bootstrap distribution of adjusted Delta,
3+ = Individual coefficient distributions.
Default is |
ask |
Logical. If |
... |
Additional arguments passed to plotting functions. |
Value
Invisibly returns NULL.
Print method for xtbhst objects
Description
Print method for xtbhst objects
Usage
## S3 method for class 'xtbhst'
print(x, digits = 4L, ...)
Arguments
x |
An object of class |
digits |
Number of digits to display (default: 4). |
... |
Additional arguments (ignored). |
Value
Invisibly returns the input object.
Summary method for xtbhst objects
Description
Summary method for xtbhst objects
Usage
## S3 method for class 'xtbhst'
summary(object, digits = 4L, ...)
Arguments
object |
An object of class |
digits |
Number of digits to display (default: 4). |
... |
Additional arguments (ignored). |
Value
Invisibly returns a list with summary statistics.
Bootstrap Slope Heterogeneity Test for Panel Data
Description
Implements the bootstrap slope heterogeneity test based on Blomquist and Westerlund (2015). Tests the null hypothesis that slope coefficients are homogeneous across cross-sectional units.
Usage
xtbhst(
formula,
data,
id,
time,
reps = 999L,
blocklength = NULL,
partial = NULL,
csa = NULL,
csa_lags = 0L,
constant = TRUE,
seed = NULL
)
Arguments
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
|
partial |
Optional formula specifying variables to be partialled out.
For example, |
csa |
Optional formula specifying variables for which cross-sectional averages should be computed and included. Used to handle cross-sectional dependence following Pesaran (2006). |
csa_lags |
Integer. Number of lags of the cross-sectional averages to include (default: 0). |
constant |
Logical. If |
seed |
Optional integer seed for reproducibility. |
Details
The test is based on the following Delta statistic:
\Delta = \sqrt{N} \frac{\tilde{S}/N - K}{\sqrt{2K}}
where \tilde{S} is a weighted sum of squared deviations of
individual slope estimates from the weighted pooled estimate.
The adjusted Delta statistic corrects for small sample bias:
\Delta_{adj} = \sqrt{N} \frac{\tilde{S}/N - K}{\sqrt{V}}
where V = 2K(T-K-K_{partial}-1)/(T-K_{partial}+1).
Under the null hypothesis of slope homogeneity, both statistics are asymptotically standard normal. The bootstrap procedure provides finite-sample p-values.
The function requires a strongly balanced panel (all units observed for all time periods).
Value
An object of class "xtbhst" containing:
- delta
The Delta test statistic.
- delta_adj
The adjusted Delta test statistic.
- pval
Bootstrap p-value for the Delta statistic.
- pval_adj
Bootstrap p-value for the adjusted Delta statistic.
- blocklength
The block length used in the bootstrap.
- reps
Number of bootstrap replications.
- N
Number of cross-sectional units.
- T
Number of time periods.
- K
Number of regressors.
- beta_i
Matrix of individual slope estimates (N x K).
- beta_fe
Vector of weighted fixed effects (pooled) estimates.
- delta_stars
Vector of bootstrap Delta statistics.
- delta_adj_stars
Vector of bootstrap adjusted Delta statistics.
- call
The matched call.
References
Blomquist, J., & Westerlund, J. (2015). Panel bootstrap tests of slope homogeneity. Empirical Economics, 48(1), 1191-1204. doi:10.1007/s00181-015-0978-z
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
Examples
# 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)