rqbinom: 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)
Value
a data.frame with two columns (succ, fail)
Arguments
n
defines the number of clusters (\(i\))
size
integer vector defining the number of trials per cluster (\(n_i\))
prob
probability of success on each trial (\(\pi\))
phi
dispersion parameter (\(\Phi\))
Details
It is assumed that the dispersion parameter (\(\Phi\))
is constant for all \(i=1, ... I\) clusters, such that the variance becomes
$$var(y_i)=\Phi n_i \pi (1-\pi).$$
For the sampling \((a+b)_i\) is defined as
$$(a+b)_i=(\Phi-n_i)/(1-\Phi)$$
where \(a_i=\pi (a+b)_i\) and \(b_i=(a+b)_i-a_i\). Then, the binomial proportions
for each cluster are sampled from the beta distribution
$$\pi_i \sim Beta(a_i, b_i)$$
and the numbers of success for each cluster are sampled to be
$$y_i \sim Bin(n_i, \pi_i).$$
In this parametrization \(E(\pi_i)=\pi\) and \(E(y_i)=n_i \pi\).
Please note, the quasi-binomial assumption is not in contradiction with
the beta-binomial distribution if all cluster sizes are the same.