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){

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))

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?

  • $\begingroup$ It will be helpful if your code is a mwe. Eg, mju does not appear to be specified, nor do I see the purpose of bs_sim $\endgroup$ Oct 26, 2021 at 13:14
  • $\begingroup$ @ChristophHanck Ok, I edited the code. I created the bs_sim function in order to compute the coverage precision of bootstrap intervals. But the main issue is the boot_mean function, because when function boot.ci(boot()) is applied to generated data, the outputted confidence intervals are completely off. $\endgroup$
    – user
    Oct 26, 2021 at 13:47

1 Answer 1


Do you maybe simply want

boot.ci(boot(rnorm(5000, mean = 1, sd = 0.5), statistic = boot_mean, R = 500), type = c("norm", "perc", "basic"))

instead of

boot.ci(boot(rlnorm(5000, meanlog = 1, sdlog = 0.5), statistic = boot_mean, R = 500), type = c("norm", "perc", "basic"))?

You are after constructing a confidence interval of the log-normal distribution, i.e., $\exp(\mu+\sigma^2/2)$. You construct it by producing bootstrap estimates of $\mu$ and $\sigma^2$ and pass these into the function that turns the parameters into estimates of $\exp(\mu+\sigma^2/2)$ in boot_mean. So, I would say, the input to data ought to be normal, not log-normal, for the construction to work.

I do then get reasonable CIs for a true value of exp(1+0.5^2/2).

If you, instead, feed a log-normal sample into boot_mean, the expected value and variance, from https://en.wikipedia.org/wiki/Log-normal_distribution, will be

mu <- 1
sig <- 1/2
eln <- exp(mu+sig^2/2)
vln <- exp(2*mu+sig^2)*(exp(sig^2)-1)

so that the function value is exp(eln+vln/2), which equals roughly 84, for which (for $n$ sufficiently large - note this is a rather nonlinear problem, so that even a "correct" bootstrap may not perform well in small samples), the bootstrap seems to work again.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.