Skip to content

Selecting Bootstrap Statistics in the boot package

3 messages · Jorge Ivan Velez, David Winsemius

#
Greetings Jorge;

There certainly did not seem to be something readily apparent with  
str(bmean), so the next logical place to look would be for a print  
method. If you look at print.boot with:

getAywhere(print.boot)

  ... you see that the first portion sets up an internal structure  
called "op" and the last of the function prints this with optional  
headers. If you strip out the sections with headers you get:

lim.boot <- function (x, digits = getOption("digits"), index =  
1L:ncol(boot.out$t),
     ...)
{
     boot.out <- x
     sim <- boot.out$sim
     cl <- boot.out$call
     t <- matrix(boot.out$t[, index], nrow = nrow(boot.out$t))
     allNA <- apply(t, 2L, function(t) all(is.na(t)))
     ind1 <- index[allNA]
     index <- index[!allNA]
     t <- matrix(t[, !allNA], nrow = nrow(t))
     rn <- paste("t", index, "*", sep = "")
     if (length(index) == 0L)
         op <- NULL
     else if (is.null(t0 <- boot.out$t0)) {
         if (is.null(boot.out$call$weights))
             op <- cbind(apply(t, 2L, mean, na.rm = TRUE), sqrt(apply(t,
                 2L, function(t.st) var(t.st[!is.na(t.st)]))))
         else {
             op <- NULL
             for (i in index) op <- rbind(op, imp.moments(boot.out,
                 index = i)$rat)
             op[, 2L] <- sqrt(op[, 2])
         }
         dimnames(op) <- list(rn, c("mean", "std. error"))
     }
     else {
         t0 <- boot.out$t0[index]
         if (is.null(boot.out$call$weights)) {
             op <- cbind(t0, apply(t, 2L, mean, na.rm = TRUE) -
                 t0, sqrt(apply(t, 2L, function(t.st) var(t.st[! 
is.na(t.st)]))))
             dimnames(op) <- list(rn, c("original", " bias  ",
                 " std. error"))
         }
         else {
             op <- NULL
             for (i in index) op <- rbind(op, imp.moments(boot.out,
                 index = i)$rat)
             op <- cbind(t0, op[, 1L] - t0, sqrt(op[, 2L]), apply(t,
                 2L, mean, na.rm = TRUE))
             dimnames(op) <- list(rn, c("original", " bias  ",
                 " std. error", " mean(t*)"))
         }
     }

     cat("\n\nBootstrap Statistics :\n")
     if (!is.null(op))
         print(op, digits = digits)
     if (length(ind1) > 0L)
         for (j in ind1) cat(paste("WARNING: All values of t",
             j, "* are NA\n", sep = ""))
     invisible(boot.out)
}
#--------------------------------
lim.boot(bmean)


Bootstrap Statistics :
      original      bias    std. error
t1* 0.0904059 0.004641537  0.09239923

Probably too much in that function, but it does what was requested.