Learn R Programming

hyperdirichlet (version 1.4-2)

hyperdirichlet-package: The Hyperdirichlet package

Description

A generalization of the Dirichlet distribution

Arguments

Details

ll{ Package: hyperdirichlet Type: Package Version: 1.1-8 Date: 2008-03-26 License: GPL }

This package provides a generalization of the Dirichlet distribution that is useful for analyzing multinomial trials with a priori restrictions.

As an example, consider six people (players), numbered 1 to 6. These players are members of a running club and regularly race one another.

Each player has an associated number $p_1$ to $p_6$, with $0\leq p_i\leq 1$ for $i=1,\ldots,6$ and $\sum_{i=1}^6 p_i=1$. If all six take part in a race, then the probability that player $i$ wins is simply $p_i$.

We wish to make inferences about the $p_i$ from their performances.

If all six race and $p_i$ wins $n_i$, then the likelihood function is just

$${p_1}^{n_1}\cdot{p_2}^{n_2}\cdot{p_3}^{n_3}\cdot{p_4}^{n_4}\cdot{p_5}^{n_5}\cdot{p_6}^{n_6}.$$

With a uniform prior, the posterior is Dirichlet.

The players now have a race but only $p_1$, $p_2$ and $p_3$ take place, winning $r_1$, $r_2$ and $r_3$ respectively. The likelihood function is then

$$\frac{ {p_1}^{n_1+r_1}\cdot{p_2}^{n_2+r_2}\cdot{p_3}^{n_3+r_3}\cdot{p_4}^{n_4}\cdot{p_5}^{n_5}\cdot{p_6}^{n_6} }{ \left(p_1+p_2+p_3\right)^{r_1+r_2+r_3 } }$$

This distribution is not a Dirichlet distribution but is representable in this package; the R idiom would be

jj <- dirichlet(powers = c(5,4,3,5,3,2)) jj <- jj + mult_restricted_obs(6, 1:3, c(4,5,2))

where the first line specifies a Dirichlet distribution for the all-play data and the second line augments the likelihood with the observations from the restricted race.

References

Robin K. S. Hankin (2010). A Generalization of the Dirichlet Distribution, Journal of Statistical Software, 33(11), 1-18, http://www.jstatsoft.org/v33/i11/

Examples

Run this code
jj <- dirichlet(powers = c(5,4,3,5,3,2))
  jj <- jj + mult_restricted_obs(6, 1:3, c(4,5,2))

data(icons)
maximum_likelihood(as.hyperdirichlet(icons))

Run the code above in your browser using DataLab