On Wed, 17 Dec 2003, Brandon Vaughn wrote:

> Thanks to everyone who wrote in with suggestions.  I will check out the
> books mentioned.
> 
> The book I mentioned "Resampling: The New Statistics" is actually available
> free online at:
> 
> http://www.resample.com/content/text/index.shtml
> 
> It seems pretty good as an introduction.  But then again, I am new at this
> concept.

An introduction to what?  (It seems to confuse resampling and
simulation-based inference.)

> Does anyone know right off hand how to do simple simulation with R?  Like
> for instance, in the book mentioned above, there is an example of figuring
> out the probability that a company with 20 trucks with have 4 or more fail
> on a given day (the probability that any given truck fails is .10).  So the
> way they do it is to simulate uniform numbers from 1 to 10, and let the
> number 1 represent a defective truck.  So here is the setup in the program
> Resampling Stat:
> 
>       REPEAT 400   [repeat simulation 400 times]
>       GENERATE 20 1,10 a      [generate 20 numbers between 1 and 10; store
> in vector a]
>       COUNT a = 1 b   [count the number of 1's and store in vector b]
>       SCORE b z       [keep track of each trial in vector z]
>       END     [repeat process]
>       COUNT z > 3 k   [count the number of times trials more than 3 and
> store]
>       DIVIDE k 400 kk [convert to probability and store]
>       PRINT kk        [print result]
> 
> This seems like a simple problem, and seemingly simple process in Resampling
> Stats.  Any idea on how to get started doing this in R?

However, the number of failures is a binomial variate, so it is much 
simpler in R, for example

cnts <- rbinom(400, 20, 0.1)
mean(cnts >= 4)

However, doing 1 million runs was almost instantaneous on my machine.

And the expected answer is pbinom(3, 20, 0.1, lower=FALSE)

As a matter of terminology, this is not resampling as usually defined, so 
I do wonder exactly what it is you are after.  For resampling in the usual 
sense, I would echo Jason's recommendation of Davison and Hinkley's CUP 
book.

-- 
Brian D. Ripley,                  [EMAIL PROTECTED]
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 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to