Learn R Programming

hyper2 (version 3.2)

dirichlet: Dirichlet distribution and generalizations

Description

The Dirichlet distribution in likelihood (for p) form, including the generalized Dirichlet distribution due to Connor and Mosimann

Usage

dirichlet(powers, alpha)
dirichlet3(powers, lambda=NULL)
GD(alpha, beta, beta0=0)
GD_wong(alpha, beta)
rdirichlet(n,H)
is.dirichlet(H)
rp_unif(n,H)

Arguments

powers

In function dirichlet() a (named) vector of powers

alpha,beta

A vector of parameters for the Dirichlet or generalized Dirichlet distribution

beta0

In function GD(), an arbitrary parameter

H

Object of class hyper2

lambda

Vector of weights in dirichlet3()

n

Number of observations

Author

Robin K. S. Hankin

Details

These functions are really convenience functions.

Function rdirichlet() returns random samples drawn from a Dirichlet distribution using the gamma distribution. If second argument H is a hyper2 object, it is tested [with is.dirichlet()] for being a Dirichlet distribution. If so, samples from it are returned. If not, (e.g. icons), an error is given. If H is not a hyper2 object, it is interpreted as a (possibly named) vector of parameters \(\alpha\) [not a vector of powers].

Function rp_unif() returns uniformly distributed vectors, effectively using H*0; but note that this uses Dirichlet sampling which is much faster and better than the Metropolis-Hastings functionality documented at rp.Rd.

Functions GD() and GD_wong() return a likelihood function corresponding to the Generalized Dirichlet distribution as presented by Connor and Mosimann, and Wong, respectively. In GD_wong(), alpha and beta must be named vectors; the names of alpha give the names of \(x_1,\ldots,x_k\) and the last element of beta gives the name of \(x_{k+1}\).

Function dirichlet3() returns a hyper3 object with weights lambda. If lambda is length less than that of powers, it is padded with 1s [so default NULL corresponds to unit weights, that is, a hyper2 object]. A use-case is given in inst/rock_paper_scissors_monster.Rmd.

References

  • R. J. Connor and J. E. Mosimann 1969. “Concepts of independence for proportions with a generalization of the Dirichlet distribution”. Journal of the American Statistical Association, 64:194--206

  • T.-T. Wong 1998. “Generalized Dirichlet distribution in Bayesian Analysis”. Applied Mathematics and Computation, 97:165--181

See Also

hyper2,rp

Examples

Run this code

x1 <- dirichlet(c(a=1,b=2,c=3))
x2 <- dirichlet(c(c=3,d=4))

x1+x2

H <- dirichlet(c(a=1,b=2,c=3,d=4))
rdirichlet(10,H)
colMeans(rdirichlet(1e4,H))

dirichlet3(c(fish=3,chips=2),lambda=1.8)
dirichlet3(c(x=6,y=5,z=2),1:3)

Run the code above in your browser using DataLab