[R] Using boot.ci "norm" not working
Rui Barradas
ru|pb@rr@d@@ @end|ng |rom @@po@pt
Thu Dec 16 23:54:49 CET 2021
Hello,
When the confidence interval is the normal CI, the return matrix has
only 3 columns, all other CI's return a matrix with 5 columns. See
section value in ?boot.ci.
So just change
$norm[, 4:5]
to
$norm[, 2:3]
Hope this helps,
Rui Barradas
Às 22:24 de 16/12/21, varin sacha via R-help escreveu:
> Dear R-experts,
>
> Here below my R code. Using "bca" in the boot.ci function at the end of my R code works perfectly. Using "perc" and "basic" perfectly works as well. But using "norm", my R code does not work anymore.
> Is it possible to solve that problem and to make my R code work ?
>
> ################################################
> library(boot)
>
> s<- sample(178:798, 10000, replace=TRUE)
> mean(s)
>
> N <- 100
> out <- replicate(N, {
> a<- sample(s,size=5)
> mean(a)
>
> dat<-data.frame(a)
> med<-function(d,i) {
> temp<-d[i,]
> mean(temp)
>
> }
>
> boot.out <- boot(data = dat, statistic = med, R = 10000)
> boot.ci(boot.out, type = "norm")$norm[, 4:5]
> })
> mean(out[1,] < mean(s) & mean(s) < out[2,])
> ################################################
>
> ______________________________________________
> 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