Can you please tell me the advantage of bootstrapping in the example below:
sampleOne <- function(x) sample(x, replace = TRUE) sampleMany <- function(x, n) replicate(n, sampleOne(x), simplify = FALSE) listMeans <- function(x, n) lapply(sampleMany(x, n), mean) bootData <- function(x,n) do.call(rbind, listMeans(x,n)) sampleSize <- 100000 numBoots <- 1000 # Left Skewed distribution # shape1 = a and shape2 = b set.seed(400) popSkewLeft <- rbeta(sampleSize, shape1 = 5, shape2 = 1) hist(popSkewLeft) skewLeftbootData <- bootData(popSkewLeft, numBoots) (populationMean <- mean(popSkewLeft))# Mean = a/(a+b) = (5)/(5+1) = 0.8333333 (bootMean <- mean(skewLeftbootData)) (populationSd <- sd(popSkewLeft)) #sd = sqrt(ab/((a+b)^2 (a+b+1))) = sqrt((5*1)/((5+1)^2*(5+1+1))) = 0.140859 (bootSd <- sd(skewLeftbootData) * sqrt(sampleSize))
I created a left skewed population as can be seen from the above code. I also calculated the sample standard deviation. the population standard deviation was calculated using the beta distribution equation.
The sample standard deviation and the booted standard error * the square root of the sample size are almost the same. As a matter of fact the sample standard deviation is closer to the population parameter.