Skip to contents

The function MLE_dirichlet performs a maximum-likelihood estimation of the \(\alpha\) parameter of a Dirichlet distribution for a given sample of probability vectors.

Usage

MLE_dirichlet(probs, alpha0 = rep(1, ncol(probs)))

Arguments

probs

a matrix with N rows representing observations of probability vectors and K columns representing the classes. Therefore, values of each row should sum to 1.

alpha0

vector of K=ncol(probs) values as starting parameter for the optimization. Values have to be greater 0.

Value

Returns a numeric vector of length K=ncol(probs) representing the \(\alpha\) of the Dirichlet distribution.

Details

The density of the Dirichlet distribution for \(\alpha = (\alpha_1, ..., \alpha_K )\) and \(\alpha_i > 0 \forall i=1,...,K\) is given by $$f(p|\alpha)=\frac{1}{B(\alpha)} \prod_{i=1}{K} p_{i}^{\alpha_i - 1},$$ if \(0\leq p_i \leq 1 \forall i = 1,...,K\) and \(\sum_{i=1}^{K} p_i ) 1\), and \(f(p|\alpha) = 0\), else.

The function optimizes the log-likelihood of a sample of probability vectors given in probs using the function optim and a Nelder-Mead algorithm.

Author

Sebastian Hellmann.

Examples

probs <- matrix(c(0.2, 0.4, 0.2, 0.4, 0, 0.2, 0.4, 0.4, 0.6, 0.2, 0.2,
                  0.4, 0.4, 0.2, 0.2, 0.4, 0.8, 0.4), ncol=3)
MLE_dirichlet(probs)
#> [1] 0.008449577 0.867905274 0.891974546