Tutorials › Marginal Structural Models › Conditional Outcome Models for Longitudinal Histories

The Parametric g-Formula · Tutorial 300 of 501

Conditional Outcome Models for Longitudinal Histories

Formulate and interpret conditional outcome models for terminal binary or continuous outcomes and discrete-time events, and see how their assumptions affect g-computation.

Advanced 12 min read

What You'll Learn

  • Define the treatment and covariate histories on which a longitudinal outcome regression is conditioned.
  • Specify logistic models for binary outcomes and interpret their conditional probabilities.
  • Specify Gaussian models for continuous outcomes and distinguish mean from variance assumptions.
  • Formulate discrete-time event hazards for individuals still at risk.
  • Recognize why outcome-model fit, history support, and functional form matter for g-computation.

Why Model the Outcome Given the History?

In the parametric g-formula, the outcome model describes how the outcome distribution varies with treatment and covariate histories. It is not merely a regression chosen to summarize associations: its conditional predictions are used as part of a longitudinal calculation under specified treatment regimes. Consequently, the model must represent the outcome distribution at histories that arise under those regimes, not just fit the observed outcomes overall.

Use the following time ordering. At baseline, \(L_0\) is observed. At each time \(t=0,\ldots,K\), treatment \(A_t\) is assigned after observing \(L_t\). The terminal outcome \(Y\) is observed after \(A_K\). Write \(\bar L_t=(L_0,\ldots,L_t)\) and \(\bar A_t=(A_0,\ldots,A_t)\). The history available after the final treatment is \((\bar L_K,\bar A_K)\). If past outcomes are measured and inform later outcomes, they should also be included in the relevant history.

Definition: A conditional outcome model specifies the conditional distribution of an outcome given treatment and covariate history. For a terminal outcome, this is \(P(Y\mid \bar L_K,\bar A_K)\), or a chosen feature of that distribution such as \(E[Y\mid \bar L_K,\bar A_K]\). A parametric outcome model specifies this conditional distribution through a finite-dimensional model, such as logistic or Gaussian regression.

The outcome regression does not, by itself, make a causal comparison. Causal interpretation of regime-specific predictions also relies on assumptions such as consistency and sequential exchangeability, as well as support for the histories needed by the regimes. The earlier material on identification under sequential exchangeability and the longitudinal g-formula supplies that causal framework. This tutorial focuses on specifying the conditional outcome law that enters the calculation.

Binary and Continuous Terminal Outcomes

For a binary outcome, a standard choice is a logistic regression for the conditional mean. Let \(Y\in\{0,1\}\), and let \(h(\bar L_K,\bar A_K)\) be a specified vector of history features, including an intercept. A logistic model is

$$ \operatorname{logit}\{P(Y=1\mid \bar L_K,\bar A_K)\} = h(\bar L_K,\bar A_K)^\mathsf{T}\beta, \qquad \operatorname{logit}(p)=\log\left(\frac{p}{1-p}\right). $$

It implies the conditional probability \(P(Y=1\mid \bar L_K,\bar A_K)=\operatorname{expit}\{h^\mathsf{T}\beta\}\), where \(\operatorname{expit}(u)=1/(1+e^{-u})\). Logistic regression ensures predictions lie strictly between zero and one for finite linear predictors. It does not ensure that the chosen features adequately describe how risk varies with time, treatment, or covariates.

For a continuous outcome, one possible model is a Gaussian conditional distribution:

$$ Y\mid \bar L_K,\bar A_K \sim N\left\{m(\bar L_K,\bar A_K),\sigma^2\right\}, \qquad m(\bar L_K,\bar A_K)=h(\bar L_K,\bar A_K)^\mathsf{T}\beta. $$

This specifies both a conditional mean and a conditional variance. A normal model with constant variance is an assumption about the whole conditional distribution, not just a convenient way to estimate the mean. If the outcome is skewed, bounded, or has variance changing markedly with history, a Gaussian conditional law may be inappropriate even if its mean regression is useful. In g-computation, simulating outcomes from the model requires a distributional specification; predicting only the mean is not equivalent when later calculations depend on the outcome distribution.

Result: Under the logistic model, the conditional probability is the inverse-logit of the linear predictor. Indeed, if \(p=P(Y=1\mid \bar L_K,\bar A_K)\) and \(\log\{p/(1-p)\}=\eta\), then \(p/(1-p)=e^\eta\), so \(p=e^\eta(1-p)\), and therefore \(p=e^\eta/(1+e^\eta)=1/(1+e^{-\eta})\). This conversion is exact for every finite \(\eta\).

Worked Example: A Binary Outcome With a Treatment-History Interaction

Suppose there are two treatment times, \(A_0,A_1\in\{0,1\}\), and a binary covariate \(L_1\). Consider the model

$$ \operatorname{logit}P(Y=1\mid L_1,A_0,A_1) =-2+0.5L_1+0.8A_0+0.6A_1+0.4A_0A_1. $$

For history \(L_1=1,A_0=1,A_1=0\), the linear predictor is \(-2+0.5+0.8=-0.7\). The predicted probability is \(1/(1+e^{0.7})\approx 0.332\). For history \(L_1=1,A_0=1,A_1=1\), the predictor is \(-2+0.5+0.8+0.6+0.4=0.3\), giving probability \(1/(1+e^{-0.3})\approx 0.574\).

The interaction means the effect of changing \(A_1\) on the log odds depends on \(A_0\). When \(A_0=0\), changing \(A_1\) changes the predictor by \(0.6\); when \(A_0=1\), it changes it by \(0.6+0.4=1.0\). The predicted probabilities are conditional on the stated histories. They are not yet averages over the covariate histories expected under a treatment regime.

Worked Example: A Continuous Outcome and Its Conditional Distribution

Suppose a continuous outcome is modeled as

$$ Y\mid L_1,A_0,A_1\sim N(10+2L_1-1.5A_0+3A_1,\; 4). $$

The second argument is the variance, so the conditional standard deviation is \(\sqrt{4}=2\). At \(L_1=2,A_0=1,A_1=0\), the conditional mean is \(10+2(2)-1.5=12.5\). The model assigns \(Y\) a normal distribution with mean \(12.5\) and variance \(4\) at that history.

At \(L_1=2,A_0=1,A_1=1\), the mean is \(15.5\), with the same variance under this model. Thus the model represents a constant conditional mean increment of \(3\) for \(A_1\), while also imposing constant residual variance and normal conditional errors. Those distributional restrictions need to be assessed, not inferred from the mean equation alone.

Event Outcomes: Model the Conditional Hazard

For an event recorded over discrete intervals, define \(D_t=1\) if the event occurs in interval \(t\), and \(R_t=1\) if the individual is event-free and observed at risk at the start of that interval. A conditional hazard model describes the probability of an event during interval \(t\), given that the individual is at risk and the observed history through the treatment in that interval:

$$ \lambda_t(\bar l_t,\bar a_t) = P(D_t=1\mid R_t=1,\bar L_t=\bar l_t,\bar A_t=\bar a_t). $$

A logistic discrete-time hazard model might use a separate intercept for each interval and selected history features:

$$ \operatorname{logit}\{\lambda_t(\bar l_t,\bar a_t)\} =\alpha_t+g(\bar l_t,\bar a_t)^\mathsf{T}\gamma. $$

The at-risk condition is essential: after an event, the person is no longer at risk for a first event. A recorded absence of an event in an interval is not interchangeable with missing follow-up. If censoring occurs, the observed event process and the censoring process must be distinguished; treating censored intervals as event-free can misrepresent the conditional event law.

Worked Example: Specifying a Discrete-Time Event Model

Consider a study with three intervals and a binary treatment \(A_t\). Suppose the conditional hazard model is

$$ \operatorname{logit}(\lambda_t) =\alpha_t+0.7A_t+0.3A_{t-1}, $$

where the lagged-treatment term is included only for \(t\geq1\). Let \((\alpha_0,\alpha_1,\alpha_2)=(-3,-2.5,-2)\). For an individual at risk in interval 1 with \(A_0=1,A_1=0\), the logit hazard is \(-2.5+0+0.3=-2.2\), so \(\lambda_1=1/(1+e^{2.2})\approx0.100\). For an individual at risk in interval 2 with \(A_1=0,A_2=1\), it is \(-2+0.7+0=-1.3\), so \(\lambda_2=1/(1+e^{1.3})\approx0.214\).

These are conditional interval-specific probabilities among individuals still at risk, not marginal probabilities for the study population. The interval intercepts allow the baseline hazard to change over time. The model still assumes that the selected treatment-history terms adequately describe the conditional hazards.

Likelihood Contributions and Model Checks

The conditional outcome model contributes a likelihood factor determined by the outcome type. For independent individuals \(i=1,\ldots,n\), the conditional likelihood is the product of their outcome probabilities or densities given their histories. For a binary outcome with fitted probabilities \(p_i\), the contribution is \(p_i^{Y_i}(1-p_i)^{1-Y_i}\). This follows by considering the two possible observed values: it equals \(p_i\) when \(Y_i=1\), and \(1-p_i\) when \(Y_i=0\).

For a continuous outcome with conditional density \(f(y_i\mid \bar l_{Ki},\bar a_{Ki})\), the contribution is that density evaluated at the observed value. For a discrete-time event, let \(T_i\) be the event interval, if observed before the end of follow-up. Conditional on the realized histories and risk indicators, the event-process contribution is the product of \(\lambda_{it}\) for event intervals and \(1-\lambda_{it}\) for observed at-risk intervals without an event. This is a direct application of the chain rule to the sequential event indicators, conditional on the information available at each interval; it does not treat post-event intervals as if the person remained at risk.

A well-fitting overall outcome model can still be inadequate for g-computation. The relevant checks concern conditional behavior across history: compare observed and fitted outcome frequencies or residual patterns across treatment and covariate strata, inspect calibration over time for event hazards, and examine whether the model uses plausible functional forms. Sparse or absent histories make these checks weak and can force predictions to rely on extrapolation. The earlier material on outcome-blind diagnostics is a reminder that good treatment or covariate diagnostics do not establish that the outcome regression is correctly specified.

1
State the outcome and its timing.
Distinguish a terminal binary or continuous measurement from an event indicator recorded over intervals.
2
Define the conditioning history.
Include the treatment and covariate information available before the outcome being modeled; add past outcomes when they belong to that history.
3
Choose a conditional distribution.
Use a model compatible with the outcome support, and make its link, mean, variance, or hazard assumptions explicit.
4
Assess conditional fit and support.
Look for systematic prediction errors across histories and identify predictions that depend on sparse or unsupported combinations.

Alternatives, Limitations, and a Common Pitfall

A parametric conditional model is one way to represent the outcome law. A more flexible regression method may reduce reliance on a particular linear predictor, but flexibility does not remove the need for histories to be represented in the data or for predictions to be suitable for the g-formula calculation. A direct comparison of observed outcomes between treatment groups is another possible analysis, but it does not generally replace modeling the conditional outcome distribution over longitudinal histories when treatment and covariates evolve over time.

The principal limitation is model dependence: incorrect links, omitted interactions, inadequate time trends, or misspecified conditional variances can distort predictions. Even a correctly specified regression form cannot recover information for histories with no relevant support. Conversely, adding many terms can make estimates unstable in sparse histories. Model choice should therefore reflect the scientific timing and plausible outcome mechanisms, and diagnostics should be interpreted alongside support.

Common pitfall: “The treatment coefficient in a logistic outcome regression is the marginal causal effect, so I can report it as the regime contrast.” This reasoning confuses a conditional model coefficient with an average over the covariate histories that would occur under a regime. Logistic coefficients are conditional log-odds contrasts, and in general they are not marginal contrasts. The correction is to use the fitted conditional outcome law within the longitudinal g-formula, averaging over the appropriate covariate histories for each regime. The coefficient alone does not perform that averaging.

Key takeaway: Specify the conditional outcome distribution at the correct point in the longitudinal history. Binary regressions model conditional probabilities, continuous models require explicit distributional assumptions, and event models condition on being at risk. The resulting conditional predictions are ingredients of g-computation, not marginal regime effects by themselves.

Check Your Understanding

Answer each question, then compare with the solutions below.

  1. In a logistic model with linear predictor \(\eta\), how do you obtain the conditional event probability?
  2. A Gaussian outcome model has conditional variance \(9\). What is its conditional standard deviation, and what additional distributional assumption does the model make beyond specifying a mean?
  3. Why must a discrete-time hazard be defined among individuals at risk at the start of the interval?
  4. Why is a treatment coefficient in a conditional logistic outcome model not automatically a marginal regime contrast?

Solutions. (1) The probability is \(\operatorname{expit}(\eta)=1/(1+e^{-\eta})\), obtained by solving \(\log\{p/(1-p)\}=\eta\) for \(p\). (2) The standard deviation is \(\sqrt{9}=3\). A Gaussian conditional model also assumes normality and, if one variance is used for all histories, a constant conditional variance. (3) After an event, an individual is no longer eligible to experience a first event in a later interval; the hazard is therefore conditional on being event-free and at risk. (4) The coefficient is a conditional log-odds parameter. A marginal regime contrast additionally averages conditional predictions over the covariate histories under each regime, so the coefficient alone does not equal that contrast in general.

Clinical Biostats