* An example of creating and using bootstrap weights.

* Reference: Valliant, Richard and Jill A. Dever. Survey Weights: 
* A Step-by-Step Guide to Calculation. 1st edition. College Station, 
* TX: Stata Press, 2018. pp.97-98.
* https://www.stata-press.com/books/survey-weights/

* Get the bsweights package for creating bootstrap weights.

findit bsweights

* In the Viewer window that pops up, click on link for:
* st0187 from http://www.stata-journal.com/software/sj10-2

* In the next Viewer window that pops up, click on:
* (click here to install)

* Once the bsweights package is installed, get the following data file
* to try out creating bootstrap weights:

use http://www.stata-press.com/data/svywt/smhosam, clear

* Compare descriptive statistics for the number of hospital beds
* using 1) no weights, 2) the probability weight only and 3) the 
* the probability weight and 500 bootsrap weights (to be created).

summarize BEDS

mean BEDS

* Set up the complex samples scheme with the (one) probability weight.

svyset ID [pweight=wt], strata(hosptype)

svy: mean BEDS

* Create the bootstrap weights. An example is given below.
* Documentation and command options are available at:
* https://www.stata-journal.com/article.html?article=st0187
* and click on:
* View this article (PDF)
* This article includes an explantion of how bootstrap weights are created.
* Please note: As mentioned above, the example given here is from 
* Valliant and Dever, Survey Weights, 2018, pp.97-98. A seed value is set 
* in order that the bootstrap weights can be replicated exactly.
		
bsweights bwt_, n(raowu) reps(500) double seed(339487731)

* Compare a few of the boostrap weights to the probability weight.

summarize wt bwt_1 bwt_2 bwt_499 bwt_500

total wt bwt_1 bwt_2 bwt_499 bwt_500

corr wt bwt_1 bwt_2 bwt_499 bwt_500

* Set up the complex samples scheme with the (one) probability weight
* and the 500 bootstrap weights just created.

svyset ID [pweight=wt], bsrweight(bwt_*) vce(bootstrap) mse

svy: mean BEDS