Probability & Statistics

Bernoulli Likelihood Ratio Test

Compare a null likelihood with its fitted alternative and build an exact LR-ordered test.

By Riano · Published · Updated · Report a correction

Bernoulli Likelihood Ratio Test

The likelihood ratio test (LRT) provides a general methodology for constructing hypothesis tests. It compares the maximum probability of the observed data under the null hypothesis to the maximum probability under the unrestricted alternative hypothesis. For a Bernoulli process, this leads to an exact test that ranks possible outcomes by their likelihood ratio, providing a distinct rejection ordering compared to a simple binomial test.

Worked example: The exact Likelihood Ratio calculation

Consider a sample of n = 10 independent trials with k = 2 successes. We want to test the null hypothesis H0: p = 0.5 against the unrestricted alternative H1: p ≠ 0.5.

The likelihood function for a Bernoulli sample is L(p) = pk(1-p)n-k.

  1. Null Likelihood: Under H0, p is fixed at p0 = 0.5.
    L0 = (0.5)2(1 - 0.5)10-2 = (0.5)10 = 1/1024.
    The log-likelihood is log(L0) = 10 · log(0.5) ≈ -6.93147.
  2. Alternative Likelihood (MLE): Under H1, we use the Maximum Likelihood Estimate (MLE) for p, which is p̂ = k/n = 2/10 = 0.2.
    L1 = (0.2)2(1 - 0.2)8 = (0.04)(0.16777) ≈ 0.00671.
    The log-likelihood is log(L1) = 2 · log(0.2) + 8 · log(0.8) ≈ -5.00402.
  3. Test Statistic: The likelihood ratio statistic is Λ = L0 / L1, but we typically compute -2 log Λ = 2(log L1 - log L0).
    -2 log Λ = 2 · (-5.00402 - (-6.93147)) = 2 · (1.92745) ≈ 3.8549.
    Using exact fractions inside the logarithms, we get the precise value: 3.85489514043515.
  4. Exact LR-ordered p-value: We calculate this statistic for every possible outcome k ∈ {0, ..., 10}. The p-value is the sum of the null probabilities P(X=x | H0) for all outcomes that produce a statistic at least as large as the observed 3.8549.
    The outcomes with stat ≥ 3.8549 are k=0 (stat ≈ 13.86), k=1 (stat ≈ 7.36), k=2 (stat ≈ 3.85), k=8 (stat ≈ 3.85), k=9 (stat ≈ 7.36), and k=10 (stat ≈ 13.86).
    Summing their null binomial probabilities: P(X≤2) + P(X≥8) = 0.0546875 + 0.0546875 = 0.109375.

Reproduce the calculation in the module

Open the Bernoulli Likelihood Ratio Test module to interactively explore the exact LR-ordered p-value.

  1. Set Sample count to 10, Successes to 2, and Null probability to 0.5.
  2. Verify the calculated Statistic is 3.85489514043515 and the Exact LR p value is 0.109375.
  3. In the visualization, observe which bars are colored red. These correspond to the rejection region—outcomes whose likelihood ratio statistic is greater than or equal to the observed one. Because p0 = 0.5 is symmetric, the rejection region includes k ∈ {0, 1, 2, 8, 9, 10}.
  4. Change the Null probability to 0.25 and the Successes to 5. The MLE is now 0.5. Notice that the rejection region is no longer perfectly symmetric in k, because the underlying null distribution is skewed. The exact LR test naturally orders outcomes by their evidence against the null, avoiding arbitrary decisions about how to define two-sided tails for asymmetric discrete distributions.
  5. Set Successes to 0 (with n=10, p0=0.5). Notice the MLE probability drops to 0.0, and the exact p-value is 0.001953125. The test seamlessly handles boundary observations where the MLE is 0 or 1, calculating the limit 0 log 0 = 0.

Asymptotic Comparisons and Limitations

By Wilks' Theorem, as the sample size n approaches infinity, the distribution of the test statistic -2 log Λ under the null hypothesis converges to a chi-square distribution with 1 degree of freedom (since we are estimating 1 parameter, p). However, this module intentionally computes the exact finite-sample p-value by summing over the binomial distribution. The chi-square approximation can be poor for small n or when p0 is close to 0 or 1. The exact calculation used here provides valid inference regardless of sample size.

A limitation of the exact calculation is that because the binomial distribution is discrete, the achievable p-values jump in discrete steps. It is generally impossible to achieve an exact Type I error rate of, say, exactly α = 0.05 without randomized testing. Additionally, floating-point arithmetic can introduce tiny residuals when comparing theoretically equal statistics (like k=2 and k=8 when p0=0.5); a small tolerance (e.g., 1e-11) is necessary to ensure symmetric ties are correctly included in the rejection region.

Sources

PennState STAT 415: Lesson 27.1 - Likelihood Ratio Tests introduces the general framework for likelihood ratio tests, defining the statistic and demonstrating its application to parameter hypothesis testing.

Experience it interactively

Adjust parameters, observe in real time, and build deep intuition with Riano’s interactive Bernoulli Likelihood Ratio Test module.

Try Bernoulli Likelihood Ratio Test on Riano →

More in Probability & Statistics