| Title: | Finite-Sample Tail Bound of Likelihood Ratio Test under Multinomial Sampling |
|---|---|
| Description: | Computes a finite-sample tail bound for the log-likelihood ratio test (LRT) statistic under multinomial sampling. The resulting bound is used to compute finite-sample conservative p-values and critical values when the standard chi-squared asymptotics can be unreliable. The package also supports multiple independent multinomial trials. |
| Authors: | Richard Guo [aut, cre, cph], Ivana Liu [aut] |
| Maintainer: | Richard Guo <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.0.0 |
| Built: | 2026-05-23 08:59:02 UTC |
| Source: | https://github.com/richardkwo/multchernoff |
The LRT is the log-likelihood ratio test statistic, which can be written as
By the Wilks' theorem, for a fixed k-dimensional probability vector, it holds that
This function returns a finite-sample counterpart to
qchisq(p, k-1, lower.tail=FALSE).
The LRT is also extended to multiple independent multinomial trials.
For example, for a -trial and a -trial,
we have
criticalValue(k, n, p = 0.05, verbose = FALSE)criticalValue(k, n, p = 0.05, verbose = FALSE)
k |
number of categories (a vector for independent multinomial draws) |
n |
sample size (a vector for independent multinomial draws) |
p |
significance level (e.g., 0.05) |
verbose |
draw the minimizer if |
A finite-sample critical value such that the bound on
is at most p.
For independent multinomial samples, k and n must be of the same length.
n <- 1:40 crit <- sapply(n, function(.n) criticalValue(20, .n, p=0.01)) plot(n, crit) # chi-squared asymptotic by Wilks' theorem abline(h=qchisq(0.01, df=20-1, lower.tail = FALSE)) criticalValue(10, 40, p=0.05) # two independent multinomial trials (k=3, n=4) and (k=12, n=20) criticalValue(c(3, 4), c(12, 20), p=0.05)n <- 1:40 crit <- sapply(n, function(.n) criticalValue(20, .n, p=0.01)) plot(n, crit) # chi-squared asymptotic by Wilks' theorem abline(h=qchisq(0.01, df=20-1, lower.tail = FALSE)) criticalValue(10, 40, p=0.05) # two independent multinomial trials (k=3, n=4) and (k=12, n=20) criticalValue(c(3, 4), c(12, 20), p=0.05)
The LRT is the log-likelihood ratio test statistic, which can be written as
namely the Kullback-Leibler divergence from the empirical probabilities to
the true probabilities multiplied by the sample size. is
a polynomial in such that
holds for every and every .
mgfBound(k, n, lambda)mgfBound(k, n, lambda)
k |
number of categories |
n |
sample size |
lambda |
number between 0 and 1 |
A numeric upper bound on the MGF of LRT evaluated at lambda.
mgfBound(k = 5, n = 20, lambda = 0.5) mgfBound(k = 5, n = 20, lambda = 0) # always 1 at lambda = 0mgfBound(k = 5, n = 20, lambda = 0.5) mgfBound(k = 5, n = 20, lambda = 0) # always 1 at lambda = 0
The LRT is the log-likelihood ratio test statistic, which can be written as
By the Wilks' theorem, for a fixed k-dimensional probability vector, it holds that
This function returns a finite-sample counterpart to
pchisq(x, k-1, lower.tail=FALSE).
The LRT is also extended to multiple independent multinomial trials.
For example, for a -trial and a -trial,
we have
tailProbBound(x, k, n, verbose = FALSE)tailProbBound(x, k, n, verbose = FALSE)
x |
the value of |
k |
number of categories (a vector for independent multinomial draws) |
n |
sample size (a vector for independent multinomial draws) |
verbose |
draw the minimizer if |
An upper bound on P(2 LRT > x), which can be used as a conservative p-value.
For independent multinomial samples, k and n must be of the same length.
tailProbBound(20, 7, 50) pchisq(20, 6, lower.tail=FALSE) # compare with the standard chi-square asymptotic # two independent multinomial trials (k=3, n=4) and (k=12, n=20) tailProbBound(12, c(3, 4), c(12, 20)) pchisq(12, 5, lower.tail=FALSE) # compare with the standard chi-square asymptotictailProbBound(20, 7, 50) pchisq(20, 6, lower.tail=FALSE) # compare with the standard chi-square asymptotic # two independent multinomial trials (k=3, n=4) and (k=12, n=20) tailProbBound(12, c(3, 4), c(12, 20)) pchisq(12, 5, lower.tail=FALSE) # compare with the standard chi-square asymptotic