Re: [R] bootstrap confidence bands

From: Johannes Hüsing <>
Date: Fri, 29 Aug 2008 08:15:57 +0200

This is an attempt to an answer to Geertja van der Heijden's question, which seems not to have been answered yet.

Your attempt was:

>drought <- read.table("D:/drought080525.txt", header=T)

>regres <- function(x, indices) {
>x <- x[indices,]
>coef(lm(x$AGB ~ x$days, weights=x$weights))

and what you need are the confidence bands for the regression line.

How about generating fitted values out of bootstrap samples the following way

days <- seq(from=min(x$days), to=max(x$days), length=200) days.df <-

regres <- function(x, indices) {

   x <- x[indices,]
   predict(lm(x$AGB ~ x$days), newdata=days.df) }

predvals <- boot(drought, regres, R=10000, stype="i")

You can then plot the results of as lines. mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Fri 29 Aug 2008 - 06:19:38 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 29 Aug 2008 - 06:34:23 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive