Tutorials › Marginal Structural Models › Binary and Categorical Covariate Transitions

The Parametric g-Formula · Tutorial 302 of 501

Binary and Categorical Covariate Transitions

Fit and interpret logistic or multinomial transition models, then use their predicted probabilities to generate covariate histories under a treatment regime.

Advanced 12 min read

What You'll Learn

  • Specify a conditional transition model for a binary time-varying covariate.
  • Interpret logistic-regression coefficients and calculate fitted transition probabilities.
  • Construct and check reference-category multinomial probabilities.
  • Use predicted probabilities to draw categorical covariate values sequentially.
  • Recognize sparse-data, calibration, and model-support problems in transition models.
  • Distinguish transition-model assumptions from assumptions about treatment assignment.

Why Model Covariate Transitions?

In the parametric g-formula, a time-varying covariate must be generated according to its distribution given the history that precedes it. When the covariate is binary or takes a small number of categories, logistic and multinomial regression provide familiar ways to specify that conditional distribution. The model’s predictions are probabilities for the next covariate value, not predictions of treatment assignment.

Use the following timing convention. At time \(t\), \(L_t\) is observed after treatment \(A_{t-1}\) and before treatment \(A_t\). Write the information available before \(L_t\) as \(H_t^L=(V,\bar L_{t-1},\bar A_{t-1})\), where \(V\) denotes baseline covariates, \(\bar L_{t-1}=(L_0,\ldots,L_{t-1})\), and \(\bar A_{t-1}=(A_0,\ldots,A_{t-1})\). Thus the transition of interest is \(P(L_t\mid H_t^L)\). A specified treatment regime supplies the treatment values in this history; as established in the earlier material on why g-computation does not model treatment assignment, the transition model is not a model for how treatment was allocated.

Definition: A covariate transition model specifies the conditional distribution of a time-varying covariate at time \(t\), given its preceding covariate and treatment history. For a binary covariate, it models \(P(L_t=1\mid H_t^L)\). For a categorical covariate with categories \(0,\ldots,J-1\), it models \(P(L_t=j\mid H_t^L)\) for each category \(j\).

The model must use variables that are available before the covariate being generated. If \(L_t\) is measured after \(A_{t-1}\), its model can include \(A_{t-1}\), but it cannot condition on a future treatment \(A_t\) or on a future covariate \(L_{t+1}\). This ordering is substantive: the transition probability is meant to describe how the covariate evolves given the history that has already occurred.

Binary Covariate Transitions With Logistic Regression

For a binary covariate, a standard model is logistic regression. Let \(x_t(H_t^L)\) be a specified vector of history features, including an intercept, and let \(\beta_t\) be its coefficient vector. A separate model can be fitted at each time, or a pooled model can include time indicators and shared coefficients.

$$ \operatorname{logit}\{p_t(H_t^L)\} = \log\left\{\frac{p_t(H_t^L)}{1-p_t(H_t^L)}\right\} = x_t(H_t^L)^\top\beta_t, \qquad p_t(H_t^L)=P(L_t=1\mid H_t^L) = \frac{\exp\{x_t(H_t^L)^\top\beta_t\}} {1+\exp\{x_t(H_t^L)^\top\beta_t\}}. $$

A coefficient describes a change in conditional log odds for a one-unit change in the corresponding feature, holding the other model features fixed. For example, a coefficient of \(0.8\) for a binary treatment indicator means that the conditional odds are multiplied by \(\exp(0.8)\), about \(2.23\), when that indicator changes from zero to one. It does not mean the probability rises by 0.8; the probability change depends on the other history values.

Worked Example: Calculating a Binary Transition Probability

Suppose a binary covariate \(L_t\) is modeled using a previous binary covariate \(L_{t-1}\) and treatment \(A_{t-1}\): \( \operatorname{logit}\{P(L_t=1\mid H_t^L)\}=-1+0.8A_{t-1}+0.5L_{t-1} \). Calculate the predicted probability when \(A_{t-1}=1\) and \(L_{t-1}=1\).

The linear predictor is \(-1+0.8(1)+0.5(1)=0.3\). Therefore,

$$ P(L_t=1\mid A_{t-1}=1,L_{t-1}=1) = \frac{\exp(0.3)}{1+\exp(0.3)} = \frac{1.3499}{2.3499} \approx 0.5744. $$

The model assigns probability \(0.5744\) to \(L_t=1\) and probability \(1-0.5744=0.4256\) to \(L_t=0\) for this history. The treatment coefficient changes the conditional log odds, but the transition probability is obtained by applying the inverse-logit transformation.

Categorical Transitions With Multinomial Logistic Regression

For a covariate with \(J\) unordered categories, a reference-category multinomial logistic model specifies \(J-1\) log odds. Choose category \(0\) as the reference and define a linear predictor \(\eta_{tj}(H_t^L)\) for each \(j=1,\ldots,J-1\). Set \(\eta_{t0}(H_t^L)=0\). The corresponding probabilities are

$$ P(L_t=j\mid H_t^L) = \frac{\exp\{\eta_{tj}(H_t^L)\}} {\sum_{k=0}^{J-1}\exp\{\eta_{tk}(H_t^L)\}}, \qquad j=0,\ldots,J-1. $$

Each non-reference linear predictor is commonly modeled as \(x_t(H_t^L)^\top\beta_{tj}\). Its coefficients describe changes in the log odds of category \(j\) relative to category \(0\). The resulting probabilities are a single distribution over all categories, not a collection of separately fitted binary probabilities that might fail to sum to one.

Worked Example: Computing Multinomial Transition Probabilities

Suppose \(L_t\) has categories \(0,1,2\), with category \(0\) as the reference. At one history, the fitted log odds are \(\eta_{t1}=0.3\) and \(\eta_{t2}=-0.3\). Calculate the probability of each category.

The unnormalized weights are \(\exp(0)=1\), \(\exp(0.3)\approx1.3499\), and \(\exp(-0.3)\approx0.7408\). Their sum is \(1+1.3499+0.7408=3.0907\). Thus

$$ P(L_t=0\mid H_t^L)=\frac{1}{3.0907}\approx0.3236,\quad P(L_t=1\mid H_t^L)=\frac{1.3499}{3.0907}\approx0.4368,\quad P(L_t=2\mid H_t^L)=\frac{0.7408}{3.0907}\approx0.2397. $$

The rounded probabilities add to \(0.3236+0.4368+0.2397=1.0001\); the unrounded probabilities sum to one. A useful check is to verify that each fitted probability is nonnegative and that the probabilities across the categories sum to one, allowing for rounding.

Fitting and Using the Transition Distributions

For observed individuals \(i=1,\ldots,n\), let \(l_{it}\) be the observed value of \(L_t\), and let \(h_{it}^L\) be that individual’s history before \(L_t\). Under independent sampling of individuals and a correctly specified collection of conditional transition models, the conditional likelihood contribution for the transitions is

$$ L(\beta) = \prod_{i=1}^{n}\prod_{t=1}^{K} P_{\beta}\bigl(L_t=l_{it}\mid H_t^L=h_{it}^L\bigr), \qquad \ell(\beta) = \sum_{i=1}^{n}\sum_{t=1}^{K} \log P_{\beta}\bigl(L_t=l_{it}\mid H_t^L=h_{it}^L\bigr). $$

The log-likelihood is the sum of the logarithms of the conditional probabilities. These expressions concern the transition distributions conditional on the observed histories; they do not add a treatment-assignment model. In practice, models may be fitted separately by time or pooled across times with time represented in the model. The choice depends on the number of observations, the amount of history information, and whether sharing parameters across times is defensible.

Once coefficients are estimated, substitute the histories of interest into the fitted model to obtain conditional probabilities. For a binary covariate, a draw can be generated using a uniform random variable \(U\sim\operatorname{Uniform}(0,1)\): set \(L_t=1\) if \(U\leq\hat p_t(H_t^L)\), and \(L_t=0\) otherwise. For a categorical covariate, form cumulative probabilities in category order and select the category whose interval contains \(U\). The next transition uses the newly generated history, not the original observed history.

Theorem: Fix a baseline value and a treatment regime. Suppose each categorical transition is drawn from its correctly specified conditional distribution given the preceding generated history, and each model assigns probabilities summing to one. Then the probability of any covariate path is the product of its successive transition probabilities. Consequently, sequential draws reproduce the joint distribution defined by those conditional models.

Proof. For a path \((l_1,\ldots,l_K)\) under the fixed regime, the chain rule for conditional probabilities gives \(P(L_1=l_1,\ldots,L_K=l_K)=\prod_{t=1}^{K}P(L_t=l_t\mid L_1=l_1,\ldots,L_{t-1}=l_{t-1})\), with the regime’s treatment values included in the conditioning history at each time. The transition-model assumption identifies each factor with the model probability evaluated at the history along this path. Sequential drawing assigns precisely that product probability to the path: at each draw, conditional on the previous draws, the probability of the required next category is the corresponding transition probability. Multiplying these conditional probabilities yields the stated path probability. Finally, summing the product over all paths gives one by successively summing the last transition probabilities, then the preceding ones, because each conditional distribution sums to one. Thus the sequentially generated paths have the joint distribution specified by the transitions. \(\square\)

Worked Example: Drawing a Two-Time Binary History

Under a fixed treatment regime, suppose \(P(L_1=1)=0.6\). At the next time, suppose \(P(L_2=1\mid L_1=1)=0.8\) and \(P(L_2=1\mid L_1=0)=0.25\). Generate a path using uniforms \(U_1=0.42\) and \(U_2=0.70\), and calculate two path probabilities.

At the first time, \(0.42\leq0.6\), so the draw is \(L_1=1\). Given \(L_1=1\), the threshold for \(L_2=1\) is \(0.8\). Since \(0.70\leq0.8\), the second draw is \(L_2=1\). The generated path is \((1,1)\), with probability \(0.6(0.8)=0.48\).

For the path \((0,1)\), the probability is \(P(L_1=0)P(L_2=1\mid L_1=0)=0.4(0.25)=0.10\). As a further check, the marginal probability of \(L_2=1\) is \(0.6(0.8)+0.4(0.25)=0.48+0.10=0.58\). This calculation sums the probabilities of the two possible paths that end with \(L_2=1\).

Diagnostics, Alternatives, and Limits

Transition probabilities are only useful if the fitted models represent the observed conditional distributions adequately and provide support for the histories at which predictions are needed. Examine fitted probabilities by time and category, and compare predicted transition frequencies with observed frequencies across meaningful history groups. Very sparse groups, probabilities close to zero or one, and categories that are never observed for some histories can signal instability or lack of support. A model that predicts a category as essentially impossible when it is observed often, or predicts it often when it is absent, warrants investigation.

Calibration should be assessed for the transitions themselves, conditional on relevant history features; good overall prediction can conceal poor fit in particular histories. Separation in a binary logistic model or sparse category-history combinations in a multinomial model can yield unstable or extreme estimates. Also check whether the histories used for prediction resemble those represented in the data. A fitted model can return probabilities for an unsupported history, but this is extrapolation, not evidence that the transition distribution is known there.

A saturated table of observed transition frequencies is a direct alternative when the history has only a few well-populated combinations. It avoids imposing a particular regression form but becomes unreliable or undefined in sparse combinations. Logistic and multinomial regression share information through a chosen parametric form and can be more stable, at the cost of depending on that form. Neither approach removes the need for adequate data support. The model choice also does not replace the causal identification assumptions, including consistency and sequential exchangeability.

A further distinction is important when several covariates are measured at the same time. Modeling each covariate separately as if they were conditionally independent can give the wrong joint distribution if they are associated given the history. One option is a joint categorical model when the joint state space is manageable; another is to specify a conditional ordering among the covariates and model each in turn. The chosen factorization must represent the intended joint transition distribution.

The main limitation is that predicted transitions inherit the model’s assumptions. A correctly normalized probability distribution is not necessarily a well-fitting one. Model diagnostics can reveal important failures but cannot prove that all conditional distributions are correctly specified. In particular, a transition model cannot repair a lack of observed support for a regime-generated history.

Check Your Understanding

Answer each question, then compare with the brief solutions below.

  1. In the stated timing convention, may the model for \(L_t\) include \(A_t\)? Why or why not?
  2. A binary logistic model has linear predictor \(-0.4\) at a given history. What is the predicted probability of \(L_t=1\), approximately?
  3. Why is it not generally valid to fit a separate binary probability for each category of a three-category covariate and use all three predictions as a multinomial distribution?
  4. If a categorical transition model predicts probabilities \(0.2,0.5,0.3\), how would a uniform draw \(U=0.62\) be converted to a category using that order?
  5. Give one reason a saturated transition table and a multinomial regression model may behave differently in a small data set.

Solutions. (1) No. \(A_t\) occurs after \(L_t\), so it is not part of the history available before that transition. (2) The probability is \(\exp(-0.4)/\{1+\exp(-0.4)\}\approx0.4013\). (3) The independently fitted probabilities need not sum to one, whereas a multinomial model constructs one normalized distribution across categories. (4) The cumulative probabilities are \(0.2,0.7,1.0\), so \(0.62\) falls in the second interval and selects category 1. (5) A saturated table estimates each history-specific frequency directly and can be unstable or empty in sparse groups; regression shares information through its parametric structure but depends on that structure being appropriate.

Clinical Biostats