Dear Rui,
Many thanks, I got it now, thanks.
In my R code, I have moved the replication term
N <-1000
out <- replicate(N, {
This time I get what I am looking for.
library(boot)
s<- sample(178:798, 1, replace=TRUE)
mean(s)
N <- 1
out <- replica
Hello,
As for the code, I think it's simple. Before calling boot.ci you need to
call boot. And replicate calls the expression between {} N times. After
running boot.ci, the component bca is extracted. See ?boot.ci, section
Value, after bca:
These latter four components will be matrices with
Dear Rui,
I really thank you a lot for your response. Even if I don't fully understand
your R code, there is something strange happening while running the code.
Indeed, I have run this R code here below 20 times and I always got the same
answer : [1] 1
l
Hello,
The problem can be solved with ?replicate.
in the code below I only repeat N <- 1e3, not 1e4.
set.seed(2021)
N <- 1e3
out <- replicate(N, {
boot.out <- boot(data = dat, statistic = med, R = 1)
boot.ci(boot.out, type = "bca")$bca[, 4:5]
})
mean(out[1,] < mean(s) & mean(s) < out[2,
Dear R-experts,
Here below my R code. I am trying to do 2 things :
1) I would like to repeat this R code 1 times
2) Out of the 1 repetitions I would have liked R to tell me how many times
the "true" mean value of the population called "s" in my R example here below
is included in the 1
5 matches
Mail list logo