(Q5.1) Consider the samples {1, 2, 3, 4, 5, 6}. Using a random number generator, obtain three different bootstrap samples and their respective means. What is the bootstrap estimate of the standard error of the sample mean using these three replicates?
IN R
Firstly let us feed in the data:
dat <- c{1,2,3,4,5,6}
Generate 3 bootstrap replications and their respective means:
n <- length(dat) #n=6
B <- 3
boot <- numeric(B)
for (i in 1:B) { idx <- sample(1:n, size = n, replace = TRUE) #choose 8 indices with replacement
boot[i] <- mean(sort(dat[idx])[3:6]) #draw sample, compute & store trimmed mean
}
Compute bootstrap estimate of standard error:
se <- sd(boot)
cat("Bootstrap estimate of standard error is", se)
Get Answers For Free
Most questions answered within 1 hours.