rbbinom {predint} | R Documentation |
Sampling of beta-binomial data
Description
rbbinom()
samples beta-binomial data according to Menssen and Schaarschmidt (2019).
Usage
rbbinom(n, size, prob, rho)
Arguments
n |
defines the number of clusters ( |
size |
integer vector defining the number of trials per cluster ( |
prob |
probability of success on each trial ( |
rho |
intra class correlation ( |
Details
For beta binomial data with clusters, the variance is
with as the intra class correlation coefficient
For the sampling is defined as
where and
. Then, the binomial proportions
for each cluster are sampled from the beta distribution
and the number of successes for each cluster are sampled to be
In this parametrization and
.
Please note, that
is a constant if all cluster sizes are
the same and hence, in this special case, also the quasi-binomial assumption is
fulfilled.
Value
a data.frame
with two columns (succ, fail)
References
Menssen M, Schaarschmidt F.: Prediction intervals for overdispersed binomial data with application to historical controls. Statistics in Medicine. 2019;38:2652-2663. doi:10.1002/sim.8124
Examples
# Sampling of example data
set.seed(234)
bb_dat1 <- rbbinom(n=10, size=50, prob=0.1, rho=0.06)
bb_dat1
set.seed(234)
bb_dat2 <- rbbinom(n=3, size=c(40, 50, 60), prob=0.1, rho=0.06)
bb_dat2