Negative log-likelihood for BNB
nll_bnb.RdThe negative log-likelihood for bivariate negative binomial outcomes.
Arguments
- param
(numeric:
(0, Inf))
A vector of BNB parameters. Must be in the following order for each scenario:Null:
c(mean, dispersion)Alternative:
c(mean1, mean2, dispersion)
for samples 1 and 2.
- value1
(integer:
(0, Inf))
The vector of BNB values from sample 1. Must be sorted by the subject/item index. Must not contain NAs.- value2
(integer:
(0, Inf))
The vector of BNB values from sample 2. Must be sorted by the subject/item index. Must not contain NAs.- ratio_null
(Scalar numeric:
(0, Inf))
The ratio of means assumed under the null hypothesis (sample 2 / sample 1). Typicallyratio_null = 1(no difference).
Details
These functions are primarily designed for speed in simulation. Limited argument validation is performed.
Suppose \(X_1 \mid G = g \sim \text{Poisson}(\mu g)\) and \(X_2 \mid G = g \sim \text{Poisson}(r \mu g)\) where \(G \sim \text{Gamma}(\theta, \theta^{-1})\) is the random item (subject) effect. Then \(X_1, X_2 \sim \text{BNB}(\mu, r, \theta)\) is the joint distribution where \(X_1\) and \(X_2\) are dependent (though conditionally independent), \(X_1\) is the count outcome for sample 1 of the items (subjects), \(X_2\) is the count outcome for sample 2 of the items (subjects), \(\mu\) is the conditional mean of sample 1, \(r\) is the ratio of the conditional means of sample 2 with respect to sample 1, and \(\theta\) is the gamma distribution shape parameter which controls the dispersion and the correlation between sample 1 and 2.
The likelihood is
$$ \begin{aligned} L(r, \mu, \theta \mid X_1, X_2) = & \left( \frac{\theta^{\theta}}{\Gamma(\theta)} \right)^{n} \times \\ & \frac{\mu^{\sum{x_{1i}} + \sum{x_{2i}}}}{\prod_{i=1}^{n} x_{1i}!} \frac{r^{\sum{x_{2i}}}}{\prod_{i=1}^{n} x_{2i}!} \times \\ & \frac{\prod_{i = 1}^{n} \Gamma(x_{1i} + x_{2i} + \theta)}{(\mu + r \mu + \theta)^{\sum (x_{1i} + x_{2i} + \theta)}} \end{aligned} $$
and the parameter space is \(\Theta = \left\{ (r, \mu, \theta) : r, \mu, \theta > 0 \right\}\). The log-likelihood is
$$ \begin{aligned} l(r, \mu, \theta) = \ & n \left[ \theta \ln \theta - \ln \Gamma(\theta) \right] + \\ & n (\bar{x}_1 + \bar{x}_2) \ln(\mu) + n \bar{x}_2 \ln r + \\ & \sum_{i=1}^{n}{\ln \Gamma(x_{1i} + x_{2i} + \theta)} - \\ & n (\bar{x}_1 + \bar{x}_2 + \theta) \ln(\mu + r\mu + \theta) - \\ & \sum_{i = 1}^{n}{\ln x_{1i}!} - \sum_{i = 1}^{n}{\ln x_{2i}!} \end{aligned} $$
References
Rettiganti M, Nagaraja HN (2012). “Power Analyses for Negative Binomial Models with Application to Multiple Sclerosis Clinical Trials.” Journal of Biopharmaceutical Statistics, 22(2), 237–259. ISSN 1054-3406, 1520-5711, doi:10.1080/10543406.2010.528105 .
Aban IB, Cutter GR, Mavinga N (2009). “Inferences and power analysis concerning two negative binomial distributions with an application to MRI lesion counts data.” Computational Statistics & Data Analysis, 53(3), 820–833. ISSN 01679473, doi:10.1016/j.csda.2008.07.034 .
Examples
#----------------------------------------------------------------------------
# nll_bnb*() examples
#----------------------------------------------------------------------------
library(depower)
set.seed(1234)
d <- sim_bnb(
n = 40,
mean1 = 10,
ratio = 1.2,
dispersion = 2
)
nll_bnb_alt(
param = c(mean1 = 10, mean2 = 12, dispersion = 2),
value1 = d[[1L]],
value2 = d[[2L]]
)
#> [1] 242.4529
nll_bnb_null(
param = c(mean = 10, dispersion = 2),
value1 = d[[1L]],
value2 = d[[2L]],
ratio_null = 1
)
#> [1] 247.0826