On Wed, 15 Jul 2009, Shinichi Nakagawa wrote:
Dear R users
I would like to simulate underdispersed Poisson and binomial distributions
somehow.
I know you can do this for overdispersed counterparts - using rnbinom() for
Poisson and rbetabinom() for binomial.
Could anyone share functions to do this? Or please share some tips for
modifying existing functions to achieve this.
Shinichi,
You really need a model for the underdispersion. Using that model, you
would calculate the probabiltities fo the binomial or Poisson counts.
But you have to come up with something appropriate for your situation.
For example,
probs <- prop.table( dbinom( 0:10, 10, .5)^3 )
or
probs <- prop.table( dbinom( 0:10, 10, .5) +
ifelse( 0:10 == 5, 1, 0) )
will each produce probabilities for counts that are less dispersed than
probs <- dbinom( 0:10, 10, 0.5 )
but neither may suitably model the counts for the situation in which you
are interested.
---
Once you have that model in hand
sample( 0:10, N, pr=probs, repl=TRUE )
will 'simulate' N such counts.
HTH,
Chuck
Thank you very much for your help and time
Shinichi
____________________
Shinichi Nakagawa, PhD
(Lecturer of Behavioural Ecology)
Department of Zoology
University of Otago
340 Great King Street
P. O. Box 56
Dunedin, New Zealand
Tel: +64-3-479-5046
Fax: +64-3-479-7584
http://www.otago.ac.nz/zoology/staff/academic/nakagawa.html
______________________________________________
R-help@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.
Charles C. Berry (858) 534-2098
Dept of Family/Preventive Medicine
E mailto:cbe...@tajo.ucsd.edu UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901
______________________________________________
R-help@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.