Why a Difference Needs Joint Uncertainty
A logistic model can predict risk for two covariate profiles, such as a treated and an untreated profile. Their difference is often easier to interpret as an absolute change in probability than a difference in odds. But the uncertainty in that contrast is not generally the sum of two separate prediction variances: both predictions use the same estimated coefficients, so they are dependent.
The appropriate calculation treats the risk difference as one function of the coefficient vector. Its gradient describes how the contrast changes when the coefficients change, and the full coefficient covariance matrix carries the dependence into the resulting variance.
Definition and Delta-Method Variance
For a profile with linear predictor \(x^T\beta\), the derivative of its risk with respect to \(\beta\) is \(p(1-p)x\), where \(p=\operatorname{expit}(x^T\beta)\). Therefore the gradient of the risk difference, evaluated at \(\hat\beta\), is
Let \(\widehat V\) be the estimated covariance matrix of \(\hat\beta\), using the convention that it already includes the sample-size scaling. The delta-method variance estimate is
The design vectors include all model terms used for prediction: an intercept, covariates, indicator variables, and any interaction terms. The two vectors need not differ in only one entry.
Why the Formula Works
The relevant delta-method result is a multivariate version of first-order Taylor approximation. Suppose the true coefficient vector is \(\beta_0\), and, under the model’s usual regularity conditions, \(\sqrt n(\hat\beta-\beta_0)\xrightarrow{d}N(0,\Sigma)\). For logistic maximum likelihood, this asymptotic normality applies when the model is correctly specified, the true parameter is an interior point, the information is nonsingular, and standard likelihood regularity conditions hold. Let \(h(\beta)\) be differentiable at \(\beta_0\), with gradient \(g_0\).
Proof. Differentiability at \(\beta_0\) means that for \(u\) near zero, \(h(\beta_0+u)-h(\beta_0)=g_0^Tu+r(u)\), where \(r(u)/\lVert u\rVert\to0\) as \(u\to0\). Asymptotic normality implies \(\hat\beta-\beta_0=O_p(n^{-1/2})\), hence \(\hat\beta\xrightarrow{p}\beta_0\). It follows from the remainder condition that \(\sqrt n\,r(\hat\beta-\beta_0)=o_p(1)\). Thus
The first term converges in distribution to a mean-zero normal random variable with variance \(g_0^T\Sigma g_0\), because it is a linear transformation of the limiting multivariate normal vector. Slutsky’s theorem then gives the stated limit. \(\square\)
For the risk difference, take \(h(\beta)=\operatorname{expit}(x_A^T\beta)-\operatorname{expit}(x_B^T\beta)\). This function is differentiable, and its gradient is the difference of the two profile gradients displayed above. Replacing the unknown gradient and covariance with their fitted estimates gives the stated variance estimate. When \(\widehat V\) consistently estimates the coefficient covariance, this plug-in estimate is the corresponding first-order asymptotic variance.
The Covariance Between Predictions
The same result can be expressed in terms of the two fitted risks separately. Let \(g_A=p_A(1-p_A)x_A\) and \(g_B=p_B(1-p_B)x_B\), evaluated at the fitted coefficients when estimating. Their approximate variances and covariance are
Subtracting predictions subtracts their covariance twice. This is an algebraic identity, not an optional adjustment:
In matrix form, \((g_A-g_B)^TV(g_A-g_B)\) expands to \(g_A^TVg_A+g_B^TVg_B-2g_A^TVg_B\), which is exactly the same calculation. In general, the covariance is not zero just because the profiles are different: both fitted risks depend on \(\hat\beta\).
Worked Calculations
Worked Example: A Treatment-Profile Risk Difference
Suppose a logistic model has coefficient vector \(\hat\beta=(-1,0.7)^T\), with estimated covariance matrix $$ \widehat V= \begin{pmatrix} 0.04&0.01\\ 0.01&0.09 \end{pmatrix}. $$ Compare the profile with \(x_B=(1,0)^T\) to the profile with \(x_A=(1,1)^T\). The two linear predictors are \(-0.3\) and \(-1\), respectively, so
\(\hat p_A=\operatorname{expit}(-0.3)\approx0.425557\) and \(\hat p_B=\operatorname{expit}(-1)\approx0.268941\). Thus \(\hat\Delta\approx0.156616\), or about 15.7 percentage points.
The risk derivatives are \(a_A=\hat p_A(1-\hat p_A)\approx0.244458\) and \(a_B=\hat p_B(1-\hat p_B)\approx0.196612\). Therefore \(\hat g_A=(a_A,a_A)^T\), \(\hat g_B=(a_B,0)^T\), and \(\hat g=(a_A-a_B,a_A)^T\approx(0.047846,0.244458)^T\).
The variance is calculated with the full covariance matrix:
For a check using the two predictions, their approximate variances are \(a_A^2(0.04+2(0.01)+0.09)\approx0.008964\) and \(a_B^2(0.04)\approx0.001546\). Their covariance is \(a_Aa_B(0.04+0.01)\approx0.002403\). Hence the contrast variance is approximately \(0.008964+0.001546-2(0.002403)=0.005704\), consistent up to rounding. The standard error is about \(0.07552\).
Worked Example: Checking the Gradient and Variance Arithmetic
Consider profiles \(x_A=(1,0,0)^T\) and \(x_B=(1,c,c)^T\), where \(c=0.187370/0.172376\). Let \(\hat p_A=0.10\), and choose \(\hat p_B\) so that \(\hat p_B(1-\hat p_B)=0.172376\); the smaller root is \(\hat p_B=(1-\sqrt{1-4(0.172376)})/2\approx0.22139\). These risks are compatible with a logistic coefficient vector: set \(\hat\beta_0=\operatorname{logit}(0.10)\) and \(\hat\beta_1=\hat\beta_2=\{\operatorname{logit}(\hat p_B)-\hat\beta_0\}/(2c)\).
The profile derivatives are \(0.10(0.90)=0.09\) and \(0.172376\). Subtracting the profile gradients gives \(\hat g=(0.09-0.172376,-0.172376c,-0.172376c)^T\approx(-0.082376,-0.187370,-0.187370)^T\). Suppose \(\widehat V=\operatorname{diag}(0.04,0.01,0.0225)\). Then the variance estimate, using the displayed rounded gradient entries, is
The standard error is \(\sqrt{0.00141243}\approx0.03758\). The estimated difference is \(0.10-0.22139\approx-0.12139\). A 95% Wald interval is therefore \(-0.12139\pm1.96(0.03758)\), approximately \((-0.195, -0.048)\). The negative sign indicates a lower fitted risk at profile A than at profile B.
Worked Example: Forming a Wald Interval
Suppose a fitted risk difference is \(\hat\Delta=0.08\), and the joint delta-method calculation gives \(\widehat{\operatorname{Var}}(\hat\Delta)=0.0009\). The standard error is \(\sqrt{0.0009}=0.03\). A 95% Wald interval, using the standard normal critical value 1.96, is
On the probability-difference scale, this corresponds to an estimated increase of 8 percentage points, with an approximate interval from 2.1 to 13.9 percentage points. This is a large-sample approximation: it uses the normal limit for the smooth contrast, not an exact finite-sample distribution.
Interpretation and a Common Pitfall
For a fixed pair of profiles, the result estimates the difference between their model-fitted risks. The point estimate is measured in probability units; multiplying by 100 expresses it in percentage points. The Wald interval uses the same contrast and its estimated standard error. Because it is based on a normal approximation, its endpoints can sometimes fall outside the possible risk-difference range \([-1,1]\). Such endpoints signal a limitation of the approximation; they do not change the fitted risks or make a probability difference unbounded.
Common mistake: treating the predictions as independent. A tempting calculation is to add the two prediction variances and use that as the contrast variance. It omits the covariance term. For example, in the first worked example the covariance between the fitted risks is positive, so subtracting twice that covariance makes the difference more precise than the independence calculation would suggest. In other settings the covariance could be negative, in which case accounting for it increases the contrast variance. The correction is to calculate \(\hat g^T\widehat V\hat g\) directly, or to include the covariance term explicitly.
A second practical check is to keep the sign of the contrast consistent. If the definition is \(\hat p_A-\hat p_B\), reverse the sign of both the estimate and its gradient when reversing the profile order; the variance and standard error remain unchanged. Reporting the profile order and the risk-difference scale makes the result interpretable.
Check Your Understanding
Use the formulas and reasoning in this tutorial to answer the following.
- Write the gradient of the difference between risks at profiles \(x_A\) and \(x_B\).
- Why does the variance of a fitted risk difference include a covariance term?
- If the covariance between two fitted risks is positive, how does omitting it affect the estimated variance of their difference?
- What information must be present in the design vectors when the logistic model includes an interaction?
- Explain what a negative fitted risk difference means when the contrast is defined as risk at profile A minus risk at profile B.