I would like to bootstrap the difference between two mean costs (I have a
different number of observations in the two group costs under
consideration).
So, this is my script:
x <- datos$direct_costsUS
fun <- function(x){m=(mean(x[63:136])-mean(x[1:62]))
}
boot.x<- boot(x,
statistic = function(d, ind){fun(d[ind])},
R = 5000,
sim = "ordinary")
boot.ci(boot.x, conf = 0.95,type =
c("norm","basic","perc","bca"))
####Problem with bca
plot(boot.x)
This is the final result:
Bootstrap Statistics :
original bias std. error
t1* 15.95379 -15.95875 4.792771
the bias sounds to me really strange.
Do you think my bootstrap procedure is working well?
Thanks a lot for your time.
Best Regards.
Marcella
--
View this message in context:
http://r.789695.n4.nabble.com/Bootstrap-tp2317776p2317776.html
Sent from the R help mailing list archive at Nabble.com.
Hi,
I assume you used boot package. Try this:
library(boot)
x <- rnorm(136)
fun <- function(x,ind){
x <- x[ind]
m <- mean(x[63:136])-mean(x[1:62])
m
}
boot.x<- boot(x, fun, R = 5000, sim = "ordinary")
-----
A R learner.
--
View this message in context:
http://r.789695.n4.nabble.com/Bootstrap-tp2317776p2317860.html
Sent from the R help mailing list archive at Nabble.com.
You should bootstrap the two groups separately. The bootstrap sample you get do not follow the same order as the original sample, so the first 62 observations are coming from both groups. What you bootstrapped is essentially the difference between the pooled mean and itself, which would no doubt come up as 0. -- View this message in context: http://r.789695.n4.nabble.com/Bootstrap-tp2317776p2318480.html Sent from the R help mailing list archive at Nabble.com.