Tutorials › Generalized Linear Models › Initializing Intercepts from Response Margins

Initialization and Numerical Stability · Tutorial 226 of 981

Initializing Intercepts from Response Margins

Learn to turn response margins into intercept starting values, including offset models where the intercept must be found from a monotone equation.

Intermediate 11 min read

What You'll Learn

  • Derive the logit intercept from the Bernoulli success proportion.
  • Use the pooled success proportion for grouped binomial observations.
  • Derive the Poisson log-link intercept from the observed count total.
  • Construct intercept starts when a known offset is present.
  • Recognize boundary margins that do not yield a finite intercept.
  • Explain why grouped proportions and offset-adjusted margins require care.

Why Initialize an Intercept From the Response Margin?

An iterative GLM fit needs starting coefficients. A useful baseline is an intercept-only fit: it begins with a common fitted mean and matches that mean to the observed response margin. This gives the optimizer a starting point on the scale of the data, rather than an arbitrary intercept that might imply implausible probabilities or count means.

The formulas depend on the response distribution and link. For Bernoulli and binomial responses with a logit link, the intercept matches the overall success proportion. For Poisson responses with a log link, it matches the overall count mean. A known offset changes the matching equation: with nonconstant offsets, the intercept generally has to be found by solving an equation rather than by applying a single inverse link to the raw margin.

Definition: An intercept-only starting value is an intercept \(\alpha\) chosen so that the fitted means from a model with no covariate effects match the observed response margin. In a model \(\eta_i=\alpha+x_i^\mathsf{T}\beta+o_i\), setting \(\beta=0\) leaves \(\eta_i=\alpha+o_i\), where \(o_i\) is a known offset. Without an offset, the fitted means are constant across observations.

Bernoulli and Binomial Responses Without Offsets

Let \(Y_i\) be a Bernoulli response, with \(Y_i=1\) for a success and \(Y_i=0\) for a failure. Under a logistic intercept-only model, every observation has success probability \(p=\operatorname{expit}(\alpha)=1/(1+\exp(-\alpha))\). If \(S=\sum_{i=1}^n Y_i\) successes are observed, the log-likelihood, apart from terms not involving \(\alpha\), is \(S\log p+(n-S)\log(1-p)\). Its score is \(S-np\). Thus, when \(0<S<n\), the score is zero at \(p=S/n\), giving the starting value

$$ \hat\alpha_0 =\log\left(\frac{S/n}{1-S/n}\right) =\log\left(\frac{S}{n-S}\right). $$

Here the subscript \(0\) labels the intercept-only starting value. If \(S=0\), the score is negative for every finite \(\alpha\), and the likelihood increases as \(\alpha\) decreases without bound. If \(S=n\), it increases as \(\alpha\) increases without bound. In either case there is no finite intercept-only maximum; the corresponding limiting intercept is \(-\infty\) or \(+\infty\).

Worked Example: A Bernoulli Margin

Suppose 10 patients are classified as having an event or not, and 6 have the event. For an intercept-only logistic model, \(S=6\) and \(n=10\), so the observed event proportion is \(6/10=0.6\). The odds are \(0.6/(1-0.6)=0.6/0.4=1.5\), and therefore

$$ \hat\alpha_0=\log(1.5)\approx 0.4055. $$

Checking the result, \(\operatorname{expit}(0.4055)\approx 0.6000\). Thus the starting model assigns each patient an event probability of about 0.6, matching the observed margin.

For grouped binomial data, let \(Y_i\) be the number of successes among \(m_i\) trials, where \(m_i\) is a nonnegative integer and \(0\leq Y_i\leq m_i\). Write \(S=\sum_iY_i\) and \(M=\sum_i m_i\). With a common probability \(p\), the score for \(\alpha\) is \(S-Mp\). If \(0<S<M\), setting this score to zero gives \(p=S/M\), and hence

$$ \hat\alpha_0=\log\left(\frac{S}{M-S}\right). $$

The Bernoulli formula is the special case \(m_i=1\) for every observation. The grouped formula uses the pooled success proportion, not the unweighted average of the group-specific proportions. A group with more trials contributes more information to the pooled margin.

Worked Example: Grouped Binomial Data With a Zero-Trial Group

Three groups have trial counts \(m=(4,0,6)\) and observed successes \(Y=(1,0,5)\). The middle group contributes no trials. The totals are \(S=1+0+5=6\) and \(M=4+0+6=10\). Consequently,

$$ \hat p_0=\frac{6}{10}=0.6, \qquad \hat\alpha_0=\log\left(\frac{6}{10-6}\right) =\log(1.5)\approx0.4055. $$

The group proportions for the informative groups are \(1/4=0.25\) and \(5/6\approx0.8333\). Their unweighted average is about \(0.5417\), not \(0.6\); the correct pooled value weights each group by its number of trials. The zero-trial group contributes neither successes nor trials and has no effect on the starting value.

Poisson Responses Without Offsets

Suppose \(Y_i\) are independent Poisson responses and the intercept-only model uses the log link, so that \(E[Y_i]=\mu=\exp(\alpha)\). The log-likelihood, apart from constants, is \(\ell(\alpha)=\sum_i\{Y_i\alpha-\exp(\alpha)\}\). Differentiating gives the score \(\sum_iY_i-n\exp(\alpha)\). If the total count is positive, setting the score to zero gives

$$ \hat\mu_0=\frac{\sum_iY_i}{n}, \qquad \hat\alpha_0=\log\left(\frac{\sum_iY_i}{n}\right). $$

The intercept is the log of the sample mean count, not the sample mean count itself. If every observed count is zero, the score is \(-n\exp(\alpha)<0\) for every finite \(\alpha\); the likelihood increases as \(\alpha\) tends to \(-\infty\), so there is no finite intercept-only maximum.

Worked Example: A Poisson Count Margin

Suppose the observed counts are \(Y=(2,0,4)\). Their total is \(6\), and there are \(n=3\) observations. The intercept-only fitted mean is \(6/3=2\), so

$$ \hat\alpha_0=\log(2)\approx0.6931. $$

The implied mean is \(\exp(\hat\alpha_0)=\exp(\log 2)=2\), which agrees with the observed average count. The individual observations need not equal 2; it is their mean that the intercept-only fit matches.

Adding a Known Offset

An offset is a known term added to the linear predictor with coefficient fixed at one. With an offset \(o_i\), the intercept-only predictor is \(\eta_i=\alpha+o_i\). For a logistic binomial model, the fitted success probability in group \(i\) is \(p_i(\alpha)=\operatorname{expit}(\alpha+o_i)\). The intercept score is therefore

$$ U(\alpha)=\sum_i\{Y_i-m_i\operatorname{expit}(\alpha+o_i)\} =S-h(\alpha), \qquad h(\alpha)=\sum_i m_i\operatorname{expit}(\alpha+o_i). $$

The starting value solves \(h(\alpha)=S\). When the offsets differ, there is generally no formula that turns the pooled proportion \(S/M\) directly into \(\alpha\), because each group has a different probability even at the same intercept.

Theorem: Suppose \(m_i\geq0\), the offsets \(o_i\) are finite, and \(M=\sum_i m_i>0\). For the offset logistic binomial intercept-only model, if \(0<S<M\), there is exactly one finite intercept \(\alpha\) satisfying \(\sum_i m_i\operatorname{expit}(\alpha+o_i)=S\).

Proof. Each term \(m_i\operatorname{expit}(\alpha+o_i)\) is nondecreasing in \(\alpha\), and it is strictly increasing whenever \(m_i>0\). Since \(M>0\), at least one \(m_i\) is positive, so their sum \(h\) is strictly increasing. It is continuous because it is a finite sum of continuous functions. Since the offsets are finite, \(\operatorname{expit}(\alpha+o_i)\) tends to 0 as \(\alpha\) tends to \(-\infty\), and to 1 as \(\alpha\) tends to \(+\infty\). It follows that \(h(\alpha)\) tends to 0 and \(M\), respectively. For \(0<S<M\), the intermediate value theorem gives a finite \(\alpha\) with \(h(\alpha)=S\); strict increase makes that solution unique. \(\square\)

Worked Example: A Logistic Intercept With Unequal Offsets

Consider two binomial groups with \(m_1=2\), \(m_2=4\), observed successes \(Y_1=1\), \(Y_2=3\), and offsets \(o_1=0\), \(o_2=\log 3\). The total number of successes is \(S=4\), out of \(M=6\) trials. At \(\alpha=0\), the group probabilities are

$$ p_1(0)=\operatorname{expit}(0)=\frac12, \qquad p_2(0)=\operatorname{expit}(\log 3)=\frac{3}{1+3}=\frac34. $$

The fitted total is \(2(1/2)+4(3/4)=1+3=4\), exactly the observed total. Thus \(\alpha=0\) solves the score equation and is the unique finite intercept because \(0<S<M\). Notice that applying the no-offset formula to the pooled proportion would instead give \(\log(4/(6-4))=\log 2\), which is not the offset-model solution.

For a Poisson log-link model with offset, \(\mu_i(\alpha)=\exp(\alpha+o_i)\). The score equation is

$$ \sum_iY_i-\exp(\alpha)\sum_i\exp(o_i)=0. $$

If \(\sum_iY_i>0\), every \(\exp(o_i)\) is positive and finite, so the unique solution is

$$ \hat\alpha_0 =\log\left(\frac{\sum_iY_i}{\sum_i\exp(o_i)}\right). $$

The denominator is the sum of the known exposure multipliers on the log scale. This expression reduces to \(\log(\sum_iY_i/n)\) when every offset is zero. If the total count is zero, no finite Poisson intercept solves the score equation; the likelihood approaches its supremum as \(\alpha\) tends to \(-\infty\).

Worked Example: A Poisson Intercept With Exposure Offsets

Suppose counts are \(Y=(2,6,4)\) and offsets are \(o=(\log 1,\log 2,\log 3)\). The count total is \(12\), while the sum of the exposure multipliers is \(1+2+3=6\). Therefore

$$ \hat\alpha_0=\log(12/6)=\log 2\approx0.6931. $$

The fitted means are \(\exp(\log 2+\log 1)=2\), \(\exp(\log 2+\log 2)=4\), and \(\exp(\log 2+\log 3)=6\). Their sum is \(12\), as required by the score equation. The raw average count is \(12/3=4\), but that is not a common fitted mean when the offsets differ.

Using the Intercept as a Starting Value

In a model with covariates, these calculations provide a baseline rather than a claim that the full model has been fitted. Setting slope coefficients to zero leaves the intercept-only predictor, and the margin-based intercept gives the corresponding starting means. With no offset this baseline mean is constant; with offsets it varies according to the known offset while the intercept adjusts the overall level.

For the offset logistic binomial case, the monotone equation can be solved numerically. A bracket can be expanded until its lower endpoint gives a fitted total below \(S\) and its upper endpoint gives one above \(S\); bisection then converges because the function is continuous and strictly increasing. In practice, a safeguarded root solver can use the same monotonicity. The relevant target is the total fitted successes, not an unweighted average of group probabilities.

Common Mistakes

  • Using the wrong grouped-binomial margin. Averaging \(Y_i/m_i\) without weights treats a group with one trial like a group with many trials. Use \(\sum_iY_i/\sum_i m_i\).
  • Applying the no-offset formula when offsets vary. The pooled success proportion does not generally determine an offset logistic intercept by a simple logit. Solve \(\sum_i m_i\operatorname{expit}(\alpha+o_i)=S\).
  • Using the Poisson mean as the intercept. With a log link, the intercept is the logarithm of the fitted mean, not the mean itself.
  • Assuming every group has positive trial count. A zero-trial group contributes zero to both the total trial count and the score. For uniqueness in the interior-margin result, it is enough that \(M>0\), which ensures at least one positive \(m_i\).
  • Ignoring boundary totals. All failures, all successes, or an all-zero Poisson sample do not yield a finite intercept-only maximum. Do not substitute a boundary proportion into a logarithm and treat the result as finite.
Key takeaway: Match the intercept-only fitted total to the observed response total. The resulting intercept is a logit of the pooled success odds for Bernoulli or binomial data without offsets, a log sample mean for Poisson data without offsets, and the solution to an offset-adjusted score equation when the offsets vary.

Check Your Understanding

Work through these questions by identifying the response margin and the equation the intercept must satisfy.

  1. In a Bernoulli sample of 20 observations with 8 successes, what is the logistic intercept-only starting value?
  2. For grouped binomial data with \(S=15\) successes out of \(M=25\) trials, what pooled proportion and intercept are used when there is no offset?
  3. Why can a zero-trial group be present without changing the grouped-binomial intercept start? What condition on \(M\) is still needed for the interior-margin uniqueness result?
  4. For Poisson counts with total \(18\) across 6 observations and no offset, calculate the intercept and verify the implied mean.
  5. In a Poisson model with offsets, explain why the intercept uses \(\sum_i\exp(o_i)\) rather than the number of observations in its denominator.
  6. What happens to the finite-intercept calculation for a logistic binomial model if all trials are failures?
Clinical Biostats