rqbinom {predint} | R Documentation |
Sampling of overdispersed binomial data with constant overdispersion
Description
rqbinom samples overdispersed binomial data with constant overdispersion from the beta-binomial distribution such that the quasi-binomial assumption is fulfilled.
Usage
rqbinom(n, size, prob, phi)
Arguments
n |
defines the number of clusters ( |
size |
integer vector defining the number of trials per cluster ( |
prob |
probability of success on each trial ( |
phi |
dispersion parameter ( |
Details
It is assumed that the dispersion parameter ()
is constant for all
clusters, such that the variance becomes
For the sampling is defined as
where and
. Then, the binomial proportions
for each cluster are sampled from the beta distribution
and the numbers of success for each cluster are sampled to be
In this parametrization and
.
Please note, the quasi-binomial assumption is not in contradiction with
the beta-binomial distribution if all cluster sizes are the same.
Value
a data.frame
with two columns (succ, fail)
Examples
# Sampling of example data
set.seed(456)
qb_dat1 <- rqbinom(n=10, size=50, prob=0.1, phi=3)
qb_dat1
set.seed(456)
qb_dat2 <- rqbinom(n=3, size=c(40, 50, 60), prob=0.1, phi=3)
qb_dat2