Dir | R Documentation |
The Dirichlet distribution is an absolute continuous probability,
specifically a multivariate generalization of the beta distribution,
parameterized by a vector \boldsymbol{\alpha} =
(\alpha_1, \alpha_2, ..., \alpha_k)
with \alpha_i > 0
.
Dir(alpha = c(1, 1))
ddir(x, alpha, log = FALSE)
rdir(n, alpha)
## S4 method for signature 'Dir,numeric'
d(distr, x, log = FALSE)
## S4 method for signature 'Dir,matrix'
d(distr, x)
## S4 method for signature 'Dir,numeric'
r(distr, n)
## S4 method for signature 'Dir'
mean(x)
## S4 method for signature 'Dir'
mode(x)
## S4 method for signature 'Dir'
var(x)
## S4 method for signature 'Dir'
entro(x)
## S4 method for signature 'Dir'
finf(x)
lldir(x, alpha)
## S4 method for signature 'Dir,matrix'
ll(distr, x)
edir(x, type = "mle", ...)
## S4 method for signature 'Dir,matrix'
mle(
distr,
x,
par0 = "same",
method = "L-BFGS-B",
lower = 1e-05,
upper = Inf,
na.rm = FALSE
)
## S4 method for signature 'Dir,matrix'
me(distr, x, na.rm = FALSE)
## S4 method for signature 'Dir,matrix'
same(distr, x, na.rm = FALSE)
vdir(alpha, type = "mle")
## S4 method for signature 'Dir'
avar_mle(distr)
## S4 method for signature 'Dir'
avar_me(distr)
## S4 method for signature 'Dir'
avar_same(distr)
alpha |
numeric. The non-negative distribution parameter vector. |
x |
For the density function, |
log |
logical. Should the logarithm of the probability be returned? |
n |
number of observations. If |
distr |
an object of class |
type |
character, case ignored. The estimator type (mle, me, or same). |
... |
extra arguments. |
par0 , method , lower , upper |
arguments passed to optim for the mle optimization. |
na.rm |
logical. Should the |
The probability density function (PDF) of the Dirichlet distribution is given by:
f(x_1, ..., x_k; \alpha_1, ..., \alpha_k) =
\frac{1}{B(\boldsymbol{\alpha})} \prod_{i=1}^k x_i^{\alpha_i - 1},
where B(\boldsymbol{\alpha})
is the multivariate Beta function:
B(\boldsymbol{\alpha}) = \frac{\prod_{i=1}^k
\Gamma(\alpha_i)}{\Gamma\left(\sum_{i=1}^k \alpha_i\right)}
and \sum_{i=1}^k x_i = 1
, x_i > 0
.
Each type of function returns a different type of object:
Distribution Functions: When supplied with one argument (distr
), the
d()
, p()
, q()
, r()
, ll()
functions return the density, cumulative
probability, quantile, random sample generator, and log-likelihood functions,
respectively. When supplied with both arguments (distr
and x
), they
evaluate the aforementioned functions directly.
Moments: Returns a numeric, either vector or matrix depending on the moment
and the distribution. The moments()
function returns a list with all the
available methods.
Estimation: Returns a list, the estimators of the unknown parameters. Note that in distribution families like the binomial, multinomial, and negative binomial, the size is not returned, since it is considered known.
Variance: Returns a named matrix. The asymptotic covariance matrix of the estimator.
Oikonomidis, I. & Trevezas, S. (2025), Moment-Type Estimators for the Dirichlet and the Multivariate Gamma Distributions, arXiv, https://arxiv.org/abs/2311.15025
# -----------------------------------------------------
# Dir Distribution Example
# -----------------------------------------------------
# Create the distribution
a <- c(0.5, 2, 5)
D <- Dir(a)
# ------------------
# dpqr Functions
# ------------------
d(D, c(0.3, 0.2, 0.5)) # density function
x <- r(D, 100) # random generator function
# alternative way to use the function
df <- d(D) ; df(x) # df is a function itself
# ------------------
# Moments
# ------------------
mean(D) # Expectation
mode(D) # Mode
var(D) # Variance
entro(D) # Entropy
finf(D) # Fisher Information Matrix
# List of all available moments
mom <- moments(D)
mom$mean # expectation
# ------------------
# Point Estimation
# ------------------
ll(D, x)
lldir(x, a)
edir(x, type = "mle")
edir(x, type = "me")
mle(D, x)
me(D, x)
e(D, x, type = "mle")
mle("dir", x) # the distr argument can be a character
# ------------------
# Estimator Variance
# ------------------
vdir(a, type = "mle")
vdir(a, type = "me")
avar_mle(D)
avar_me(D)
v(D, type = "mle")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.