Tutorials › Generalized Linear Models › Comparing Three Tests for a Logistic Slope

Wald Score and Likelihood-Ratio Tests · Tutorial 280 of 981

Comparing Three Tests for a Logistic Slope

Work through all three tests for a binary logistic slope, tracing each statistic to its fitted model and comparing the resulting p-values and decisions.

Intermediate 10 min read

What You'll Learn

  • Set up a logistic slope test for two independent binomial groups.
  • Identify the unrestricted fit used by the Wald test and the restricted fit used by the score test.
  • Calculate nuisance-adjusted score information under the common-probability null.
  • Derive the likelihood-ratio statistic from the null and unrestricted likelihoods.
  • Compare the three statistics, p-values, and decisions using explicit counts.
  • Recognize when boundary counts make an ordinary score calculation undefined.

One Logistic Slope, Three Routes to a Test

A logistic regression slope can be tested in three standard ways: the Wald test uses the estimated slope and its standard error; the score test evaluates the slope score at the fit constrained by the null; and the likelihood-ratio test compares the maximized likelihoods under the unrestricted and null models. In large regular samples, these tests have the same limiting reference distribution. In a particular finite sample, however, they use different information and need not give identical statistics or decisions.

We will compare them in a particularly transparent logistic model. Two independent groups have covariate values \(x_0=0\) and \(x_1=1\), with group sizes \(n_0,n_1>0\). Let \(Y_j\) be the number of events in group \(j\). The model is

$$ Y_j\sim\operatorname{Binomial}(n_j,p_j),\qquad \operatorname{logit}(p_j)=\alpha+\beta x_j,\quad j=0,1. $$

The target is the two-sided test \(H_0:\beta=0\) against \(H_1:\beta\ne 0\). Under the null, the two groups have a common event probability. Under the unrestricted model, the two group probabilities can differ. We assume independent binomial sampling, positive group sizes, and interior observed proportions when using the ordinary finite maximum-likelihood estimates below. The usual chi-square reference distributions are large-sample approximations under regularity conditions, including an identifiable model and an interior null fit with nonsingular information.

What Each Test Fits

Definition: For testing one logistic slope, the Wald test uses the unrestricted estimate \(\hat\beta\) and its estimated standard error. The score test evaluates the slope score and its nuisance-adjusted information at the restricted maximum-likelihood fit under \(H_0\). The likelihood-ratio test compares the unrestricted and restricted maximized log-likelihoods. Each test statistic is referred to an asymptotic \(\chi^2_1\) distribution for a two-sided test.

In this two-group model, the unrestricted estimates are \(\hat p_j=Y_j/n_j\), and the slope is the difference of the groups’ estimated logits:

$$ \hat\beta=\operatorname{logit}(\hat p_1)-\operatorname{logit}(\hat p_0). $$

The restricted fit instead pools the event counts: \(\tilde p=(Y_0+Y_1)/(n_0+n_1)\). The score test needs this null fit, not the unrestricted estimate of \(\beta\). The likelihood-ratio test needs both fits. Keeping these fitting requirements distinct is essential when calculating or interpreting the three tests.

Worked Comparison With Explicit Counts

Worked Example: A Logistic Slope With Unequal Group Sizes

Suppose \(n_0=11,\;Y_0=3\) and \(n_1=9,\;Y_1=7\). Test \(H_0:\beta=0\) against a two-sided alternative. All four event and non-event counts are positive, so both fitted group probabilities are interior.

Unrestricted fit and Wald test. The estimated probabilities are \(\hat p_0=3/11\) and \(\hat p_1=7/9\). Thus

$$ \hat\beta =\log\!\left(\frac{7/9}{2/9}\right) -\log\!\left(\frac{3/11}{8/11}\right) =\log(7/2)-\log(3/8) =\log(28/3) \approx 2.2336. $$

For independent binomial groups, the estimated variance of each group logit is \(1/[n_j\hat p_j(1-\hat p_j)]\). The two group estimates are independent, so the variance of their difference is the sum:

$$ \widehat{\operatorname{Var}}(\hat\beta) =\frac{1}{3(8/11)}+\frac{1}{7(2/9)} =\frac{11}{24}+\frac{9}{14} =\frac{463}{420} \approx 1.10119. $$

The standard error is \(\sqrt{463/420}\approx1.0494\). Therefore \(Z_W=2.2336/1.0494\approx2.1285\), and \(W=Z_W^2\approx4.5305\). The \(\chi^2_1\) p-value is approximately \(0.0333\).

Restricted fit and score test. Under \(H_0\), the pooled probability is \(\tilde p=(3+7)/(11+9)=1/2\). The null intercept is consequently \(\tilde\alpha=\operatorname{logit}(1/2)=0\). The slope score at this fit is \(U_\beta=Y_1-n_1\tilde p=7-9/2=2.5\). As derived below, its nuisance-adjusted information is \(1.2375\). Hence

$$ S=\frac{U_\beta^2}{I_{\beta\beta\cdot\alpha}} =\frac{2.5^2}{1.2375} =\frac{500}{99} \approx5.0505. $$

The \(\chi^2_1\) p-value is approximately \(0.02465\).

Likelihood-ratio test. The unrestricted log-likelihood uses the two fitted probabilities \(3/11\) and \(7/9\); the null log-likelihood uses \(1/2\) in both groups. Binomial coefficients cancel in their difference, giving

$$ G^2=2\left[ 3\log\!\left(\frac{6}{11}\right) +8\log\!\left(\frac{16}{11}\right) +7\log\!\left(\frac{14}{9}\right) +2\log\!\left(\frac{4}{9}\right) \right] \approx5.3002. $$

Its \(\chi^2_1\) p-value is approximately \(0.0213\). The three p-values differ: Wald \(0.0333\), score \(0.02465\), and likelihood ratio \(0.0213\). At level \(0.025\), the score and likelihood-ratio tests reject, while the Wald test does not. In particular, the score p-value is below \(0.025\); the decision does not depend on rounding or an equality convention.

Why the Score Information Has This Form

The score calculation includes the intercept as a nuisance parameter: it must account for estimating the intercept under the null rather than treating it as known. The following derivation shows exactly how that adjustment enters.

Result: Suppose \(n_0,n_1>0\) and \(0<Y_0+Y_1<n_0+n_1\). At the null fit, let \(\tilde p=(Y_0+Y_1)/(n_0+n_1)\), and set \(w_j=n_j\tilde p(1-\tilde p)\). Then \(U_\beta=Y_1-n_1\tilde p\), and the slope’s nuisance-adjusted information is \(I_{\beta\beta\cdot\alpha}=w_0w_1/(w_0+w_1)\). The ordinary score statistic is \(S=U_\beta^2/I_{\beta\beta\cdot\alpha}\).

Proof. Apart from terms constant in \(\alpha,\beta\), the log-likelihood is

$$ \ell(\alpha,\beta) =\sum_{j=0}^1\left\{ Y_j(\alpha+\beta x_j)-n_j\log[1+\exp(\alpha+\beta x_j)] \right\}. $$

Write \(p_j=\operatorname{logit}^{-1}(\alpha+\beta x_j)\). Differentiating with respect to the slope gives \(U_\beta=\sum_j x_j(Y_j-n_jp_j)\). Under \(H_0\), \(p_0=p_1=\tilde p\), and \(x_0=0,x_1=1\), so \(U_\beta=Y_1-n_1\tilde p\). The intercept score is \(U_\alpha=Y_0+Y_1-(n_0+n_1)\tilde p=0\), by the definition of the pooled estimate.

For a binomial logistic observation, the information contribution for a linear predictor is \(n_jp_j(1-p_j)\). Thus, at the null fit, the information matrix in the order \((\alpha,\beta)\) is

$$ I= \begin{pmatrix} w_0+w_1&w_1\\ w_1&w_1 \end{pmatrix}. $$

Adjusting for the nuisance intercept gives the Schur complement

$$ I_{\beta\beta\cdot\alpha} =I_{\beta\beta}-\frac{I_{\beta\alpha}^2}{I_{\alpha\alpha}} =w_1-\frac{w_1^2}{w_0+w_1} =\frac{w_0w_1}{w_0+w_1}. $$

The score statistic is the squared nuisance-adjusted score divided by this information. Since the restricted intercept score is zero, the adjusted slope score equals \(U_\beta\). The stated result follows. The count condition ensures \(0<\tilde p<1\), so both weights and the adjusted information are positive. \(\square\)

Worked Example: Checking the Restricted Score Numerically

For the counts in the first example, the null fit has \(\tilde p=1/2\), so \(w_0=11(1/2)(1/2)=2.75\) and \(w_1=9(1/2)(1/2)=2.25\). The adjusted information is

$$ \frac{w_0w_1}{w_0+w_1} =\frac{(2.75)(2.25)}{5} =1.2375. $$

The null-fit slope score is \(7-9(1/2)=2.5\). Direct substitution gives \(S=6.25/1.2375=500/99\approx5.0505\), confirming the score statistic used above. Using the unrestricted probabilities \(3/11\) and \(7/9\) here would be a different calculation: the score test is specifically evaluated at the restricted fit.

Deriving the Likelihood-Ratio Comparison

For these two groups, the unrestricted model has one free probability for each group, while the null model constrains them to be equal. Their maximized log-likelihoods make the likelihood-ratio statistic especially direct to derive.

Result: If both group proportions are interior, the likelihood-ratio statistic for \(H_0:\beta=0\) is
$$ G^2 =2\sum_{j=0}^1\left[ Y_j\log\!\left(\frac{\hat p_j}{\tilde p}\right) +(n_j-Y_j)\log\!\left(\frac{1-\hat p_j}{1-\tilde p}\right) \right], \qquad \hat p_j=\frac{Y_j}{n_j},\quad \tilde p=\frac{Y_0+Y_1}{n_0+n_1}. $$

Derivation. The binomial log-likelihood for group \(j\), including its combinatorial constant, is \( \log {n_j\choose Y_j}+Y_j\log p_j+(n_j-Y_j)\log(1-p_j)\). At the unrestricted maximum, \(p_j=\hat p_j\); at the null maximum, both probabilities equal \(\tilde p\). Subtracting the null log-likelihood from the unrestricted one cancels the combinatorial constants. Multiplying the remaining difference by two gives the displayed expression. The statistic is nonnegative because the unrestricted model includes the null model and therefore cannot have a smaller maximized likelihood. Under the null and the stated regularity conditions, its asymptotic reference distribution is \(\chi^2_1\), since the null imposes one independent restriction. \(\square\)

Worked Example: A Different Sample With the Same Three Tests

Let \(n_0=n_1=10,\;Y_0=2,\;Y_1=6\). The unrestricted probabilities are \(0.2\) and \(0.6\), while the null pooled probability is \(8/20=0.4\). The slope estimate is

$$ \hat\beta=\operatorname{logit}(0.6)-\operatorname{logit}(0.2) =\log(1.5)-\log(0.25)=\log 6\approx1.7918. $$

For the Wald test, the estimated variance is \(1/[10(0.2)(0.8)]+1/[10(0.6)(0.4)]=0.625+0.416667=25/24\). Thus \(Z_W=\log(6)/\sqrt{25/24}\approx1.7555\), \(W\approx3.0818\), and the two-sided \(\chi^2_1\) p-value is about \(0.079\).

For the score test, \(U_\beta=6-10(0.4)=2\), and each group weight is \(10(0.4)(0.6)=2.4\). The adjusted information is \((2.4)(2.4)/(2.4+2.4)=1.2\), so \(S=2^2/1.2=3.3333\), with p-value about \(0.068\).

For the likelihood-ratio test,

$$ G^2=2\left[ 2\log(0.2/0.4)+8\log(0.8/0.6) +6\log(0.6/0.4)+4\log(0.4/0.6) \right]\approx3.4522. $$

Its p-value is about \(0.063\). All three tests fail to reject at level \(0.05\), though their p-values are not identical. The calculations illustrate that similar conclusions do not imply the statistics are interchangeable.

Interpreting Differences and Avoiding Pitfalls

In the first example, the Wald statistic is smaller than the score and likelihood-ratio statistics, and its p-value lies above \(0.025\) while the other two lie below. This is not a contradiction: each statistic is built from a different aspect of the likelihood. The Wald test measures the unrestricted estimate relative to its estimated standard error; the score test measures the slope’s evidence at the null fit; and the likelihood-ratio test measures the loss in maximized log-likelihood when the null restriction is imposed. Their local equivalence explains why they often agree in large samples, not why they must agree exactly in finite samples.

A common mistake is to calculate the score statistic using the unrestricted slope estimate and the unrestricted information, or to call the score p-value “approximately at the cutoff” after rounding. The correction is to evaluate the score and its nuisance-adjusted information at the restricted fit, then compare the unrounded p-value with the chosen level. In the first example, \(S=500/99\) gives \(p\approx0.02465\), so the score test rejects at level \(0.025\).

There is also an important boundary caveat. If \(Y_0+Y_1=0\) or \(Y_0+Y_1=n_0+n_1\), the pooled null estimate is \(0\) or \(1\). Then \(w_0=w_1=0\), the restricted finite intercept does not exist, and the ordinary score statistic has zero information in its denominator. It is not valid to substitute these values into the interior score formula and report a \(0/0\) statistic as a test result. Boundary cases require separate treatment.

Key takeaway: For a logistic slope, trace the test to its fit: Wald uses the unrestricted estimate, score uses the restricted fit and nuisance-adjusted information, and likelihood ratio compares both maximized likelihoods. Compute the corresponding statistic before comparing p-values; finite-sample decisions can differ.

Check Your Understanding

Use the two-group logistic setup to answer these questions.

  1. Which fitted model supplies the slope estimate and standard error for a Wald test?
  2. For the score test, why is the pooled probability used under \(H_0:\beta=0\)?
  3. In the first worked example, what are the score statistic and its approximate p-value, and what is its decision at level \(0.025\)?
  4. Explain why the likelihood-ratio statistic compares two maximized log-likelihoods rather than two slope estimates.
  5. What goes wrong with the ordinary score information formula if the total number of events is zero?
Clinical Biostats