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 (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.

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



[Package predint version 2.2.1 Index]