cmm | R Documentation |
Functions for the \textrm{CMM}_k(m, \bm{p}, ν) distribution.
d_cmm(x, p, nu, take_log = FALSE, normalize = TRUE) normconst_cmm(m, p, nu, take_log = FALSE) r_cmm(n, m, p, nu, burn = 0, thin = 1, x_init = NULL, report_period = NULL) e_cmm(m, p, nu) v_cmm(m, p, nu)
x |
A eqnk-dimensional vector representing the outcome. |
p |
Probability parameter; a vector of positive numbers which sums to 1. |
nu |
Dispersion parameter. |
take_log |
|
normalize |
|
m |
Number of trials in the CMB cluster. |
n |
Number of draws to produce. |
burn |
Number of initial draws to burn for Gibbs sampler. |
thin |
Thinning interval for Gibbs sampler. A value of |
x_init |
Initial value for Gibbs sampler. If |
report_period |
How often to output progress for Gibbs sampler. A value of
|
Let Ω_{m,k} denote the multinomial sample space based on m trials and k categories. A random variable \bm{X} \sim \textrm{CMM}_k(m, \bm{p}, ν) has probability mass function
f(\bm{x} \mid m, \bm{p}, ν) = C(m, \bm{p}, ν)^{-1} {m \choose x_1 \cdots x_k}^ν p_1^{x_1} \cdots p_k^{x_k}, \quad \bm{x} \in Ω_{m,k}
with
C(m, \bm{p}, ν) = ∑_{\bm{x} \in Ω_{m,k}} {m \choose x_1 \cdots x_k}^ν p_1^{x_1} \cdots p_k^{x_k}
as the normalizing constant.
This package computes CMM density values in C++ to improve the performance of iterating over the sample space. A Gibbs sampler is used to draw samples from CMM. Further details can be found in Morris, Raim, and Sellers (2020+).
The values returned by each function are:
d_cmm
: the CMM density f(\bm{x} \mid m, \bm{p}, ν),
where m is assumed to be sum(x)
.
r_cmm
: an n \times k matrix of draws.
normconst_cmm
: a number representing the normalizing constant C(m, \bm{p}, ν).
e_cmm
: a k-dimensional vector representing \textrm{E}(\bm{X}).
v_cmm
: a k \times k matrix representing \textrm{Var}(\bm{X})
set.seed(1234) m = 10 p = c(0.1,0.1,0.8) nu = 0.8 x = r_cmm(100, m, p, nu, burn = 1000, thin = 10) d_cmm(x[1,], p, nu, take_log = TRUE) normconst_cmm(m, p, nu, take_log = TRUE) e_cmm(m, p, nu) v_cmm(m, p, nu)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.