Tutorials › Generalized Linear Models › Initial Values with Offsets, Trials, and Exposure

Initialization and Numerical Stability · Tutorial 228 of 981

Initial Values with Offsets, Trials, and Exposure

Learn to initialize intercepts by matching the correct trial-weighted or exposure-weighted total, including when binomial offsets require a numerical solution.

Intermediate 10 min read

What You'll Learn

  • Distinguish a binomial count from its observed proportion when initializing a model.
  • Derive the intercept that matches the total number of binomial successes.
  • Solve for a binomial intercept when observations have different offsets.
  • Derive the Poisson intercept for counts observed over unequal exposures.
  • Recognize when a finite margin-matching intercept does not exist.
  • Diagnose why raw averages can produce poorly targeted fitted means.

Why margins must match the observation structure

An initial intercept is useful when it gives the optimizer fitted means on a sensible scale before slopes are updated. For ordinary binary responses without offsets, the response proportion often provides a direct starting point. With grouped binomial data, however, observations can represent different numbers of trials; with Poisson data, counts can correspond to different exposure durations or populations at risk. In both cases the model’s total expected response depends on those trial counts or exposures. An unweighted average of the recorded responses generally does not match that total.

This tutorial derives intercept starts by setting the slopes to zero and matching the model’s fitted total to the observed total. The resulting start is a computational choice, not a claim that the intercept-only model describes all the structure in the data. Offsets remain part of the linear predictor: they are known contributions and are not estimated as coefficients.

Binomial counts: match successes across trials

Definition: For grouped binomial observations, let \(Y_i\sim\operatorname{Bin}(m_i,p_i)\), where \(m_i\) is the number of trials and \(Y_i\) is the number of successes, for \(i=1,\ldots,n\). In a logistic model with known offset \(o_i\) and covariate vector \(x_i\), write \( \operatorname{logit}(p_i)=o_i+x_i^\mathsf{T}\beta \), where \(\operatorname{logit}(p)=\log\{p/(1-p)\}\). An intercept-only starting fit sets the slopes to zero and uses \(\operatorname{logit}(p_i)=\alpha+o_i\).

If all offsets are zero, setting the intercept so that each fitted probability is the same makes the fitted expected number of successes equal the observed total when \( \sum_i m_i p_i=\sum_i Y_i. \) Thus the probability to use is the pooled proportion of successes, not the mean of the observation-specific proportions. When offsets differ, a single probability cannot be assigned to every group: the intercept must instead be chosen so that the offset-adjusted probabilities have the right trial-weighted total.

Worked Example: Unequal Numbers of Binomial Trials

Suppose two groups have \(Y_1=8\) successes in \(m_1=10\) trials and \(Y_2=9\) successes in \(m_2=30\) trials. There are no offsets. Find the intercept-only logistic starting value by matching the total number of successes.

The observed total number of successes is \(8+9=17\), and the total number of trials is \(10+30=40\). The common fitted probability must therefore satisfy \(40p=17\), so \(p=17/40=0.425\).

The intercept is the logit of this pooled probability: \( \alpha=\log\left(\frac{0.425}{1-0.425}\right) =\log\left(\frac{17}{23}\right)\approx -0.3023. \) The fitted expected counts are \(10(0.425)=4.25\) and \(30(0.425)=12.75\); their sum is \(17\), as required.

The unweighted mean of the two observed proportions is \((8/10+9/30)/2=(0.8+0.3)/2=0.55\). It would imply \(40(0.55)=22\) fitted successes, not 17. The two groups do not contribute equal numbers of trials, so averaging their proportions equally does not match the observed margin.

Binomial offsets: solve a weighted intercept equation

With offsets, the intercept-only fitted probabilities are \(p_i(\alpha)=\operatorname{logit}^{-1}(\alpha+o_i)\), where \(\operatorname{logit}^{-1}(u)=1/(1+\exp(-u))\). The margin-matching equation is \( \sum_i m_i\operatorname{logit}^{-1}(\alpha+o_i)=\sum_i Y_i. \) Except in special cases, it does not reduce to taking the logit of one pooled proportion and subtracting a common offset. The probabilities differ across observations, and each is weighted by its number of trials.

Result: Suppose every \(m_i>0\), all offsets \(o_i\) are finite, and the observed total \(Y=\sum_iY_i\) satisfies \(0<Y<M\), where \(M=\sum_i m_i\). Then the binomial margin-matching equation has exactly one finite solution \(\alpha\).

To prove this, define \(F(\alpha)=\sum_i m_i\operatorname{logit}^{-1}(\alpha+o_i)\). Each inverse-logit term is continuous and strictly increasing in \(\alpha\), so \(F\) is continuous and strictly increasing. Because each offset is finite, \( \lim_{\alpha\to-\infty}F(\alpha)=0,\qquad \lim_{\alpha\to+\infty}F(\alpha)=M. \) The condition \(0<Y<M\) therefore places \(Y\) strictly between these limits. The intermediate value theorem gives a solution to \(F(\alpha)=Y\), and strict increase gives uniqueness. A scalar root finder, such as bisection on a bracket with \(F(\alpha_{\rm low})<Y<F(\alpha_{\rm high})\), can compute it. \(\square\)

The interior-total condition matters. If \(Y=0\), fitted probabilities approach zero only as \(\alpha\to-\infty\); if \(Y=M\), they approach one only as \(\alpha\to+\infty\). In either case there is no finite intercept that exactly matches the total.

Worked Example: Two Binomial Groups With Different Offsets

Two groups each have \(m_i=10\) trials. Their offsets are \(o_1=0\) and \(o_2=\log 2\), and the observed success counts are \(Y_1=5\) and \(Y_2=7\). Find the margin-matching logistic intercept.

The observed total is \(12\). Let \(z=\exp(\alpha)>0\). The fitted probabilities are \(p_1=z/(1+z)\) and \(p_2=2z/(1+2z)\), because \(\exp(\alpha+\log 2)=2z\). Matching the total requires \(10\{z/(1+z)+2z/(1+2z)\}=12\), or \(z/(1+z)+2z/(1+2z)=1.2\).

Combining fractions gives \((3z+4z^2)/(1+3z+2z^2)=1.2\). Multiplying through and rearranging yields \(1.6z^2-0.6z-1.2=0\), equivalently \(4z^2-1.5z-3=0\). The positive root is \( z=\{1.5+\sqrt{50.25}\}/8\approx1.0736\); the other root is negative and cannot equal \(\exp(\alpha)\). Hence \(\alpha=\log(1.0736)\approx0.0710\).

The resulting probabilities are approximately \(p_1=1.0736/2.0736=0.5177\) and \(p_2=2.1472/3.1472=0.6823\). Their fitted total is approximately \(10(0.5177)+10(0.6823)=12.000\), up to rounding. Taking the logit of the pooled proportion \(12/20=0.6\) would give an intercept near \(0.4055\), but with the stated offsets that intercept would not match the total.

Poisson counts: account for exposure

Definition: For Poisson counts with exposure \(t_i>0\), let \(Y_i\sim\operatorname{Poisson}(\mu_i)\), where \( \log(\mu_i)=\alpha+\log(t_i)+x_i^\mathsf{T}\beta. \) The known term \(\log(t_i)\) is an offset. With slopes set to zero, the model has \(\mu_i=t_i\exp(\alpha)\); \(\exp(\alpha)\) is the common event rate per unit of exposure.

The fitted total under this intercept-only start is \(\sum_i t_i\exp(\alpha)\). Setting it equal to the observed count total gives a closed-form intercept whenever the total count is positive: \( \hat\alpha_{\rm start}=\log\left(\frac{\sum_iY_i}{\sum_i t_i}\right). \) This is the log of the pooled count rate. It is not, in general, the log of the unweighted average of the individual rates \(Y_i/t_i\).

Result: If all exposures are positive and \(Y_\cdot=\sum_iY_i>0\), the intercept-only Poisson log-likelihood is maximized at \(\hat\alpha=\log(Y_\cdot/T_\cdot)\), where \(T_\cdot=\sum_i t_i\).

For fixed slopes equal to zero, the log-likelihood, omitting terms that do not depend on \(\alpha\), is \( \ell(\alpha)=\sum_i\{Y_i(\alpha+\log t_i)-t_i\exp(\alpha)\}+C, \) where \(C\) is constant in \(\alpha\). Its derivative is \( \ell'(\alpha)=\sum_iY_i-\exp(\alpha)\sum_i t_i =Y_\cdot-\exp(\alpha)T_\cdot. \) Setting this derivative to zero gives \(\exp(\alpha)=Y_\cdot/T_\cdot\). The second derivative is \( \ell''(\alpha)=-\exp(\alpha)T_\cdot<0 \), so the stationary point is the unique maximum. If \(Y_\cdot=0\), the derivative is negative for every finite \(\alpha\); the likelihood increases toward its supremum as \(\alpha\to-\infty\), and no finite intercept matches the total. \(\square\)

Worked Example: Counts With Unequal Poisson Exposures

Suppose counts of \(Y_1=2\) and \(Y_2=12\) are observed over exposures \(t_1=1\) and \(t_2=4\). Find the intercept-only Poisson starting value using \(\log(\mu_i)=\alpha+\log(t_i)\).

The total count is \(2+12=14\), and the total exposure is \(1+4=5\). The pooled rate is \(14/5=2.8\), so \(\alpha=\log(2.8)\approx1.0296\). The fitted means are \(\mu_1=1(2.8)=2.8\) and \(\mu_2=4(2.8)=11.2\). They sum to 14, matching the observed total.

The individual observed rates are \(2/1=2\) and \(12/4=3\); their unweighted average is \(2.5\). Using that average as the common rate would give fitted means \(2.5\) and \(10\), with total \(12.5\), not 14. The longer exposure contributes four times as much exposure as the shorter one, so the pooled rate must weight it accordingly.

Offsets and current slope values

The same margin principle applies if slopes have already been assigned starting values rather than set to zero. For a binomial logit model, replace \(o_i\) in the intercept equation by \(o_i+x_i^\mathsf{T}\beta^{(0)}\), where \(\beta^{(0)}\) is the chosen starting slope vector. For a Poisson log-link model, the fitted means become \(t_i\exp(\alpha+x_i^\mathsf{T}\beta^{(0)})\), and matching the total gives \( \hat\alpha_{\rm start} =\log\left\{\frac{\sum_iY_i}{\sum_i t_i\exp(x_i^\mathsf{T}\beta^{(0)})}\right\}, \) provided \(\sum_iY_i>0\). These formulas make explicit that the intercept compensates for the offsets and any nonzero starting linear predictors; it should not simply be copied from an offset-free calculation.

A practical sequence is to choose the slope starts, retain all known offsets, and then solve for the intercept that makes the total fitted mean agree with the observed total. For Poisson log-link models the equation is explicit. For binomial logit models with varying offsets, it is a one-dimensional monotone equation. In both cases the target is a total count: successes across trials for binomial data, and events across exposure for Poisson data.

Common mistake: averaging the recorded responses

A tempting shortcut is to average the observed proportions \(Y_i/m_i\) equally for binomial data, or the rates \(Y_i/t_i\) equally for Poisson data, and then transform that average into an intercept. That reasoning treats each row as if it represented the same number of trials or the same exposure. Unless the trial counts or exposures are equal, it can produce fitted means whose sum misses the observed total. The correction is to match the total directly: weight binomial probabilities by \(m_i\), and weight Poisson rates by \(t_i\). When offsets vary in a binomial model, solve the weighted equation rather than applying one pooled proportion to every group.

Key takeaway: A sound intercept start respects the units represented by each response. Match the sum of fitted successes to the observed successes, or the sum of fitted Poisson counts to the observed count total, while retaining every known offset.

Check Your Understanding

Use the model structure, not an unweighted response average, to answer each question.

  1. In grouped binomial data with trial counts \(m_i\) and no offsets, what pooled proportion determines the intercept-only logistic start?
  2. Why does a binomial logistic model with varying finite offsets have a unique finite margin-matching intercept when the total number of successes is strictly between zero and the total number of trials?
  3. For Poisson counts with exposures \(t_i\), write the intercept-only estimate that matches the observed total count.
  4. Two Poisson observations have equal observed rates but unequal exposures. Would an unweighted average of their rates necessarily give the correct pooled rate? Explain.
  5. What happens to the finite margin-matching intercept in the binomial case if every trial is a success, and in the Poisson case if the total observed count is zero?
Clinical Biostats