dbetabinom {emdbook} | R Documentation |
Density function and random variate generator for the beta-binomial function, parameterized in terms of probability and overdispersion
dbetabinom(x, prob, size, theta, log = FALSE) rbetabinom(n, prob, size, theta)
x |
a numeric vector of values |
prob |
numeric vector: mean probability of underlying beta distribution |
size |
integer: number of samples |
theta |
overdispersion parameter |
log |
(logical) return log probability density? |
n |
integer number of random variates to return |
The beta-binomial distribution is the result of compounding a beta distribution of probabilities with a binomial sampling process. The density function is ... v <- lchoose(size,x)-lbeta(theta*(1-prob),theta*prob)+lbeta(size-x+theta*(1-prob),x+theta*prob) (alternative parameterization)
A vector of probability densities or random deviates.
Ben Bolker
~put references to the literature/web site here ~
set.seed(100) n <- 9 z <- rbetabinom(1000, 0.5, size=n, theta=4) plot(table(z)/length(z),ylim=c(0,0.34),col="gray",lwd=4) points(0:n,dbinom(0:n,size=n,prob=0.5),col=2,pch=16,type="b") points(0:n,dbetabinom(0:n,size=n,theta=4, prob=0.5),col=3,pch=17,type="b")