rnbinom() samples negative-binomial data.
The following description of the sampling process is based on the parametrization
used by Gsteiger et al. 2013.
Usage
rnbinom(n, lambda, kappa, offset = NULL)
Value
rnbinom() returns a data.frame with two columns:
y as the observations and offset as the number of offsets per
observation.
Arguments
n
defines the number of clusters (\(I\))
lambda
defines the overall Poisson mean (\(\lambda\))
kappa
dispersion parameter (\(\kappa\))
offset
defines the number of experimental units per cluster (\(n_i\))
Details
The variance of the negative-binomial distribution is
$$var(Y_i) = n_i \lambda (1+ \kappa n_i \lambda).$$
Negative-biomial observations can be sampled based on predefined values of \(\kappa\),
\(\lambda\) and \(n_i\):
Define the parameters of the gamma distribution as \(a=\frac{1}{\kappa}\) and
\(b_i=\frac{1}{\kappa n_i \lambda}\). Then, sample the Poisson means for each cluster
$$\lambda_i \sim Gamma(a, b_i).$$
Finally, the observations \(y_i\) are sampled from the Poisson distribution
$$y_i \sim Pois(\lambda_i)$$
References
Gsteiger, S., Neuenschwander, B., Mercier, F. and Schmidli, H. (2013):
Using historical control information for the design and analysis of clinical
trials with overdispersed count data. Statistics in Medicine, 32: 3609-3622.
tools:::Rd_expr_doi("10.1002/sim.5851")