cmm: Conway Maxwell Multinomial distribution

cmmR Documentation

Conway Maxwell Multinomial distribution

Description

Functions for the \textrm{CMM}_k(m, \bm{p}, ν) distribution.

Usage

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)

Arguments

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

TRUE or FALSE; if TRUE, return the value on the log-scale.

normalize

TRUE or FALSE; if FALSE, do not compute or apply the normalizing constant to each density value.

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 s means that s iterations of the sampler will be carried out before saving each of the n requested draws.

x_init

Initial value for Gibbs sampler. If NULL, it is set to the extreme point m \bm{e}_{\ell} where \ell = \textrm{argmax}_{j}\{p_j\}.

report_period

How often to output progress for Gibbs sampler. A value of s means that a progress message will be printed every s iterations of the sampler.

Details

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+).

Value

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})

Examples

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)


andrewraim/COMMultReg documentation built on April 2, 2022, 11:04 p.m.