[R] bootstrap confidence intervals
varin sacha
v@r|n@@ch@ @end|ng |rom y@hoo@|r
Mon Nov 8 17:53:06 CET 2021
Hi,
I really thank you a lot for your response.
Le samedi 6 novembre 2021, 02:37:46 UTC+1, David Winsemius <dwinsemius using comcast.net> a écrit :
On 11/5/21 1:16 PM, varin sacha via R-help wrote:
> Dear R-experts,
>
> Here is a toy example. How can I get the bootstrap confidence intervals working ?
>
> Many thanks for your help
>
> ############################
> library(DescTools)
> library(boot)
>
> A=c(488,437,500,449,364)
> dat<-data.frame(A)
> med<-function(d,i) {
> temp<-d[i,]
# shouldn't this be
HodgesLehmann(temp) # ???
# makes no sense to extract a bootstrap sample and then return a value calculated on the full dataset
> HodgesLehmann(A)
> }
> boot.out<-boot(data=dat,statistic=med,R=100)
I would have imagined that one could simply extract the quantiles of the
HodgesLehmann at the appropriate tail probabilities:
quantile(boot.out$t, c(0.025, 0.975))
2.5% 97.5%
400.5000 488.0001
It doesn't seem reasonable to have bootstrap CI's that are much tighter
than the estimates on the original data:
> HodgesLehmann(boot.out$t, conf.level=0.95)
est lwr.ci upr.ci
449.75 444.25 453.25 # seems to be cheating
> HodgesLehmann(dat$A, conf.level=0.95)
est lwr.ci upr.ci
449 364 500 # Much closer to the quantiles above
--
David.
> HodgesLehmann(boot.out$t)
>
> boot.ci(boot.out,type="all")
> ############################
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
______________________________________________
R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list