Re: [R] bootstrap confidence bands

From: Johannes Hüsing <johannes_at_huesing.name>
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
(untested!):

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

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 boot.ci as lines.



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html 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 https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive