View source: R/family.univariate.R
rdiric | R Documentation |
Generates Dirichlet random variates.
rdiric(n, shape, dimension = NULL, is.matrix.shape = FALSE)
n |
number of observations.
Note it has two meanings, see |
shape |
the shape parameters. These must be positive.
If |
dimension |
the dimension of the distribution.
If |
is.matrix.shape |
Logical.
If |
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.
A n
by dimension
matrix of Dirichlet random variates.
Each element is positive, and each row will sum to unity.
If shape
has names then these will become the column names
of the answer.
Thomas W. Yee
Lange, K. (2002). Mathematical and Statistical Methods for Genetic Analysis, 2nd ed. New York: Springer-Verlag.
dirichlet
is a VGAM family function for
fitting a Dirichlet distribution to data.
ddata <- data.frame(rdiric(n = 1000, shape = c(y1 = 3, y2 = 1, y3 = 4)))
fit <- vglm(cbind(y1, y2, y3) ~ 1, dirichlet, data = ddata, trace = TRUE)
Coef(fit)
coef(fit, matrix = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.