User_111995
Keen member
Hi,
In CS1B paper - April 2022 question 2v it asks you to "determine an estimate of the standard error of the sample mean using bootstrap with a bootstrap sample size of 10,000".
When answering the question, using what we know about calculating the standard error from question iv) (Standard_error = sd(y)/sqrt(length(y)) I calculated the standard error using the following code:
set.seed(12345)
bm<-rep(0,10000)
for (i in 1:10000)
{bm<-sd(sample(y, length(y), replace=TRUE))/sqrt(length(y))}
mean(bm)
# 0.4264077
However, in the examiners report they do the mean of the sample and then take the standard deviation like so:
set.seed(12345)
nsim = 10^4
ybar.sim = numeric(nsim)
for (i in 1:nsim){
y.sim = sample(y, replace=T)
ybar.sim = mean(y.sim)
se.boot = sd(ybar.sim); se.boot
# 0.4318923
Is the standard deviation of the mean of a bootstrap sample the same as the standard error? I've tried googling and I've only found similar code to how I answered the question. Would someone please be able to explain how my code is not calculating the se?
Thank you,
Lily
In CS1B paper - April 2022 question 2v it asks you to "determine an estimate of the standard error of the sample mean using bootstrap with a bootstrap sample size of 10,000".
When answering the question, using what we know about calculating the standard error from question iv) (Standard_error = sd(y)/sqrt(length(y)) I calculated the standard error using the following code:
set.seed(12345)
bm<-rep(0,10000)
for (i in 1:10000)
{bm<-sd(sample(y, length(y), replace=TRUE))/sqrt(length(y))}
mean(bm)
# 0.4264077
However, in the examiners report they do the mean of the sample and then take the standard deviation like so:
set.seed(12345)
nsim = 10^4
ybar.sim = numeric(nsim)
for (i in 1:nsim){
y.sim = sample(y, replace=T)
ybar.sim = mean(y.sim)
se.boot = sd(ybar.sim); se.boot
# 0.4318923
Is the standard deviation of the mean of a bootstrap sample the same as the standard error? I've tried googling and I've only found similar code to how I answered the question. Would someone please be able to explain how my code is not calculating the se?
Thank you,
Lily