University of Minnesota, Twin Cities
School of Statistics
Stat 5601
Rweb

Stat 5601 (Geyer) Examples
(Bootstrap Bias Correction)
Contents
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.
Section 10.3 in Efron and Tibshirani.
Everything pretty obvious here. No comments.

Section 10.3 in Efron and Tibshirani.
z <- oldpatch - placebo
y <- newpatch - oldpatch
print(theta.hat <- mean(y) / mean(z))
n <- length(y)
nboot <- 1000
theta.star <- double(nboot)
p.bar <- rep(0, n)
for (i in 1:nboot) {
k <- sample(1:n, replace = TRUE)
z.star <- z[k]
y.star <- y[k]
theta.star[i] <- mean(y.star) / mean(z.star)
p.bar <- p.bar + tabulate(k, n)
}
p.bar <- p.bar / (n * nboot)
hist(theta.star)
abline(v = theta.hat, lty = 2)
# bootstrap estimate of bias
print(bias.hat <- mean(theta.star) - sum(y * p.bar) / sum(z * p.bar))
# bias corrected estimate
theta.hat - bias.hat

External Data Entry
Enter a dataset URL :
Everything pretty obvious here too.

The only comment is about the `tabulate`

function
(a
on-line help ), which is an R (or S) ism that you have to know about
to do this job. It produces a vector of counts of how many times each
integer from 1 to `n`

occurs in the vector `k`

.