How to calculate confidence interval using the “bootstrap function” in R

前端 未结 2 723
时光取名叫无心
时光取名叫无心 2021-01-07 10:57

I am trying to calculate the confidence interval in R. Due to some special reasons, I have to do it with the functions in \"bootstrap\" package.(which means I can\'t use th

2条回答
  •  独厮守ぢ
    2021-01-07 11:19

    There are different ways of calculating the CI for the bootstrap estimator (cf. to this Wikipedia article for instance.

    The easiest is to tale the 2.5% and 97.5% quantiles from the bootstrapped coefficients (Percentile Bootstrap in the Wikipedia article):

    quantile(law.boot$thetastar, c(0.025, 0.975))
    #      2.5%     97.5% 
    # 0.4528745 0.9454483 
    

    Basic Bootstrap would be calculated as

    2 * mean(law.boot$thetastar) - quantile(law.boot$thetastar, c(0.975, 0.025))
    #     97.5%      2.5% 
    # 0.5567887 1.0493625
    

提交回复
热议问题