So, the sample mean for the log-normal is defined as $exp(\mu + \sigma^2/2)$. So, I made the boot statistic function as follows:
boot_mean <- function(data, ind){
exp(base::mean(data[ind])+var(data[ind])/2)
}
Then the simulation function:
bs_sim <- function(n, bs_N, mju){
bs <- boot(rlnorm(n, meanlog = 1, sdlog = 0.5), statistic = boot_mean, R = bs_N)
prod(boot.ci(bs)$perc[4:5] - mju)
}
Here is the function that computes the precision of bootstrap intervals:
prec_bs <- function(n, N, bs_N, mju){
rez <- replicate(N, bs_sim(n, bs_N, mju))
length(rez[rez<0])/N
}
When I apply the prec_bs to data
prec_bs(n = 50, N = 500, bs_N = 1000, mju = 1))
I get value zero. When I just apply the boot.ci(boot()) function to generated rlnorm() data, I get unreasonable confidence intervals:
Intervals :
Level Normal Basic
95% ( -0.38, 107.85 ) (-43.13, 83.99 )
Level Percentile BCa
95% ( 32.05, 159.17 ) ( 34.87, 173.55 )
What I am doing wrong?
mju
does not appear to be specified, nor do I see the purpose ofbs_sim
$\endgroup$