Wald test for NB ratio of means
wald_test_nb.RdWald test for the ratio of means from two independent negative binomial outcomes.
Usage
wald_test_nb(
data,
equal_dispersion = FALSE,
ci_level = NULL,
link = "log",
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 Wald test is calculated assuming both groups have the same population dispersion parameter. IfFALSE(default), the Wald test is calculated assuming different dispersions.- ci_level
(Scalar numeric:
NULL;(0, 1))
IfNULL, confidence intervals are set asNA. If in(0, 1), confidence intervals are calculated at the specified level.- link
(Scalar string:
"log")
The one-to-one link function for transformation of the ratio in the test hypotheses. Must be one of"log"(default),"sqrt","squared", or"identity". See 'Details' for additional information.- ratio_null
(Scalar numeric:
1;(0, Inf))
The (pre-transformation) 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\) Wald 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). | |
| 4 | 1 | estimate | Point estimate. |
| 4 | 2 | lower | Confidence interval lower bound. |
| 4 | 3 | upper | Confidence interval upper bound. |
| 5 | mean1 | Estimated mean of group 1. | |
| 6 | mean2 | Estimated mean of group 2. | |
| 7 | dispersion1 | Estimated dispersion of group 1. | |
| 8 | dispersion2 | Estimated dispersion of group 2. | |
| 9 | n1 | Sample size of group 1. | |
| 10 | n2 | Sample size of group 2. | |
| 11 | method | Method used for the results. | |
| 12 | ci_level | The confidence level. | |
| 13 | equal_dispersion | Whether or not equal dispersions were assumed. | |
| 14 | link | Link function used to transform the ratio of means in the test hypotheses. | |
| 15 | ratio_null | Assumed ratio of means under the null hypothesis. | |
| 16 | mle_code | Integer indicating why the optimization process terminated. | |
| 17 | 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 Wald test of \(r\) are
$$ \begin{aligned} H_{null} &: f(r) = f(r_{null}) \\ H_{alt} &: f(r) \neq f(r_{null}) \end{aligned} $$
where \(f(\cdot)\) is a one-to-one link function with nonzero derivative, \(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\)).
Rettiganti and Nagaraja (2012) found that \(f(r) = r^2\) and \(f(r) = r\) had greatest power when \(r < 1\). However, when \(r > 1\), \(f(r) = \ln r\), the likelihood ratio test, and the Rao score test have greatest power. Note that \(f(r) = \ln r\), LRT, and RST were unbiased tests while the \(f(r) = r\) and \(f(r) = r^2\) tests were biased when \(r > 1\). The \(f(r) = \ln r\), LRT, and RST produced acceptable results for any \(r\) value. These results depend on the use of asymptotic vs. exact critical values.
The Wald test statistic is
$$ W(f(\hat{r})) = \left( \frac{f \left( \frac{\bar{x}_2}{\bar{x}_1} \right) - f(r_{null})}{f^{\prime}(\hat{r}) \hat{\sigma}_{\hat{r}}} \right)^2 $$
where
$$ \hat{\sigma}^{2}_{\hat{r}} = \frac{\hat{r} \left[ n_1 \hat{\theta}_1 (\hat{r} \hat{\mu} + \hat{\theta}_2) + n_2 \hat{\theta}_2 \hat{r} (\hat{\mu} + \hat{\theta}_1) \right]}{n_1 n_2 \hat{\theta}_1 \hat{\theta}_2 \hat{\mu}} $$
Under \(H_{null}\), the Wald test statistic is asymptotically distributed
as \(\chi^2_1\). The approximate level \(\alpha\) test rejects
\(H_{null}\) if \(W(f(\hat{r})) \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. The level of significance inflation also depends on \(f(\cdot)\) and
is most severe for \(f(r) = r^2\) where only the exact critical value
should be used. 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.
data |>
wald_test_nb(
equal_dispersion = FALSE,
distribution = simulated()
)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.
data |>
power(
wald_test_nb(
equal_dispersion = FALSE,
distribution = simulated()
)
)results in parametric resampling and no label permutation in performed.
Thus, setting equal_dispersion = FALSE and distribution = simulated() is
only recommended when wald_test_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
#----------------------------------------------------------------------------
# wald_test_nb() examples
#----------------------------------------------------------------------------
library(depower)
set.seed(1234)
sim_nb(
n1 = 60,
n2 = 40,
mean1 = 10,
ratio = 1.5,
dispersion1 = 2,
dispersion2 = 8
) |>
wald_test_nb()
#> $chisq
#> [1] 11.35158
#>
#> $df
#> [1] 1
#>
#> $p
#> [1] 0.0007538376
#>
#> $ratio
#> $ratio$estimate
#> [1] 1.542934
#>
#> $ratio$lower
#> [1] NA
#>
#> $ratio$upper
#> [1] NA
#>
#>
#> $mean1
#> [1] 9.316667
#>
#> $mean2
#> [1] 14.375
#>
#> $dispersion1
#> [1] 1.545421
#>
#> $dispersion2
#> [1] 11.08002
#>
#> $n1
#> [1] 60
#>
#> $n2
#> [1] 40
#>
#> $method
#> [1] "Asymptotic Wald test for independent negative binomial ratio of means"
#>
#> $ci_level
#> NULL
#>
#> $equal_dispersion
#> [1] FALSE
#>
#> $link
#> [1] "log"
#>
#> $ratio_null
#> [1] 1
#>
#> $mle_code
#> [1] 0
#>
#> $mle_message
#> [1] "relative convergence (4)"
#>