Dir {joker}R Documentation

Dirichlet Distribution

Description

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.

Usage

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)

Arguments

alpha

numeric. The non-negative distribution parameter vector.

x

For the density function, x is a numeric vector of quantiles. For the moments functions, x is an object of class Dir. For the log-likelihood and the estimation functions, x is the sample of observations.

log

logical. Should the logarithm of the probability be returned?

n

number of observations. If length(n) > 1, the length is taken to be the number required.

distr

an object of class Dir.

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 NA values be removed?

Details

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.

Value

Each type of function returns a different type of object:

References

Examples

# -----------------------------------------------------
# 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")

[Package joker version 0.14.2 Index]