# Different answeres doing essentially the same method

I want to do a bootstrap in two ways and compute the estimated bias and variance. The dataset I use is named Data and it is just $$n=100$$ randomly generated gamma distributed numbers $$(\Gamma(2,1/2))$$. One way is by writing my own code:

N = 1800
bsM = vector("numeric", 1800L)
for (i in 1:N){         # Own code that approximates the distribution.
x = sample(Data, 100, replace = TRUE)
bsM[i] = mean(x)      # These are all bootstrap means thetaHat*
}

EstimatedBias = mean(bsM) - thetaHat
EstimatedVariance = sum((bsM-mean(bsM))^2)/(N-1)


I get the answers $$\text{Bias}(\hat{\theta})\approx 0.0031$$ and $$\text{Var}(\hat{\theta})\approx 0.0261$$.

Now I want to get close to the same results using boot-function in R:

library("boot")
fun = function(Data,i){
return(mean(Data[i]))
}

B = boot(Data,fun,N)
print(B)

ORDINARY NONPARAMETRIC BOOTSTRAP

Call:
boot(data = Data, statistic = fun, R = N)

Bootstrap Statistics :
original      bias    std. error
t1* 4.082139 0.003445815   0.5119067


The bias seems acceptable here, but getting an SE of $$0.51$$ means the estimated variance is $$s^2=SE^2\cdot n \approx 26,01$$ which is whopping 1000 times larger. I used this also: https://en.wikipedia.org/wiki/Standard_error.

I'm wondering if I'm meant to get this huge difference using these two methods or am I doing something wrong?

How did you calculate $$Var(\hat \theta)$$?

First method:

library(boot)
set.seed(1)
Data = rgamma(100, 2, 1/2)

N = 1800
bsM = vector("numeric", 1800L)
for (i in 1:N){
x = sample(Data, 100, replace = T)
bsM[i] = mean(x)
}

sd(bsM) # gives 0.2195808


Second method:

fun = function(Data,i){
return(mean(Data[i]))
}

B = boot(Data, fun, 1800)
print(B)

# Bootstrap Statistics :
#     original     bias    std. error
# t1*  3.74735 0.01100607   0.2181928


So both methods are consistent.

The standard error is defined as the standard deviation of a statistic. When you do a bootstrap, you're actually obtaining samples of the statistic, in this case, the mean. So, the standard deviation of bsM is literally the standard error and squaring it gives you $$Var(\hat \theta)$$. This is exactly what boot does.

• Ahh alright i see now. I thought there was still a difference between standard deviation and standard error even in this case. Thank you very much Aditya! Oct 4, 2018 at 13:50