help xtbhst version 1.0.0

Title

xtbhst - bootstrap test for slope homogeneity in large panels.

Version

Version 1.0.0, 28 February 2026

Author: Dr Merwan Roudane (merwanroudane920@gmail.com)

Syntax

xtbhst depvar indepvars [if] [in] , reps(integer) [blocklength(integer) partial(varlist_p)
noconstant
seed(string)
crosssectional(varlist_cr
[,cr_lags(numlist)])
graph
nooutput
]

depvar and indepvars may contain time-series operators; see tsvarlist.

Data must be xtset before using xtbhst; see xtset.

depvar is the dependent variable of the model to be tested,
indepvar the independent variables.

varlist_p are the variables to be partialled out,
varlist_cr are variables added as cross-sectional averages.

Contents

Options

Description

Econometric Model

Saved Values

Examples

References

About

Description

xtbhst performs a block bootstrap test of slope homogeneity in panels with
a large number observations of the cross-sectional (N) and time (T) dimension.
The null hypothesis of the test is of homogenous slopes.
This implies all slope coefficients are identical across cross-sectional units.

The test is a block-bootstrapped version of Swamy's test for slope homogeneity, evaluated using the resampling scheme proposed by Blomquist and Westerlund (2015).
This procedure is asymptotically valid in the presence of serial correlation and cross-sectional dependence of unknown form.
Unlike standard homogeneity tests which impose asymptotic critical values, the bootstrap corrects for finite-sample size distortions
and accommodates complicated unobserved dependencies simply through block resampling.

The procedure estimates a weighted fixed effects model and panel unit-specific OLS
regressions, partialling out variables expected to be heterogeneous (like the constant or user-defined variables).
Then, it resamples blocks of the estimated residuals (maintaining the cross-sectional structure) to compute
empirical P-values. Large original test statistics diverging from the bootstrapped distribution indicate
rejection of slope homogeneity.

xtbhst requires a strongly balanced panel to perform the block-bootstrap appropriately.
Like xthst, it also allows adding cross-sectional averages to the model.

Additionally, xtbhst introduces a powerful graph option that automatically renders a combined,
publication-quality visual diagnostic grid. It plots the empirical bootstrap distributions of the
(adjusted) Delta statistics alongside the entire cross-sectional density of the heterogeneous slope estimates.

Econometric Model

Based on Pesaran and Yamagata (2008), consider the following model with k = k1 + k2 regressors

y_it = alpha_i + x1_it * beta1_i + x2_it * beta2_i + e_it

or

y_it = z1_it * theta_i + x2_it * beta2_i + e_it

where z1_it = (1, x1_it), theta_i = (alpha_i, beta1_i),
x1_it contains k1 regressors and x2_it contains k2.
Suppose the coefficient of interest are those in beta_i,
then the hypothesis of slope homogeneity is:

H0: beta2_i = beta2, for all i = 1,...,N

The derived test statistic by Pesaran and Yamagata (2008) is:

Delta = sqrt(N) ((1/N * S2_tilde - k_2)/sqrt(2*k_2))

S2_tilde is defined as in equation 13 in Peasaran and Yamagata (2008):

S2_tilde = sum(i=1,N) (b2_i - b2_wfe)'((X2_i' * M1_i * X2_i)/sigma2_i)(b2_i - b2_wfe),

where b2_i is the estimate of beta2_i obtained from individual least squares regression, M1_i partials out the heterogeneous variables Z1_i,
and b2_wfe is the weighted fixed effects estimator.

To handle complex serial or cross-sectional dependencies, Blomquist and Westerlund (2015) construct pseudo-data
y_it* = z1_it * theta_i + x2_it * b2_wfe + e_it*, where e_it* is sampled with replacement in blocks of length l across the time dimension
for all N cross-sections simultaneously.
xtbhst then recomputes the Delta and adjusted Delta statistic for each bootstrap iteration b = 1...B. The empirical
one-sided p-value is the fraction of bootstrap iterations which result in a test statistic strictly greater than the original
value of Delta.

Options

reps(integer) specifies the number of bootstrap replications to perform. This option is required.

blocklength(integer) specifies the block length parameter l for drawing residuals. If set to 1, this results in a standard random
bootstrap. If not specified, the default is set following the data-driven rule l = floor(2 * T^(1/3)).

noconstant suppresses the individual heterogeneous constant, alpha_i.

partial(varlist_p) requests exogenous regressors in varlist_p to be partialled out.
The constant is automatically partialled out, if included in the model.
Regressors in varlist will be included in z_it, explained in Econometric Model.
These regressors are assumed to have heterogeneous slopes.

seed(string) allows users to set a random seed string to perfectly replicate the bootstrap draws.

crosssectional(varlist_cr [,cr_lags(numlist)])
defines the variables which are added as cross-sectional averages to the model to approximate cross-sectional dependence.
Variables in varlist_cr are partialled out.
cr_lags(numlist) sets the number of lags of the cross-sectional averages.
If not defined, but crosssectional() contains a varlist, then only contemporaneous cross sectional averages are added but no lags.
cr_lags(0) is the equivalent.

graph generates publication-quality visualization of the heterogeneity tests. It produces a combined multi-panel graph containing:
1) The Bootstrap Distribution Plot of the bootstrapped $\Delta^*$ statistics.
2) The Bootstrap Distribution Plot of the bootstrapped Adjusted $\Delta^*$ statistics.
3+) The Coefficient Heterogeneity Plots displaying the density of the individual slope estimates $\hat{\beta}_i$ against the pooled $\hat{\beta}_$ estimate for each heterogeneous variable.

nooutput omits output.

Diagnostics and Graphs

By simply appending the graph option to any command, xtbhst seamlessly constructs a publication-ready visual diagnostics dashboard.

The dashboard is rendered as a clean multi-panel grid contrasting the theoretical bounds against exact empirical distributions:

- Bootstrap Distributions: Two panels charting the resampled densities of the Delta and Adjusted Delta test statistics (in transparent blue), contrasting directly against the observed values marked by bold dashed cutoffs.

- Slope Heterogeneity: For every heterogeneous regressor evaluated, a dedicated sub-panel plots the exact density curves of the $N$ independently estimated unit-specific slope coefficients $\hat{\beta}_i$ (in transparent teal) against the pooled restricted fixed-effects baseline.

Saved Values

xtbhst stores the following in r():

Scalars
r(blocklength) selected block length parameter l
r(reps) number of bootstrap replications

Macros
r(crosssectional) variables of which cross-section averages are added
r(partial) variables partialled out

Matrices
r(delta) delta and adjusted delta test statistics
r(delta_p) empirical bootstrap p-values corresponding to the original delta

Examples

An example dataset taken from the Penn World Tables 8 is used to test the slope homogeneity
in a balanced panel consisting of completely observed periods.

We want to test whether slope coefficients in a simple Solow-type growth
model are homo- or heterogeneous.
We draw B = 499 replications for the bootstrap approximation:

xtbhst d.log_rgdpo log_hc log_ck log_ngd, reps(499).

To fix the seed to allow replicability, we use:

xtbhst d.log_rgdpo log_hc log_ck log_ngd, reps(499) seed(123456).

To construct the exact 2x2 multi-panel layout detailed in the Diagnostics section, displaying the two Delta distributions alongside the slope densities for mvalue and kstock:

xtbhst invest mvalue kstock, reps(499) seed(123456) graph.

In case the assumption is that all variables except the lag of GDP are heterogeneous,
the partial(varlist_partial) option can be used as in xthst:

xtbhst d.log_rgdpo L.d.log_rgdpo log_hc log_ck log_ngd, reps(499) partial(log_hc log_ck log_ngd).

References

Blomquist, J. and J. Westerlund. 2015. Panel bootstrap tests of slope homogeneity.
Empirical Economics. https://doi.org/10.1007/s00181-015-0978-z

Pesaran, M. H. and T. Yamagata. 2008. Testing slope homogeneity in large panels.
Journal of Econometrics 142, pp 50 - 93.

Author

Dr Merwan Roudane

merwanroudane920@gmail.com

About and Acknowledgements

This routine is a bootstrap extension of the xthst ado-file originally developed by Tore Bersvendsen and Jan Ditzen. We are grateful for their open-source contributions to panel econometrics in Stata.