Home > Mobile >  boot.ci() in R gives unreasonable confidence intervals for log-normal data set
boot.ci() in R gives unreasonable confidence intervals for log-normal data set

Time:10-27

So, here is the function that outputs the mean for log-normal data:

 boot_mean <- function(data, ind){
     exp(base::mean(data[ind]) var(data[ind])/2)
    }

If I apply boot.ci(boot()) functions to log-normal data, I get unreasonable confidence intervals:

CALL : 
boot.ci(boot.out = boot(rlnorm(n, meanlog = 1, sdlog = 0.5), 
    statistic = boot_mean, R = 100))

Intervals : 
Level      Normal              Basic         
95%   (  1.22, 111.72 )   (-13.43,  98.39 )  

Level     Percentile            BCa          
95%   ( 27.45, 139.28 )   ( 26.77, 137.85 ) 

I suppose, there is something wrong with the boot_mean function, maybe someone sees the error?

EDIT: Here is the edited statistic function:

boot_mean <- function(data, ind){
    ld <- log(data[ind])
    exp(base::mean(ld) var(ld)/2)
  }

But using this function the outputted confidence intervals lie around 3:

CALL : 
boot.ci(boot.out = boot(rlnorm(n, meanlog = 1, sdlog = 0.5), 
    statistic = boot_mean, R = 100))

Intervals : 
Level      Normal              Basic         
95%   ( 2.730,  3.507 )   ( 2.743,  3.537 )  

Level     Percentile            BCa          
95%   ( 2.694,  3.488 )   ( 2.728,  3.499 ) 

CodePudding user response:

I'm pretty sure you want

boot_mean <- function(data, ind) {
   ld <- log(data[ind])
   exp(base::mean(ld) var(ld)/2)
}

That is, we want exp(mean(x) var(x)/2) where the x is on the log scale ...

  •  Tags:  
  • r
  • Related