0

I have a fixed design regression problem that I am trying to get bootstrap BCa confidence intervals for, using R. Here is an example (using lmRob) but this is only for illustration:

require(robust)
data(stack.dat)
stack.rob <- lmRob(Loss ~ ., data = stack.dat)

summary(stack.rob)

Call:
lmRob(formula = Loss ~ ., data = stack.dat)

Residuals:
    Min      1Q  Median      3Q     Max 
-8.6299 -0.6713  0.3594  1.1507  8.1740 

Coefficients:
             Estimate Std. Error t value Pr(>|t|)    
(Intercept) -37.65246    5.00256  -7.527 8.29e-07 ***
Air.Flow      0.79769    0.07129  11.189 2.91e-09 ***
Water.Temp    0.57734    0.17546   3.291  0.00432 ** 
Acid.Conc.   -0.06706    0.06512  -1.030  0.31757    
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 1.837 on 17 degrees of freedom
Multiple R-Squared: 0.6205 

Test for Bias:
            statistic p-value
M-estimate      2.751  0.6004
LS-estimate     2.640  0.6197

There are the boot and the bootstrap packages in R (and also code as given here, but both of them derive non-parametric bootstrap BCa confidence intervals. This, however is a fixed-design regression setup. I am therefore wondering if there is R software available for bootstrap BCa confidence intervals fixed-design regression. An example of a R package or similar using lm would be fine, too.

Thanks!

user3236841
  • 1,088
  • 1
  • 15
  • 39
  • Maybe this [SO question](http://stackoverflow.com/questions/7588388/adjusted-bootstrap-confidence-intervals-bca-with-parametric-bootstrap-in-boot) can help you – StatMan Jul 25 '16 at 12:55
  • I am having trouble with that example. When it says "parametric" regression, does it mean that it is resampling from the normal distribution. I would like to resample from the residuals. I am finding the boot function sort of hard to follow. Thanks again! – user3236841 Jul 25 '16 at 13:52
  • The `boot` package is based on the book: Bootstrap Methods and Their Application by A. C. Davison and D. V. Hinkley (1997). This [link](http://statwww.epfl.ch/davison/BMA/CUPsample.pdf) contains a part of that book. Luckily, it includes the parametric and non-parametric bootstrap. – StatMan Jul 25 '16 at 14:31
  • My question was with regard to what the boot function in R does when it says "parametric" bootstrap. I guess I can use ran.gen to decide what it does. In which case, the bootstrap is not parametric even though it is called so? My thinking is that it is non-parametric bootstrap with a fixed design? – user3236841 Jul 25 '16 at 15:27

1 Answers1

0

I believe that I have an answer, modifying from the example in R Journal of 2002.

require(boot)
require(robust)
data(stackloss)

stack.rob <- lmRob(stack.loss ~ ., data = stackloss)

lmRob.coef <- function(data, y, pred) {
    mod <- lmRob(formula = as.formula(eval(paste(y,"~", paste(pred,collapse="+")))) , data = data,  control = lmRob.control(mxr = 1000, mxf = 1000, mxs = 1000))
    coef(mod)
}

lmRob.results <- function(data, y, pred) {
    mod <- lmRob(formula = as.formula(eval(paste(y,"~", paste(pred,collapse="+")))) , data = data)
    data.frame(fitted = fitted(mod), residuals = resid(mod))
}

fit.dat <- lmRob.results(data = stackloss, y = "stack.loss", pred = c("Air.Flow", "Water.Temp", "Acid.Conc."))

model.fun <- function(data, i, y, pred, fitted.results) {
    dat <- cbind(data, fitted.results)
    dat[, y] <- dat$fitted + dat$residuals[i]
    lmRob.coef(data = dat, y = y, pred = pred)
}

lmRob.boot <- boot(data = stackloss, statistic = model.fun, R = 999, y = "stack.loss", pred = c("Air.Flow", "Water.Temp", "Acid.Conc."), fitted.results = fit.dat)

boot.ci(boot.out=lmRob.boot, type="bca", index=4)

BOOTSTRAP CONFIDENCE INTERVAL CALCULATIONS
Based on 999 bootstrap replicates

CALL : 
boot.ci(boot.out = lmRob.boot, type = "bca", index = 4)

Intervals : 
Level       BCa          
95%   (-0.2644,  0.2963 )  
Calculations and Intervals on Original Scale

Next objective is to include weights for the different cases in the model.

user3236841
  • 1,088
  • 1
  • 15
  • 39