help for exbsampleP. Van Kerm (September 2022)

Title

exbsample -- Exchangeably weighted (or Bayesian) bootstraps

Syntax

exbsample # [if] [in] [weight] [using filename] [, options]

# is the desired number of bootstrap replicates.

option Description

stub(name) prefix of bootstrap weight variables generated
distribution(poisson or exponential) choice of bootstrap weight distribution
norescale disable scaling of weights to unit mean
balance(#) request balancing of bootstrap weights (in # iterations)
seed(#) set random-number seed to #
strata(varlist) variables identifying strata
cluster(varlist) variables identifying clusters
svysetttings reads strata and cluster identifiers from svyset
idvars(varlist) variables uniquely identifying bootrapped units in new frame or data file
frame(name [, linkvarname(varname) replace nofrlink])
save bootstrap weight variables in a separate frame name and links to the current frame using variable varname (unless nofrlink is specified)
replace replace frame name or file filename or variables stub* if they exist
nodots do not display dots

fweight, pweight or iweight are allowed.

Description

exbsample generates bootstrap replication weights for implementation of
exchangeably weighted bootstrap schemes, also known as the Bayesian bootstrap. It can be used as an alternative to bsample.

Exchangeably weighted bootstrap schemes (or weighted, or exchangeable bootstraps) are
alternatives to the traditional non-parametric (paired) bootstrap. Standard bootstrap
replications involve generating bootstrap samples of size N by drawing with replacement
from the original data. Such a bootstrap resample can be seen as a frequency weighted
version of the original data, with integer weights representing the number of times each observation
is drawn in a resample. (See the weight option of Stata's bootstrap drawing command bsample.)
Exchangeably weighted bootstrap schemes can be seen as extensions of this representation:
bootstrap resamples are created by generating replication weights directly from appropriate distribution functions.
See Praestgaard and Wellner (1993) for details. This technique is also known as the Bayesian bootstrap (Rubin, 1981).

exbsample generates weights based on draws from a Poisson distribution or from an exponential distribution (both with unit mean).
Drawing from the Poisson distribution generates integer weights 0, 1, 2, ... the distribution of which approximates the multinomial
distribution that standard resampling weights effectively follow.
Drawing from the exponential distribution generates strictly positive, non-integer weights. Draws from the exponential distribution
can be seen as continuous (smoothed) versions of the Poisson draws. The advantage of exponential draws is the absence of
zero weights: all observations from the original data are kept in the bootstrap resamples, albeit with possibly small weights.
This can have practical computational advantages. In both cases, replication weights are, by default, scaled to sum to the sample size N.

Once replication weight variables are generated, they can be used by svy bootstrap for bootstrap inference. (_svyset ,bsrweight(...) needs to be set accordingly.)
Also see J. Pitblado's bs4rw.

Stratified and/or clustered sampling is handled by specifying strata and cluster
identifiers (as in bsample); samples of clusters are `drawn' independently
across strata -- observations from the same cluster all have the same weight and weights sum to the number of clusters.

Observations that do not meet the optional if and in criteria are excluded from the bootstrap replications.

If an fweight, pweight or iweight is given, the Poisson or exponential bootstrap replication weights are multiplied by the weight expression.

The replication weight variables generated are added to the data in memory by default. They can alternatively be saved in a separate file if using filename is specified or in a separate frame with the option frame.

Options

stub(name) determines the name of the bootstrap weight variables generated. Replication weight variables are named name1, name2, etc. Default is bootvar1, bootvar2}, etc.

distribution(name) selects the bootstrap weight distribution; name is exponential (the default) or poisson.

norescale disable scaling of replication weight variables to sum to the number of observations (or clusters).

balance(#) requests balancing of weights across all replications. Standard bootstrap balancing ensures that each observation in the data is drawn the same number of times in the overall set of resamples. Balancing is implemented here by scaling resampling weights `horizontally' (i.e., across replications for each observation) so that they sum to the number of bootstrap replications. To obtain both balancing (horizontal) and scaling (vertical), the two scaling steps are iterated # number of times. (Default is 0 which implies no balancing.)

seed(#) sets the random number generator seed to # prior to generating replication weight draw.

strata(varlist) specifies the variables identifying strata. If strata() is specified, bootstrap replication weights are scaled to sum to the number of clusters in each stratum.

cluster(varlist) specifies the variables identifying resampling clusters (primary sampling units). If cluster() is specified, one replication weight is drawn per cluster and is shared across all observations in the cluster.

svysettings requests that strata and cluster information is read from the settings of the dataset, as determined by svyset.

idvars(varlist) identifies variables that uniquely identify the bootrapped units. This is required when replication weights are stored in a separate frame or data file: the variables in idvars are saved alongside the replication weights to allow matching to the dataset in memory.

frame(name) requests that bootstrap replication weight variables are stored in a new, separate frame named name (and not in the current frame in memory). A frame linkage is created to the current frame unless the nofrlink sub-option is specified. The link variable is given in linkvarname(varname) (BOOTSTRAPLINK by default).

replace requests that frame name or file filename or variables stubX are replaced if they already exist.

nodots disables display of dots.

Examples

Generate simple replication weights from exponential distribution:

. sysuse auto
. exbsample 499 , stub(rw)
. summarize rw1 rw2 rw499
. svyset , bsrweight(rw1-rw499)
. svy bootstrap : regress price trunk i.foreign

Select Poisson weights and save weights in separate dataset:

. sysuse auto
. exbsample 499 using replications-weights.dta , stub(rw) distribution(poisson) idvars(make)

Select Poisson weights, disable weight scaling and save weights in separate frame:

. sysuse auto
. exbsample 499 , stub(rw) distribution(poisson) norescale frame(replications , link(bootvarlink)) idvars(make)
. frget rw1, from(bootvarlink)
. regress price trunk i.foreign [iw=rw1]
. frame change replications
. summarize rw1 rw2 rw499

See Van Kerm (2022) for more examples.

Citation suggestion

Van Kerm, P. (2022). exbsample - Stata module for exchangeably weighted (or Bayesian) bootstraps, Statistical Software Components, Boston College Department of Economics.

Also see

Online: [R] bsample, rhsbsample (if installed), gsample (if installed), bsweights (if installed), bs4rw (if installed)

Author

Philippe Van Kerm

Luxembourg Institute of Socio-Economic Research and University of Luxembourg

References

Praestgaard, J. and Wellner, J. A. (1993), Exchangeably weighted bootstraps of the general empirical process, The Annals of Probability 21(4), 2053–208

Rubin, D. (1981), The Bayesian bootstrap, The Annals of Probability 21(4), 2053–208

Van Kerm, P. (2022). Exchangeably weighted bootstrap schemes. 2022 London Stata Users Group meeting, September 8-9 2022, University College London.

This help file was dynamically produced by
MarkDoc Literate Programming package