[R] bootstrap: boot package
Frank E Harrell Jr
fharrell at virginia.edu
Fri Jan 25 20:55:30 CET 2002
Brian - I wasn't talking about simplicity, but speed, for this special case. -Frank
On Fri, 25 Jan 2002 19:31:46 +0000 (GMT)
Prof Brian D Ripley <ripley at stats.ox.ac.uk> wrote:
> On Fri, 25 Jan 2002, Rob Gould wrote:
>
> > I'm teaching a class and using R for the first time. We're talking
> > about the bootstrap, and I've been trying to get R to replicate some
> > simple bootstrap programs with no success. I'd like to be able to use
> > the boot.ci function to produce confidence intervals (non-parametric)
> > for some simple statistics, and this requires first creating a "boot"
> > object. The boot object, in turn, requires a statistic that takes two
> > inputs: the data and the second a vector of indices, frequencies, or
> > weights which "define" the bootstrap. My question, I guess, is which
> > option do I choose to "define" an ordinary sample-with-replacement? And
> > where does this vector come from? Suppose I want to bootstrap a
> > confidence interval for the mean. Do i have to write my own "mean"
> > function to provide for this defining vector of indices?
> >
> > Just to clarify, I want to use the boot command to replicate this:
> > bstraps <- c()
> > for (i in 1:R){
> > bstraps <- c(mean(sample(data,replace=T,n=length(data))), bstraps)}
>
> Following the example in Venables & Ripley for the median:
>
> data.boot <- boot(data, function(x, i) mean(x[i]), R=R)
> boot.ci(data.boot, more options)
>
> Pretty simple, I think, Frank?
>
> --
> Brian D. Ripley, ripley at stats.ox.ac.uk
> Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
> University of Oxford, Tel: +44 1865 272861 (self)
> 1 South Parks Road, +44 1865 272860 (secr)
> Oxford OX1 3TG, UK Fax: +44 1865 272595
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
--
Frank E Harrell Jr Prof. of Biostatistics & Statistics
Div. of Biostatistics & Epidem. Dept. of Health Evaluation Sciences
U. Virginia School of Medicine http://hesweb1.med.virginia.edu/biostat
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list