Description Usage Arguments Details Value Examples
rgdirmn
generates random observations from the generalized Dirichlet multinomial distribution.
dgdirmn
computes the log of the generalized Dirichlet multinomial probability mass function.
1 2 3 |
n |
the number of random vectors to generate. When |
size |
a number or vector specifying the total number of objects that are put into d categories in the generalized Dirichlet multinomial distribution. |
alpha |
the parameter of the generalized Dirichlet multinomial distribution.
For For |
beta |
the parameter of the generalized Dirichlet multinomial distribution. For |
Y |
the multivariate count matrix with dimensions nxd, where n = 1,2, … is the number of observations and d=3,4,… is the number of categories. |
Y=(y_1, …, y_d) are the d category count vectors. Given the parameter vector α = (α_1, …, α_{d-1}), α_j>0, and β=(β_1, …, β_{d-1}), β_j>0, the generalized Dirichlet multinomial probability mass function is
P(y|α,β) =C_{y_1, …, y_d}^{m} prod_{j=1}^{d-1} {Gamma(α_j+y_j)Gamma(β_j+z_{j+1})Gamma(α_j+β_j)} / {Gamma(α_j)Gamma(β_j)Gamma(α_j+β_j+z_j)},
where z_j = sum_{k=j}^d y_k and m = sum_{j=1}^d y_j. Here, C_k^n, often read as "n choose k", refers the number of k combinations from a set of n elements.
The α and β parameters can be vectors, like the results from the distribution fitting function, or they can be matrices with n rows, like the estimate from the regression function multiplied by the covariate matrix exp(Xα) and exp(Xβ)
dgdirmn
returns the value of
logP(y|α, β).
When Y
is a matrix of n rows, the function dgdirmn
returns a vector of length n.
rgdirmn
returns a nxd matrix of the generated random observations.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # example 1
m <- 20
alpha <- c(0.2, 0.5)
beta <- c(0.7, 0.4)
Y <- rgdirmn(10, m, alpha, beta)
dgdirmn(Y, alpha, beta)
# example 2
set.seed(100)
alpha <- matrix(abs(rnorm(40)), 10, 4)
beta <- matrix(abs(rnorm(40)), 10, 4)
size <- rbinom(10, 10, 0.5)
GDM.rdm <- rgdirmn(size=size, alpha=alpha, beta=beta)
GDM.rdm1 <- rgdirmn(n=20, size=10, alpha=abs(rnorm(4)), beta=abs(rnorm(4)))
|
[1] -4.354867 -3.028577 -4.274337 -2.504931 -5.823664 -4.336512 -2.504931
[8] -3.028577 -5.330571 -4.968572
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.