Tutorials › Marginal Structural Models › Flexible Baseline Hazards for Pooled Logistic Models

Fitting MSMs for Survival Outcomes · Tutorial 191 of 501

Flexible Baseline Hazards for Pooled Logistic Models

Learn how time coding controls baseline-hazard flexibility in weighted pooled logistic models, and how to assess the consequences of pooling intervals.

Advanced 12 min read

What You'll Learn

  • Specify a saturated categorical baseline hazard and a grouped-time alternative.
  • Derive how weighted event totals determine fitted interval hazards.
  • Calculate the baseline odds implied by pooling intervals.
  • Diagnose when grouped time effects fail to represent observed hazard patterns.
  • Compare flexibility, stability, and interpretability across time codings.

Why the Time Coding Matters

In a weighted pooled logistic survival model, each person contributes a row for every interval in which they remain at risk. The treatment terms describe how the modeled discrete hazard changes with treatment history; the baseline time terms describe how that hazard changes over intervals apart from treatment. If the baseline time terms are too restrictive, a treatment term can be asked to account for time-pattern differences it was not intended to represent.

The introductory material on Encoding Baseline Hazards in Pooled Logistic MSMs establishes how interval indicators can enter the model. Here the focus is the choice between giving every interval its own baseline parameter and using grouped time effects that share a parameter across intervals. Grouping means pooling model parameters, not replacing the person-interval data with aggregated counts.

Definition: Let \(R_{it}=1\) indicate that person \(i\) is at risk at the start of interval \(t\), and let \(Y_{it}=1\) indicate an event in that interval. A weighted pooled logistic model specifies the discrete hazard among those at risk as $$ \operatorname{logit}\{P(Y_{it}=1\mid R_{it}=1,\bar A_{it})\} =\alpha_t+\beta^\top g(\bar A_{it}). $$ Here \(\bar A_{it}\) denotes the treatment history represented in the model, \(g(\bar A_{it})\) is its chosen set of predictors, \(\beta\) is the treatment-parameter vector, and \(\alpha_t\) is the baseline log odds for interval \(t\). The rows are fitted using nonnegative analysis weights \(W_{it}\), typically treatment weights and any other weights required by the analysis.

The model is a marginal structural model when its treatment-history terms describe the marginal structural outcome model and the weights are constructed for that analysis. For the time-coding comparison below, assume that intervals are defined consistently, events are observed for the risk rows used, and the weights are finite. Interpreting the fitted treatment parameters causally additionally requires the usual identification conditions, including consistency, sequential exchangeability, and positivity. Time coding does not repair failures of those conditions.

Two Ways to Represent Baseline Time

With \(K\) intervals, a categorical time effect assigns a separate \(\alpha_t\) to each interval. In a regression formula, this is an intercept plus \(K-1\) interval indicators, with one interval as the reference. The reference choice changes the coefficient representation, not the fitted interval-specific baseline hazards.

A grouped time effect partitions the intervals into \(G\) groups and assigns one intercept to each group. If \(c(t)\) gives the group containing interval \(t\), the baseline term is \(\alpha_{c(t)}\). Intervals in the same group are therefore constrained to have the same baseline log odds, after accounting for the treatment terms. The model still includes every eligible person-interval row and its weight.

FeatureCategorical time indicatorsGrouped time effects
Baseline parametersOne per intervalOne per group of intervals
Time pattern allowedArbitrary across the observed intervalsConstant within each group
Main advantageDoes not impose equality across intervalsFewer parameters and potential stabilization
Main riskMany weakly informed interval estimatesMisspecification when grouped intervals have different hazards

Worked Example: Interval Indicators With Weighted Event Totals

Consider a baseline-only model with two intervals. The total weight among at-risk rows is 100 in each interval. The weighted event totals are 10 in interval 1 and 20 in interval 2. With a separate intercept for each interval, the weighted event fractions are \(10/100=0.10\) and \(20/100=0.20\).

For a baseline-only logistic model, the fitted probability in each interval equals its weighted event fraction. The corresponding fitted log odds are $$ \hat\alpha_1=\log\left(\frac{0.10}{1-0.10}\right) =\log(1/9)\approx -2.197, \qquad \hat\alpha_2=\log\left(\frac{0.20}{1-0.20}\right) =\log(1/4)\approx -1.386. $$

The categorical model preserves the difference between the two interval-specific weighted hazards: the fitted probabilities are 0.10 and 0.20. The intercepts are log odds, not risks; for example, \(\exp(\hat\alpha_1)=1/9\) is the odds corresponding to a risk of 0.10.

Worked Example: Pooling Two Intervals Into One Group

Use the same weighted totals, but now constrain both intervals to have a common baseline intercept and include no treatment predictors. The total weighted event contribution is \(10+20=30\), and the total weight at risk is \(100+100=200\). The common fitted probability is therefore $$ \hat p=\frac{30}{200}=0.15. $$

Its log odds are $$ \hat\alpha=\log\left(\frac{0.15}{1-0.15}\right) =\log(3/17)\approx -1.735. $$ The grouped model predicts 0.15 in each interval, rather than 0.10 and 0.20. It matches the combined weighted event total, but does not match either interval-specific total individually. Pooling is thus a constraint on the modeled baseline pattern, not a harmless relabeling of time.

What the Weighted Score Equations Guarantee

The score equations make the distinction precise. Write \(\operatorname{expit}(x)=1/\{1+\exp(-x)\}\), and let \(\hat p_{it}\) denote the fitted hazard for a risk row. For fixed treatment coefficients, differentiating the weighted Bernoulli log-likelihood contribution with respect to a baseline intercept gives a weighted residual, \(W_{it}(Y_{it}-\hat p_{it})\). These equations describe the fitted weighted calibration; they do not require the weights to be integer replication counts.

Result: Suppose the treatment coefficients are fixed and the model has a separate intercept for every interval. At any finite solution, the weighted fitted event total equals the observed weighted event total in each interval: $$ \sum_{i:R_{it}=1}W_{it}\hat p_{it} = \sum_{i:R_{it}=1}W_{it}Y_{it} \qquad \text{for every }t. $$ If there are no treatment predictors, and the weighted event and non-event totals in each interval are both positive, this implies that the fitted interval probability is the weighted event fraction for that interval.

To prove the result, the weighted log-likelihood terms involving \(\alpha_t\), with the treatment coefficients held fixed, are $$ \ell_t(\alpha_t)= \sum_{i:R_{it}=1}W_{it} \left[ Y_{it}(\alpha_t+\eta_{it}) -\log\{1+\exp(\alpha_t+\eta_{it})\} \right], $$ where \(\eta_{it}=\beta^\top g(\bar A_{it})\). Differentiating gives $$ \frac{\partial\ell_t}{\partial\alpha_t} = \sum_{i:R_{it}=1}W_{it} \{Y_{it}-\operatorname{expit}(\alpha_t+\eta_{it})\}. $$ At a finite maximum, this derivative is zero, which is exactly the weighted calibration equation in the result. If \(\eta_{it}=0\) for every row, the fitted probability is a common \(p_t\) within interval \(t\). The equation becomes \(p_t\sum_i W_{it}=\sum_i W_{it}Y_{it}\), so \(p_t\) is the weighted event total divided by the total weight at risk. Positive event and non-event totals ensure this fraction lies strictly between zero and one and has finite log odds. \(\square\)

For grouped effects, the same differentiation applies to the shared group intercept, but the score sums over all intervals in that group. With no treatment predictors, it gives the group’s weighted event fraction. With treatment predictors, the score instead balances observed and fitted weighted event totals across the group, while allowing fitted hazards to vary by treatment history.

Result: In a baseline-only logistic model with one intercept for each group \(g\), a finite fitted group intercept satisfies $$ \sum_{t:c(t)=g}\sum_{i:R_{it}=1}W_{it}\hat p_{it} = \sum_{t:c(t)=g}\sum_{i:R_{it}=1}W_{it}Y_{it}. $$ When the fitted probability is common to all rows in group \(g\), it equals the group’s combined weighted event total divided by its combined weight at risk. This is a group-level calibration, not an interval-by-interval calibration.

For a complete derivation, collect the log-likelihood terms from all rows whose interval belongs to group \(g\). Differentiation with respect to the shared \(\alpha_g\) yields $$ \frac{\partial\ell_g}{\partial\alpha_g} = \sum_{t:c(t)=g}\sum_{i:R_{it}=1} W_{it}\{Y_{it}-\hat p_{it}\}. $$ At a finite maximum this derivative is zero, yielding the displayed equation. If there are no treatment predictors, \(\hat p_{it}=p_g\) is constant within the group. Solving gives \(p_g=\sum_{t:c(t)=g}\sum_i W_{it}Y_{it}/\sum_{t:c(t)=g}\sum_i W_{it}\). As before, positive weighted event and non-event totals give a finite logit. \(\square\)

Choosing and Checking a Grouping

Worked Example: A Two-Group Time Pattern

Suppose four intervals each have total weight 1,000 at risk. The weighted event totals are 50, 60, 200, and 220. A two-group specification places intervals 1 and 2 in an early group, and intervals 3 and 4 in a late group. With no treatment predictors, the early group has weighted event fraction $$ \frac{50+60}{1000+1000}=0.055, \qquad \hat\alpha_{\mathrm{early}} =\log\left(\frac{0.055}{0.945}\right) \approx -2.845. $$

The late group has weighted event fraction $$ \frac{200+220}{1000+1000}=0.21, \qquad \hat\alpha_{\mathrm{late}} =\log\left(\frac{0.21}{0.79}\right) \approx -1.326. $$ The grouped model captures a marked difference between early and late time while imposing equality within each pair. Whether that constraint is credible depends on the interval-level pattern: it would not reproduce the differences between 0.05 and 0.06, or between 0.20 and 0.22, exactly.

A defensible grouping should reflect the time scale and the amount of information available in each interval. Prespecified blocks can be useful when neighboring intervals represent similar durations or phases of follow-up. They should not be chosen only because they produce a preferred treatment estimate. Inspect weighted risk and event totals by interval, and compare interval-specific observed weighted event fractions with fitted hazards. Large within-group discrepancies are a warning that the shared-intercept assumption is doing consequential work.

The categorical model is the direct choice when the number of intervals is manageable and distinct baseline patterns are plausible. Grouping can reduce the number of baseline parameters, but it trades interval-level fit for a shared pattern. A simple linear time term is another lower-dimensional alternative, but it imposes a particular trend on the log odds rather than equality within chosen groups. No one coding is automatically best: the choice concerns which time patterns are plausible and supported by the data.

Diagnostics, Pitfalls, and Limits

  • Compare at the interval level. A grouped model can satisfy its group score equation while miscalibrating individual intervals. Check each interval, not only the combined group.
  • Check weighted support. An interval with few events or little total weight may have an unstable categorical estimate. Grouping can increase pooled information, but it cannot establish that the grouped intervals share a hazard.
  • Watch for time-treatment imbalance. If treatment histories are distributed differently across intervals, an inadequate baseline pattern can be entangled with the treatment terms in the joint fit. A changed treatment estimate under alternative reasonable time codings is a sensitivity signal, not proof that one coding is correct.
  • Do not interpret the intercept as a risk without its scale. The intercept is a log odds at the reference values of the treatment predictors. Its inverse-logit gives a hazard only at those values and under the specified model.
  • Do not aggregate away the risk rows. The grouping shares coefficients; it does not authorize dropping person-interval rows or ignoring their weights.

Both specifications are limited by the observed interval structure and the chosen treatment-history model. A saturated baseline uses more parameters and can be weakly informed in intervals with little weighted support. Grouping imposes equality that may be false. Neither choice corrects incorrect weights, violations of causal identification assumptions, or an incorrect treatment-effect structure. Assessing sensitivity across plausible codings is useful, but it is not a substitute for specifying the target model and time scale carefully.

Check Your Understanding

Answer each question, then compare with the solutions below.

  1. In a baseline-only model, an interval has weighted event total 8 and total weight at risk 80. What are its fitted probability and baseline log odds under a categorical time effect?
  2. Two intervals each have total weight at risk 50 and weighted event totals 5 and 15. If they share one grouped intercept with no treatment predictors, calculate the fitted probability.
  3. Why can a grouped model match the combined weighted event total but fail to match the weighted event total in either interval separately?
  4. Name one diagnostic for an overly restrictive grouping and one limitation that grouping does not solve.

Solutions. (1) The fitted probability is \(8/80=0.10\). The baseline log odds are \(\log\{0.10/0.90\}=\log(1/9)\approx-2.197\). (2) The combined event total is \(5+15=20\), and the combined weight at risk is \(50+50=100\), so the fitted probability is \(20/100=0.20\). (3) The grouped intercept has one score equation summing residuals over both intervals; positive residuals in one interval can offset negative residuals in the other. (4) Compare observed and fitted weighted event fractions separately by interval. Grouping does not correct incorrect weights or failures of causal identification assumptions.

Clinical Biostats