Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# Re: st: Bootstrap strata

 From Laura Gibbons To statalist@hsphsun2.harvard.edu Subject Re: st: Bootstrap strata Date Wed, 5 Jun 2013 13:26:21 -0700 (PDT)

Yes, in my example it's quite tricky, because the reason one person has more values than another probably is informative. We are trying to capture this in the predictive model, but of course will not do so completely.
```
```
This is one of several modeling approaches we will be comparing, all with deficiencies of one sort or another.
```
thanks,

Laura

On Tue, 4 Jun 2013, Steve Samuels wrote:

```
```

I should also point out that your procedure assumes that the number
of observations on an individual and, perhaps, the order of individual
observations are uninformative about the study outcomes ("perhaps",
because you might already have included sequence information among
the predictors).

S.

Laura:

The coefficients reported after -bootstrap- will be the coefficients for
from -regress- on the full sample. You want the mean  of the coefficients
from the -bootstrap- samples. You can get these with:

. estat bootstrap, all
. matrix list e(b_bs)

Throwing out data can be inefficient. As you have nested observations,
you might try -xtmixed- with robust standard errors and compare the
results.

Steve

On Jun 4, 2013, at 12:53 PM, Laura Gibbons wrote:

```
```In case someone else has this problem in the future, here is what I found out:

By default, the -strata- option for -bootstrap- would perform
sampling with replacement within each strata; but the default number
of observations is the number of observations present in the dataset.

If a person has 7 observations, the sample will consist of
7 observations for that person; the difference with the original
dataset is that it will be a sample with replacement, i.e., repeated
observations might be present.

For my purposes, since I want my samples per individual have size 1, I need to specify that as follows:

bootstrap, strata(id) size(1): regress...

```
```
On Fri, 31 May 2013, Laura Gibbons wrote:

```
```
I have data with 1 to 7 observations/person.  I want to randomly sample one observation/person in some sort of a bootstrapping process to get an appropriate error term for, say, x.

I can set this up myself using a loop around the -bsample- command [bsample 1, strata(id)], posting the estimated coefficient for x each sample and taking the std dev of the mean of x for my 1000 times through the loop.

Is there a way to do this directly in -bootstrap-?  Here is what the manual says about the strata option there:

strata(varlist) specifies the variables that identify strata.  If this
option is specified, bootstrap samples are taken independently within
each stratum.

It is not clear to me what that means.  Does it mean it will sample once from each stratum?  I think not, based on my results, but I honestly can't tell.

Many thanks,

Laura
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Laura E. Gibbons, PhD
General Internal Medicine, University of Washington
Box 359780, Harborview Medical Center, 325 Ninth Ave, Seattle, WA 98104
phone: 206-744-1842, fax: 206-744-9917,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/

```
```
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Laura E. Gibbons, PhD
General Internal Medicine, University of Washington
Box 359780, Harborview Medical Center, 325 Ninth Ave, Seattle, WA 98104
phone: 206-744-1842, fax: 206-744-9917,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/

```
```
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Laura E. Gibbons, PhD
General Internal Medicine, University of Washington
Box 359780, Harborview Medical Center, 325 Ninth Ave, Seattle, WA 98104
phone: 206-744-1842, fax: 206-744-9917,