# Stat 5601 (Geyer) Examples (Bootstrap T)

## General Instructions

To do each example, just click the "Submit" button. You do not have to type in any R instructions or specify a dataset. That's already done for you.

## Bootstrap T with Variance Estimate Supplied

### Section 12.5 in Efron and Tibshirani.

• As usual, `library(bootstrap)` says we are going to use code in the `bootstrap` library, which is not available without this command. Here `library(bootstrap)` is necessary for two reasons. Without it we can't get the data `mouse.c` and we also can't get the function `boott` (on-line help) that we use to construct bootstrap t intervals.

• The argument `theta` is a function that calculates the point estimate on which the interval is based. Here the point estimate is the sample mean, calculated by the function `mean`.

• The function `fred` calculates an estimate of the standard error of the estimator calculated by `theta`. In this example the sample mean (calculated by the `mean` function) has standard error calculated by `fred`.

• The call signature for `fred` is specified in the documentation for `boott`. It must have exactly this form, with three specified arguments and the dot, dot, dot argument.

• Generally, we only use the first argument `x` in our definition of `fred`. We can also use some of the others, but they are not so useful.
• `nbootsd` is a dummy argument that is not used.
• `theta` is the function that we passed in via the `theta` argument of `boott` (in this example, `mean`). We generally do not need to use the `theta` argument though, because we know the function: we can say `mean(x)` instead of `theta(x)`.
• `...` indicates that other named arguments to the function are allowed. But we can also use global variables rather than arguments.

• The `nboott = 1000` is because of the of the comment in the documentation for `boott`
200 is a bare minimum and 1000 or more is needed for reliable α % confidence points, α > .95 say.
and the similar comment near the top of p. 161 in Efron and Tibshirani.

## Bootstrap T with Double Bootstrap Variance Estimate

### Section 12.5 in Efron and Tibshirani.

• If we omit the `sdfun` argument. The standardization is done another way -- via the bootstrap. In each outer bootstrap iteration a sample x star with replacement from the data is formed, the function `theta` is applied to it to get theta star, the the standard error is estimated from x star by an inner bootstrap that forms samples x star star with replacement from x star and applies `theta` to them to get a bootstrap standard error.

• As everywhere else, the default bootstrap sample sizes for these functions are too low. But cranking them up, as we do here, makes things really slow. In each of the `nboott = 1000` iterations of the outer loop, the are `nbootsd = 200` iterations of the inner loop, for `1000 * 200 = 2e5` iterations in all.

If you get bored, you can use the defaults (omit `nboott` and `nbootsd`), but you won't get as accurate an answer.

## Variance Stabilized Bootstrap T

### Section 12.6 in Efron and Tibshirani.

Another method of automagic variance stabilization estimates a variance stabilizing transformation using the double bootstrap.

• The function `sally` here calculates the estimator. It uses a trick from documentation for `boott`. It's a trick we have been using all along. For complicated data structures, sample the indices 1, . . ., n rather than the data vectors. So we just supply `1:n` as the argument to `boott` and write the estimation function (here `sally` to take the (resampled) indices as an argument.