Likelihood ratio test for NB ratio of means
lrt_nb.RdLikelihood ratio test for the ratio of means from two independent negative binomial outcomes.
Usage
lrt_nb(
data,
equal_dispersion = FALSE,
ratio_null = 1,
distribution = asymptotic(),
...
)Arguments
- data
(list)
A list whose first element is the vector of negative binomial values from group 1 and the second element is the vector of negative binomial values from group 2. NAs are silently excluded. The default output fromsim_nb().- equal_dispersion
(Scalar logical:
FALSE)
IfTRUE, the LRT is calculated assuming both groups have the same population dispersion parameter. IfFALSE(default), the LRT is calculated assuming different dispersions.- ratio_null
(Scalar numeric:
1;(0, Inf))
The ratio of means assumed under the null hypothesis (group 2 / group 1). Typicallyratio_null = 1(no difference). See 'Details' for additional information.- distribution
(function:
asymptotic()orsimulated())
The method used to define the distribution of the \(\chi^2\) likelihood ratio test statistic under the null hypothesis. See 'Details' andasymptotic()orsimulated()for additional information.- ...
Optional arguments passed to the MLE function
mle_nb().
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 (group 2 / group 1). | |
| 5 | alternative | Point estimates under the alternative hypothesis. | |
| 5 | 1 | mean1 | Estimated mean of group 1. |
| 5 | 2 | mean2 | Estimated mean of group 2. |
| 5 | 3 | dispersion1 | Estimated dispersion of group 1. |
| 5 | 4 | dispersion2 | Estimated dispersion of group 2. |
| 6 | null | Point estimates under the null hypothesis. | |
| 6 | 1 | mean1 | Estimated mean of group 1. |
| 6 | 2 | mean2 | Estimated mean of group 2. |
| 6 | 3 | dispersion1 | Estimated dispersion of group 1. |
| 6 | 4 | dispersion2 | Estimated dispersion of group 2. |
| 7 | n1 | Sample size of group 1. | |
| 8 | n2 | Sample size of group 2. | |
| 9 | method | Method used for the results. | |
| 10 | equal_dispersion | Whether or not equal dispersions were assumed. | |
| 11 | ratio_null | Assumed population ratio of means. | |
| 12 | mle_code | Integer indicating why the optimization process terminated. | |
| 13 | mle_message | Information from the optimizer. |
Details
This function is primarily designed for speed in simulation. Missing values are silently excluded.
Suppose \(X_1 \sim NB(\mu, \theta_1)\) and \(X_2 \sim NB(r\mu, \theta_2)\) where \(X_1\) and \(X_2\) are independent, \(X_1\) is the count outcome for items in group 1, \(X_2\) is the count outcome for items in group 2, \(\mu\) is the arithmetic mean count in group 1, \(r\) is the ratio of arithmetic means for group 2 with respect to group 1, \(\theta_1\) is the dispersion parameter of group 1, and \(\theta_2\) is the dispersion parameter of group 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 group 2 with respect to group 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_1, \theta_2)}{\text{sup}_{\Theta} L(r, \mu, \theta_1, \theta_2)} \\ &= -2 \left[ \ln \text{sup}_{\Theta_{null}} L(r, \mu, \theta_1, \theta_2) - \ln \text{sup}_{\Theta} L(r, \mu, \theta_1, \theta_2) \right] \\ &= -2(l(r_{null}, \tilde{\mu}, \tilde{\theta}_1, \tilde{\theta}_2) - l(\hat{r}, \hat{\mu}, \hat{\theta}_1, \hat{\theta}_2)) \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)\). However,
the asymptotic critical value is known to underestimate the exact critical
value and the nominal significance level may not be achieved for small sample
sizes. Argument distribution allows control of the distribution of
the \(\chi^2_1\) test statistic under the null hypothesis by use of
functions asymptotic() and simulated().
Note that standalone use of this function with equal_dispersion = FALSE
and distribution = simulated(), e.g.
results in a nonparametric randomization test based on label permutation.
This violates the assumption of exchangeability for the randomization test
because the labels are not exchangeable when the null hypothesis assumes
unequal dispersions. However, used inside power(), e.g.
results in parametric resampling and no label permutation is performed.
Thus, setting equal_dispersion = FALSE and distribution = simulated() is
only recommended when lrt_nb() is used inside of
power(). See also, simulated().
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
#----------------------------------------------------------------------------
# lrt_nb() examples
#----------------------------------------------------------------------------
library(depower)
set.seed(1234)
sim_nb(
n1 = 60,
n2 = 40,
mean1 = 10,
ratio = 1.5,
dispersion1 = 2,
dispersion2 = 8
) |>
lrt_nb()
#> $chisq
#> [1] 10.02464
#>
#> $df
#> [1] 1
#>
#> $p
#> [1] 0.001544595
#>
#> $ratio
#> [1] 1.542934
#>
#> $alternative
#> $alternative$mean1
#> [1] 9.316667
#>
#> $alternative$mean2
#> [1] 14.375
#>
#> $alternative$dispersion1
#> [1] 1.545421
#>
#> $alternative$dispersion2
#> [1] 11.08002
#>
#>
#> $null
#> $null$mean1
#> [1] 13.17212
#>
#> $null$mean2
#> [1] 13.17212
#>
#> $null$dispersion1
#> [1] 1.31389
#>
#> $null$dispersion2
#> [1] 10.18563
#>
#>
#> $n1
#> [1] 60
#>
#> $n2
#> [1] 40
#>
#> $method
#> [1] "Asymptotic LRT for independent negative binomial ratio of means"
#>
#> $equal_dispersion
#> [1] FALSE
#>
#> $ratio_null
#> [1] 1
#>
#> $mle_code
#> [1] 0
#>
#> $mle_message
#> [1] "relative convergence (4)"
#>