I'm performing parametric bootstrapping in R
for a simple problem and getting Bias
and Standard Error
zero always. What am I doing wrong?
set.seed(12345)
df <- rnorm(n=10, mean = 0, sd = 1)
Boot.fun <-
function(data) {
m1 <- mean(data)
return(m1)
}
Boot.fun(data = df)
library(boot)
out <- boot(df, Boot.fun, R = 20, sim = "parametric")
out
PARAMETRIC BOOTSTRAP
Call:
boot(data = df, statistic = Boot.fun, R = 20, sim = "parametric")
Bootstrap Statistics :
original bias std. error
t1* -0.1329441 0 0
You need to add line of code to do the sampling, ie.
Boot.fun <-
function(data) {
data <- sample(data, replace=T)
m1 <- ...
since you didn't supply a function to the argument rand.gen
to generate random values. This is discussed in the documentation for ?boot
. If sim = "parametric"
and you don't supply a generating function, then the original data is passed to statistic
and you need to sample in that function. Since your simulation was run on the same data, there is no standard error or bias.