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@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@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.