R boot package: Code for wild bootstrap so that BCa confidence intervals can be obtained with boot.ci()?

99 Views Asked by At

I am trying to do a wild bootstrap procedure with the 'boot' R-package. The documentation of the package cites the Davison & Hinkley, 1997 book as the source they are basing their functions on. In this book there is one example of a wild bootstrap (p. 537 & 538, written for Splus) which I adapted in R for a simple OLS regression model:

# Fit regression model
model <- lm(y ~ x)
res <- model$residuals 
fit <- model$fitted.values

# Save fitted values and residuals to data frame
data <- data.frame(x, y, res, fit)

# Function for "statistic" argument in boot()
fit.model <- function(data) {
  fit <- lm(y ~ x, data = data)
  coef(fit)
}

# Information & function for wild bootstrap
data.mle <- c(nrow(data), (5+sqrt(5))/10)   
data.wild <- function(data, mle) {
  d <- data
  i <- 2*rbinom(mle[1], size = 1, prob = 1-mle[2])-1
  d$y <- d$fit + d$res*(1 - i*sqrt(5))/2
  d
}

# Number of bootstrap samples
B <- 1000

# Bootstrap
library(boot)
data.boot.wild <- boot(data, statistic = fit.model, R = B, sim = "parametric",
                       ran.gen = data.wild, mle = data.mle)

The problem is that if I want to obtain the bias-corrected and accelerated (BCa) confidence intervals for this bootstrap the boot.ci() function does not work:

boot.ci(data.boot.wild, type = "bca", index = 1)

# Error in empinf(boot.out, index = index, t = t.o, ...) : 
# influence values cannot be found from a parametric bootstrap

As can be seen in the Error message, boot.ci() seemingly can only compute (non-parametric) CIs from non-parametric bootstraps because the computation of empirical influence values (needed for the acceleration parameter in BCa) is not possible when sim = "parametric".

Is there a different way to write the wild bootstrap as a non-parametric bootstrap in 'boot' so that the BCa CIs can be obtained from boot.ci() which is also correct on a theoretical level? Or is there maybe a different method instead of boot.ci() inside the 'boot' package for obtaining the fitting BCa CIs that is correct?

This post (adjusted bootstrap confidence intervals (BCa) with parametric bootstrap in boot package) mentions changing the arguments of the empinf() function imbedded in boot.ci() but there seems to be no definite answer whether this is correct or not. I have a hard time understanding the difference between a parametric & non-parametric bootstrap and do not know if it is inherently necessary to write a wild bootstrap with sim = "parametric" instead of e.g. sim = "ordinary", since I can only find the former in Davison & Hinkley's book.

0

There are 0 best solutions below