Description Usage Arguments Details Value Author(s) References See Also Examples
Density and random generation for the beta-binomial distribution.
1 2 |
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. |
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,φ).
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.
Josu Najera-Zuloaga
Dae-Jin Lee
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.
The rbeta
and rbinom
functions of package <stats>
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.