zinb.loglik: Log-likelihood of the zero-inflated negative binomial model

View source: R/zinb_fit.R

zinb.loglikR Documentation

Log-likelihood of the zero-inflated negative binomial model

Description

Given a vector of counts, this function computes the sum of the log-probabilities of the counts under a zero-inflated negative binomial (ZINB) model. For each count, the ZINB distribution is parametrized by three parameters: the mean value and the dispersion of the negative binomial distribution, and the probability of the zero component.

Usage

zinb.loglik(Y, mu, theta, logitPi)

Arguments

Y

the vector of counts

mu

the vector of mean parameters of the negative binomial

theta

the vector of dispersion parameters of the negative binomial, or a single scalar is also possible if the dispersion parameter is constant. Note that theta is sometimes called inverse dispersion parameter (and phi=1/theta is then called the dispersion parameter). We follow the convention that the variance of the NB variable with mean mu and dispersion theta is mu + mu^2/theta.

logitPi

the vector of logit of the probabilities of the zero component

Value

the log-likelihood of the model.

Examples

n <- 10
mu <- seq(10,50,length.out=n)
logitPi <- rnorm(10)
zeta <- rnorm(10)
Y <- rnbinom(n=n, size=exp(zeta), mu=mu)
zinb.loglik(Y, mu, exp(zeta), logitPi)
zinb.loglik(Y, mu, 1, logitPi)

drisso/zinbwave documentation built on March 18, 2024, 5:13 p.m.