I am looking for a way to implement non-parametric bootstrap to confidence bands around my regression line for my linear regression model. I am, however, new to bootstrap, therefore I am unsure how to proceed. I have, thus, the following questions:

  1. Is it even possible to implement non-parametric bootstrap to confidence bands?
  2. If yes, how do I proceed?
  3. How do proceed when I am using R?

Thanks a bunch!

  • $\begingroup$ Is this simple linear regression, or something more complicated? Can you show your data? Or at least part of it, in order to provide context? Why do you need to use a nonparametric procedure? (Residuals not normal?) $\endgroup$ – BruceET May 24 at 18:48

As a pragmatic solution, for each bootstrapped dataset,

  1. Fit the regression model
  2. Calculate the predicted values at every desired observation level
  3. Calculate the bootstrap interval estimates for each set of predictions at an observation level


As always, R code seems to convince people more than anything any more so a small working example:

x <- seq(-3, 3, by=0.1)
y <- rnorm(length(x), log(x+4), x+3)

preds <- replicate(1e4, {
  i <- sample(seq(x), replace=T)
  xi <- x[i]
  yi <- y[i]
  predict(lm(yi~xi), newdata=data.frame(xi=x))

preds <- apply(preds, 1, quantile, c(0.025, 0.975))
apply(preds, 1, lines, x=x)


enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.