ddirmult: Density of the Dirichlet-Multinomial Distribution

View source: R/ddirmult.R

ddirmultR Documentation

Density of the Dirichlet-Multinomial Distribution

Description

Density function for the Dirichlet-multinomial distribution.

Usage

ddirmult(x, p, theta, alpha, log = FALSE)

Arguments

x

Numeric vector or matrix of counts. If matrix, then a vector of probability densities is returned with an element for each record of the matrix. Matrix records represent observations, and matrix fields represent dimensions.

p

Numeric vector or matrix of proportions. Matrix records represent observations, and matrix fields represent dimensions. If vector, then p is recycled for each record of matrix x.

theta

Numeric vector. Precision parameter with domain (-Inf, Inf). If scalar, then theta is recycled for each record of matrix x.

alpha

Numeric vector or matrix of conventional alpha values. Matrix records represent observations, and matrix fields represent dimensions. If vector, then alpha is recycled for each record of matrix x.

log

Logical scalar. If TRUE, then probabilities are given as log(density).

Details

Computes the probability mass of the Dirichlet-multinomial distribution. Under the proportion parameterization, the alpha parameters of the conventional Dirichlet-multinomial distribution are derived as the product of a proportion vector (p) and an exponentiated precision parameter (exp(theta)). The precision parameter controls the degree of overdispersion relative to the multinomial distribution, where higher values of theta are associated with reduced overdispersion. When theta = 0, the alpha parameters of the conventional Dirichlet-multinomial distribution are equal to the proportion vector (p). To ensure a simplex, the values of p (vector or matrix records) are internally normalized to sum to one. If alpha is provided, then the conventional alpha parameterization of the Dirichlet-multinomial distribution is used.

Value

Numeric vector of probability densities.

References

Minka TP. 2000. Estimating a Dirichlet distribution.

See Also

waic for generic function to compute widely applicable information criterion.

dmWAIC for computing widely applicable information criteria for Dirichlet-multinomial regression models.

Examples

# Compute log probability density.
ddirmult(x=c(33,115,95,359),
         p=c(0.075,0.201,0.175,0.549),
         theta=4.027,log=TRUE)

LocaTT documentation built on June 14, 2026, 1:06 a.m.