lrt_bnb: Likelihood ratio test for BNB ratio of means

View source: R/lrt_bnb.r

lrt_bnbR Documentation

Likelihood ratio test for BNB ratio of means

Description

Likelihood ratio test for the ratio of means from bivariate negative binomial outcomes.

Usage

lrt_bnb(data, ratio_null = 1, ...)

Arguments

data

(list)
A list whose first element is the vector of negative binomial values from sample 1 and the second element is the vector of negative binomial values from sample 2. Each vector must be sorted by the subject/item index and must be the same sample size. NAs are silently excluded. The default output from sim_bnb().

ratio_null

(Scalar numeric: 1; ⁠(0, Inf)⁠)
The ratio of means assumed under the null hypothesis (sample 2 / sample 1). Typically, ratio_null = 1 (no difference). See 'Details' for additional information.

...

Optional arguments passed to the MLE function mle_bnb().

Details

This function is primarily designed for speed in simulation. Missing values are silently excluded.

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 hypotheses for the LRT of r are

\begin{aligned} H_{null} &: r = r_{null} \\ H_{alt} &: r \neq r_{null} \end{aligned}

where r = \frac{\bar{X}_2}{\bar{X}_1} is the population ratio of arithmetic means for sample 2 with respect to sample 1 and r_{null} is a constant for the assumed null population ratio of means (typically r_{null} = 1).

The LRT statistic is

\begin{aligned} \lambda &= -2 \ln \frac{\text{sup}_{\Theta_{null}} L(r, \mu, \theta)}{\text{sup}_{\Theta} L(r, \mu, \theta)} \\ &= -2 \left[ \ln \text{sup}_{\Theta_{null}} L(r, \mu, \theta) - \ln \text{sup}_{\Theta} L(r, \mu, \theta) \right] \\ &= -2(l(r_{null}, \tilde{\mu}, \tilde{\theta}) - l(\hat{r}, \hat{\mu}, \hat{\theta})) \end{aligned}

Under H_{null}, the LRT test statistic is asymptotically distributed as \chi^2_1. The approximate level \alpha test rejects H_{null} if \lambda \geq \chi^2_1(1 - \alpha). Note that the asymptotic critical value is known to underestimate the exact critical value. Hence, the nominal significance level may not be achieved for small sample sizes (possibly n \leq 10 or n \leq 50).

Value

A list with the following elements:

Slot Subslot Name Description
1 chisq \chi^2 test statistic for the ratio of means.
2 df Degrees of freedom.
3 p p-value.
4 ratio Estimated ratio of means (sample 2 / sample 1).
5 alternative Point estimates under the alternative hypothesis.
5 1 mean1 Estimated mean of sample 1.
5 2 mean2 Estimated mean of sample 2.
5 3 dispersion Estimated dispersion.
6 null Point estimates under the null hypothesis.
6 1 mean1 Estimated mean of sample 1.
6 2 mean2 Estimated mean of sample 2.
6 3 dispersion Estimated dispersion.
7 n1 The sample size of sample 1.
8 n2 The sample size of sample 2.
9 method Method used for the results.
10 ratio_null Assumed population ratio of means.
11 mle_code Integer indicating why the optimization process terminated.
12 mle_message Information from the optimizer.

References

\insertRef

rettiganti_2012depower

\insertRef

aban_2009depower

Examples

#----------------------------------------------------------------------------
# lrt_bnb() examples
#----------------------------------------------------------------------------
library(depower)

set.seed(1234)
sim_bnb(
  n = 40,
  mean1 = 10,
  ratio = 1.2,
  dispersion = 2
) |>
  lrt_bnb()


depower documentation built on April 3, 2025, 9:23 p.m.