### Bootstrap t CI for the trimmed mean of the time on target data ttarg <- c(77,87,88,114,151,210,219,246,253,262,296, 299,306,376,428,515,666,1310,2611) gamma <- 0.20 # proportion to be trimmed on both sides tmuhat <- mean(ttarg,trim=gamma) tmuhat ttmean2 <- function(X){ x <- sort(X) # sort X for Winsorizing n <- length(x) a <- mean(x,trim=gamma) den <- n*(1 - 2*gamma)^2 tt <- floor(n*gamma) lower <- x[tt-1] # l for low, rep l in wv upper <- x[n-tt] # u for up, rep u in wv wv <- c(rep(lower,time=tt),x[(tt+1):(n-tt)], rep(upper,time=tt)) b <- (a-tmuhat)/sqrt(var(wv)/den) c(a,b) # returns the two values } ttmean2.boot <- bootstrap(ttarg,ttmean2,B=2500) print(ttmean2.boot) plot(ttmean2.boot) ttmean2.boot$estimate[1,3] # the SE of the trimmed means setmn <- ttmean2.boot$estimate[1,3] # location of the SE in the bootstrap data.frame setmn ttmean2.boot.emp <- limits.emp(ttmean2.boot) ttmean2.boot.emp finv05 <- ttmean2.boot.emp[2,2] finv05 finv95 <- ttmean2.boot.emp[2,3] finv95 ttmean2.btci <- c(tmuhat - (setmn*finv95), tmuhat - (setmn*finv05)) ttmean2.btci