Learn R Programming

VGAM (version 0.9-0)

rdiric: The Dirichlet distribution

Description

Generates Dirichlet random variates.

Usage

rdiric(n, shape, dimension = NULL)

Arguments

n
number of observations.
shape
the shape parameters. These must be positive. If dimension is specifed, values are recycled if necessary to length dimension.
dimension
the dimension of the distribution. If dimension is not numeric then it is taken to be length(shape).

Value

  • A n by dimension matrix of Dirichlet random variates. Each element is positive, and each row will sum to unity.

Details

This function is based on a relationship between the gamma and Dirichlet distribution. Random gamma variates are generated, and then Dirichlet random variates are formed from these.

References

Lange, K. (2002) Mathematical and Statistical Methods for Genetic Analysis, 2nd ed. New York: Springer-Verlag.

See Also

dirichlet is a VGAM family function for fitting a Dirichlet distribution to data.

Examples

Run this code
y <- rdiric(n = 1000, shape = c(3, 1, 4))
fit <- vglm(y ~ 1, dirichlet, trace = TRUE, crit = "c")
Coef(fit)
coef(fit, matrix = TRUE)

Run the code above in your browser using DataLab