[R] confusion with boot
Liaw, Andy
andy_liaw at merck.com
Thu Jun 2 04:25:01 CEST 2005
Your function does not meet the requirement for boot(). Here's an example:
> x <- runif(100)
> y <- x + rnorm(100, sd=0.1)
> dat <- data.frame(x, y)
> rm(x,y)
> rsq <- function(data, idx) summary(lm(y~x, data=dat[idx,]))$r.squared
> rsq.boot <- boot(dat, rsq, R=200)
> rsq.boot
ORDINARY NONPARAMETRIC BOOTSTRAP
Call:
boot(data = dat, statistic = rsq, R = 200)
Bootstrap Statistics :
original bias std. error
t1* 0.8964966 0.0002857293 0.01841738
HTH,
Andy
> From: John Sorkin
>
> I think I am doing something wrong when I try to bootstrap R square
> obtained from lm. My code is included below. No matter how
> many times I
> run the simulation, I always get exactly the same result, the bias and
> std.error are always zero. I would think that these values should be
> non-zero. I would appreciate any suggestions as to what I am doing
> wrong, or perhaps what I fail to understand.
> R 2.1.0 Patched Win 2k.
> Thanks,
> John
>
>
> >detefun3<-function (d,w)
> summary(lm(d$sg120~d$fg120adj,data=d))$r.square
> > boot(delete,deletefun3,R=200)
>
> ORDINARY NONPARAMETRIC BOOTSTRAP
>
> Call:
> boot(data = delete, statistic = deletefun3, R = 200)
>
> Bootstrap Statistics :
> original bias std. error
> t1* 0.3028048 0 0
> >
>
> John Sorkin M.D., Ph.D.
> Chief, Biostatistics and Informatics
> Baltimore VA Medical Center GRECC and
> University of Maryland School of Medicine Claude Pepper OAIC
>
> University of Maryland School of Medicine
> Division of Gerontology
> Baltimore VA Medical Center
> 10 North Greene Street
> GRECC (BT/18/GR)
> Baltimore, MD 21201-1524
>
> 410-605-7119
> -- NOTE NEW EMAIL ADDRESS:
> jsorkin at grecc.umaryland.edu
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
>
>
More information about the R-help
mailing list