BI | R Documentation |
Density and random generation for the binomial distribution with optional dispersion parameter.
dBI(m,p,phi)
rBI(k,m,p,phi)
k |
number of simulations. |
m |
number of trials in each binomial observation. |
p |
probability parameter of the binomial distribution. |
phi |
dispersion parameter of the binomial distribution. If |
The binomial distribution belongs to the exponential family of distributions. Consequenlty, although the usual binomial distribution only consists of two paramters, an additional dispersion parameter can be included. The inclusion of a dispersion parameter softens the relationship between the expectation and variance that the binomial distribution keeps, i.e. the model allows overdispersion to be included,
E[y]=mp, Var[y]=phi*mp(1-p).
The density function of the binomial distribution with dispersion parameter is based on the exponential family approach and it is defined as
f(y)=exp\{[y*log(p/(1-p))+m*log(1-p)]/phi+c(y,phi)\},
where c()
is a function that it is approximated with the deviance of the model by quadratic approximations of the log-likelihood function.
dBI
gives the density of the binomial distribution for those m
, p
and phi
parameters.
rBI
generates k
random observations based on a binomial distribution for those m
, p
and phi
parameters.
J. Najera-Zuloaga
D.-J. Lee
I. Arostegui
Pawitan Y. (2001): In All Likelihood: Statistical Modelling and Inference Using Likelihood. Oxford University Press
The rbinom
functions of package stats
. This function performs simulations based on a binomial distribution without dispersion parameter.
k <- 1000
m <- 10
p <- 0.765
phi <- 4.35
#simulating
y <- rBI(k,m,p,phi)
y
#density function
d <- dBI(m,p,phi)
d
#plot the simulated variable and fit the density
hist(y,col="lightgrey")
lines(seq(0,m),k*d,col="blue",lwd=2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.