2

I am asked to calculate the standard error of the sample mean using bootstrapping for this data set

y = c(4.9, 3.3, 2.2, 2.3, 1.6, 2.4, 4.7, 1.4, 1.7, 5.1) 

The solutions are as follows:

set.seed(12345)

nsim = 10^6 ybar.sim = numeric(nsim)

for (i in 1:nsim){ y.sim = sample(y, replace=T) ybar.sim[i] = mean(y.sim) }

se.boot = sd(ybar.sim); se.boot

[1] 0.4322378

whereas I thought it would be this way:

mean(replicate(1000000, sd(sample(
  y, replace=T))/sqrt(length(y))))

which gives [1] 0.4264217

and using the boot lbrary gives:

bootmean <- function(d, i) mean(d[i])
bs <- boot(y, bootmean, R=1000000, stype="i")
print(bs)

Bootstrap Statistics : original bias std. error t1* 2.96 0.00021043 0.4318501

which is similar to the first answer.

I do not understand why the first answer is correct given the formula for standard error is the standard deviation divided by the length of the vector. Why is the second answer wrong?

1 Answers1

1

Since the $10$ values of $y_i$ have mean $2.96$, the variance of the sample mean should be $\frac1{10}\sum (y_i-2.96)^2 = 0.18684$ and the square root of that is about $0.43225$. In effect that is what the official solution is simulating.

The distinction comes from the non-linearity of the square-root function: the square root of the mean of is usually not the same as the mean of the square root even if you adjust for the square root of the number of terms.

The official solution is simulating the square root of the variance of the mean while you are simulating the mean of the square root of the variance adjusted for sample size. If instead you had simulated the square root of the mean of the variance adjusted for sample size, for example with

sqrt(mean(replicate(1000000, var(sample(
          y, replace=T))/length(y))))

you would have got a result closer to $0.43225$.

Henry
  • 157,058