BB: The Beta-Binomial Distribution

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Density and random generation for the beta-binomial distribution.

Usage

1
2
dBB(y,n,p,phi)
rBB(k,n,p,phi)

Arguments

n

the maximum score of the beta-binomial trials.

k

the number of simulations.

y

the number of successes in n beta-binomial trials.

p

the probabilily parameter of the beta-binomial distribution.

phi

the dispersion parameter of the beta-binomial distribution.

Details

The beta-binomial distribution is defined as a mixture between a binomial distribution and a beta distribution. It assumes that conditioned on some random components θ, with beta distribution with parameters p/φ and p/(1-φ), the response variable y follows a binomial distribution with probability parameter θ,

y|θ \sim Bin(n,θ), θ \sim Beta(p/φ,(1-p)/φ).

The expectation, variance and density function of this distribution can be explicitly calculated:

E[y]=np,

Var[y]=np(1-p)[1+(n-1)φ/(1+φ)].

Consequently, p is called the probability parameter and φ is called the dispersion parameter of the beta-binomial distribution. Hence, the response variable y follows a beta-binomial distribution of parameters n, p and φ,

y \sim BB(n,p,φ).

Value

dBB gives the density of a beta-binomial distribution with the defined n, p and phi parameters.

rBB generates k random observations based on a beta-binomial distribution with the defined n, p and phi parameters.

Author(s)

Josu Najera-Zuloaga

Dae-Jin Lee

References

Arostegui I., Nuñez-Antón V. & Quintana J. M. (2006): Analysis of short-form-36 (SF-36): The beta-binomial distribution approach, Statistics in Medicine, 26, 1318-1342.

See Also

The rbeta and rbinom functions of package <stats>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
set.seed(12)
# We define
n <- 10     #maximum number of scores in the binomial trials
p <- 0.4    #probability parameter of the beta-binomial distribution
phi <- 1.8  #dispersion parameter of the beta-binomial distribution

# We perform k beta-binomial simulations for those parameters.
k <- 100
bb <- rBB(k,n,p,phi)

# Plot the histogram of the created variable,
# dBB() function fits beta-binomial distribution:
hist(bb,col="grey",breaks=seq(-0.5,n+0.5,1),probability=TRUE,main="Histogram",xlab="beta-binomial random variable")
lines(c(0:n),dBB(0:n,n,p,phi),col="red",lwd=4)

idaejin/HRQoL documentation built on May 18, 2019, 2:32 a.m.