Tutorials › Marginal Structural Models › Maternal Medication Use During Pregnancy

Case Studies · Tutorial 484 of 501

Maternal Medication Use During Pregnancy

Learn to define the at-risk pregnancy process, identify strategy-specific preterm-birth risks, and calculate treatment weights without assigning medication after delivery.

Advanced 14 min read

What You'll Learn

  • Define treatment and covariate histories only while a pregnancy remains at risk.
  • Derive an event-history g-formula for preterm birth by a gestational-age cutoff.
  • State the consistency, sequential exchangeability, and positivity assumptions required for identification.
  • Construct treatment weights that stop accumulating when delivery occurs.
  • Work through numerical examples of g-formula risks and weighted estimates.
  • Diagnose weak treatment support and distinguish weighting from outcome-model approaches.

Why the Pregnancy Timeline Matters

Medication decisions during pregnancy can respond to changing symptoms, laboratory measurements, or fetal assessments. Those same measurements may predict preterm delivery. A comparison that simply adjusts for the latest measurements can therefore distort the treatment contrast: it may control for variables affected by earlier medication while trying to account for confounding of later medication.

A marginal structural analysis targets risks under specified medication strategies. Pregnancy data require one additional piece of care: a pregnancy that delivers before a later decision has no later medication or symptom measurement. The analysis must stop its treatment history at delivery, not fill in hypothetical observed decisions after the pregnancy has ended.

Definition: Let \(t=0,\ldots,K-1\) index medication decision times before 37 completed weeks of gestation. Let \(R_t=1\) indicate that the pregnancy is ongoing immediately before decision \(t\), and \(R_t=0\) otherwise. For \(R_t=1\), \(L_t\) is the covariate history measured before that decision and \(A_t\) is the medication assigned. Let \(D_{t+1}=1\) indicate delivery before the next decision time, or before the 37-week cutoff at the final interval. Then \(R_{t+1}=R_t(1-D_{t+1})\). Define \(Y=1\) if delivery occurs before 37 weeks and \(Y=0\) otherwise. Medication and covariate variables after delivery are undefined.

The decision times should match the clinical question and the data collection schedule. For example, \(L_t\) might include symptom severity, blood pressure, and a laboratory measurement recorded before the prescribing decision at gestational week \(t\). The outcome is not “ever delivered”; it is delivery before the specified cutoff. A pregnancy still ongoing at 37 weeks has \(Y=0\), even though delivery may occur later.

Strategies and Identification Assumptions

Consider a static medication strategy \(\bar a=(a_0,\ldots,a_{K-1})\), prescribing the specified medication status at each decision time when the pregnancy is still ongoing. Under that strategy, there is no prescribed action at a time after delivery. The potential outcome \(Y^{\bar a}\) is the preterm-birth indicator that would result if the strategy were followed whenever its decision was applicable.

Identification assumptions: (1) Consistency: when the observed medication decisions agree with \(\bar a\) at every decision actually reached, the observed outcome equals \(Y^{\bar a}\). (2) Sequential exchangeability: among pregnancies with \(R_t=1\), conditional on the observed history \(H_t=(L_0,A_0,\ldots,A_{t-1},L_t)\), the medication \(A_t\) is independent of the potential event and covariate histories under the strategies of interest. (3) Sequential positivity: for every history with positive probability under the strategy being evaluated, the strategy’s prescribed medication has positive probability of being observed among pregnancies at risk with that history.

Exchangeability requires adequate measurement of common causes of prescribing and preterm delivery at each decision. Positivity is also local to the risk set: it concerns women still pregnant at that decision, not women who delivered earlier. These assumptions identify risks in the population represented by the data and the chosen treatment strategies; they do not guarantee that the strategies are clinically sensible or safe.

An Event-History g-Formula

For \(t<K-1\), write \(q_t(0,l_{t+1}\mid h_t,a_t)\) for the conditional joint density or mass of no delivery in interval \(t\) and the next covariate value \(L_{t+1}=l_{t+1}\), given the history \(h_t\) and treatment \(a_t\), among pregnancies at risk at \(t\). At the final interval, write \(q_{K-1}(0\mid h_{K-1},a_{K-1})\) for the probability of no delivery before the cutoff. These kernels are only defined for pregnancies that reach the relevant decision.

Theorem (event-history g-formula): Under consistency, sequential exchangeability, and sequential positivity, the risk of preterm birth under \(\bar a\) is
$$ P(Y^{\bar a}=1) = 1- \int f_0(l_0) \left\{ \prod_{t=0}^{K-2} q_t(0,l_{t+1}\mid h_t^{\bar a},a_t) \right\} q_{K-1}(0\mid h_{K-1}^{\bar a},a_{K-1}) \,d l_0\cdots d l_{K-1}, $$

where \(f_0\) is the baseline covariate distribution and \(h_t^{\bar a}\) is the history with previous medication decisions set to \(a_0,\ldots,a_{t-1}\). The integral denotes summation for discrete covariates and integration for continuous covariates. If \(K=1\), the product over \(t=0,\ldots,K-2\) is empty and equals 1.

The subtracted quantity is the probability of remaining pregnant through every interval up to the cutoff under the strategy. Its factors describe only paths with no delivery so far; a covariate value at \(t+1\) appears only after the pregnancy has remained at risk through interval \(t\).

1
Start with baseline covariates.
Average over \(L_0\) using \(f_0\).
2
Apply the strategy while at risk.
At each reached decision, use \(a_t\), then account for delivery or survival to the next decision.
3
Compute survival to the cutoff.
Multiply the no-delivery transition probabilities along paths that remain pregnant, and average over those paths.
4
Convert survival to risk.
Subtract the probability of no preterm delivery from 1.

To justify the formula, under the intervention the chance of a no-delivery path with covariate values \(l_0,\ldots,l_{K-1}\) factors into its baseline probability and the successive conditional probabilities of no delivery and the next covariate value. Sequential exchangeability lets each such conditional transition under the intervention be identified by the corresponding observed transition among pregnancies with the same history, receiving \(a_t\). Consistency links those observed transitions to the potential transitions. Positivity ensures that the required conditional probabilities are supported by the observed data. Integrating the product gives the probability of no preterm delivery; its complement is the stated risk. No factor for a decision after delivery is required. \(\square\)

Worked Example: Calculating Risk Along No-Delivery Paths

Suppose there are two medication decisions before 37 weeks. At baseline, 60% of pregnancies have low symptom severity (\(L_0=0\)) and 40% have high severity (\(L_0=1\)). Evaluate a strategy prescribing medication at both decisions, \(\bar a=(1,1)\). In the first interval, the probabilities of delivery are 0.05 for low severity and 0.15 for high severity. Among pregnancies surviving that interval, the probability of high severity at the next decision is 0.20 if baseline severity was low and 0.60 if it was high. At the final decision, delivery probabilities are 0.10 for low severity and 0.25 for high severity.

For baseline low severity, the late-interval delivery risk among survivors is \(0.80(0.10)+0.20(0.25)=0.08+0.05=0.13\). Thus the total preterm risk in this baseline group is the early delivery probability plus survival to the second decision times the late risk: \(0.05+0.95(0.13)=0.1735\).

For baseline high severity, the late risk among survivors is \(0.40(0.10)+0.60(0.25)=0.04+0.15=0.19\). The group’s total risk is \(0.15+0.85(0.19)=0.3115\).

Averaging over baseline severity gives \(0.60(0.1735)+0.40(0.3115)=0.1041+0.1246=0.2287\). The estimated strategy-specific risk is therefore 0.2287, or 22.87%. The early-delivery probabilities contribute directly to risk; the late probabilities are averaged only among pregnancies that reach the second decision.

Weights That Stop at Delivery

An alternative is to use inverse-probability weights for treatment. Let \(e_t(a_t\mid H_t)=P(A_t=a_t\mid H_t,R_t=1)\) be the observed treatment probability for the strategy’s action at a reached decision. Define the strategy weight for an observed pregnancy as

$$ W^{\bar a} = \prod_{t:R_t=1} \frac{I(A_t=a_t)}{e_t(a_t\mid H_t)}. $$

The product includes only decisions actually reached. A pregnancy that delivers after decision \(t\) has no factor for any later decision. Equivalently, one can write a product over all scheduled times with each post-delivery factor defined to equal 1, but the at-risk product makes the data structure explicit.

Theorem (event-history weighting identity): Under consistency, sequential exchangeability, and sequential positivity, for any bounded function \(h\) of the outcome,
$$ E\!\left[W^{\bar a}h(Y)\right]=E\!\left[h(Y^{\bar a})\right]. $$

For justification, factor the observed probability of each event-history path into baseline covariate, treatment, and event/covariate transition factors. Multiplication by \(W^{\bar a}\) cancels the observed conditional treatment probability at each decision reached and retains only paths whose observed treatment equals the strategy’s action there. The remaining path factors are the baseline distribution and the observed event/covariate transition kernels under those actions. By sequential exchangeability and consistency, these are the intervention path factors. Paths terminate at delivery, so no treatment factor is present beyond that point. Summing or integrating the resulting path probabilities against \(h(Y)\) gives the intervention expectation. Positivity makes every denominator nonzero on relevant histories. \(\square\)

In particular, setting \(h(Y)=Y\) gives the intervention risk as a weighted mean, since \(Y\) is binary. The identity is a population statement; a finite-sample weighted estimate can be unstable or far from the target risk.

Worked Example: A Weighted Estimate With an Early Delivery

Consider a small illustrative data set and the strategy \((1,1)\). For the first decision the treatment probability is 0.50 for the first two pregnancies and 0.25 for the third. At the second decision, reached only by pregnancies that remain pregnant, the probability of medication is 0.25 for the second and 0.50 for the third.

PregnancyObserved historyWeight for strategy (1,1)Preterm outcome \(Y\)
1\(A_0=1\); delivery before decision 1\(1/0.50=2\)1
2\(A_0=1\); reaches decision 1; \(A_1=1\)\((1/0.50)(1/0.25)=8\)1
3\(A_0=1\); reaches decision 1; \(A_1=1\)\((1/0.25)(1/0.50)=8\)0
4\(A_0=0\)01

Pregnancy 1’s delivery happens before the second decision, so its weight is 2, not a product containing a second-decision probability. Pregnancy 4 has weight 0 because its first treatment does not match the strategy. The weighted risk estimate is \((2(1)+8(1)+8(0)+0(1))/(2+8+8+0)=10/18\approx0.556\). This toy estimate illustrates the calculation, not a precise population risk: with only four records it is highly variable.

Diagnostics, Alternatives, and Common Pitfalls

Before interpreting an estimate, check whether the event and treatment timeline has been encoded correctly. Confirm that \(L_t\) precedes \(A_t\), that delivery removes a pregnancy from later risk sets, and that delivery before the cutoff is distinguished from delivery at or after it. Report the number at risk at each decision and the number delivering in each interval. These counts expose accidental use of post-delivery covariates or treatment records.

For weighting, inspect the treatment probabilities and the distribution of the resulting weights among pregnancies still at risk at each time. Very small probabilities produce large weights: if the probability of the prescribed medication is 0.02, the corresponding factor is \(1/0.02=50\). Such values may signal practical positivity problems and can make estimates sensitive to a few pregnancies. Examine covariate balance after weighting at each decision, especially for symptom and clinical measures that predict subsequent prescribing. Weight truncation may reduce variability but changes the estimator and can introduce bias; it does not repair unsupported treatment histories.

The g-formula and weighting approach address the same target through different models. The g-formula models event and covariate transitions and then averages predicted outcomes under the strategy. Weighting models treatment assignment and reweights observed histories. Their assumptions about measured confounding and support are not avoided by choosing one method. A conventional regression that adjusts directly for time-varying covariates can be inappropriate when those covariates are affected by earlier treatment and confound later treatment. Marginal structural models are designed to address that treatment-confounder feedback; the introductory material on marginal structural models provides the general framework.

Worked Example: Recognizing Weak Positivity

Suppose that among pregnancies with severe symptoms at a particular decision, only 2% receive the medication required by the strategy. A pregnancy receiving it contributes a treatment-weight factor \(1/0.02=50\). If four such pregnancies are observed, their combined contribution to the denominator of a simple weighted mean is \(4(50)=200\), while 100 pregnancies receiving the alternative medication each have strategy weight zero at that decision.

Although the observed data contain some treated pregnancies, the estimate depends heavily on those four records. If one has \(Y=1\) and the other three have \(Y=0\), their weighted outcome contribution is 50 and their weighted mean is \(50/200=0.25\). Changing the outcome of the single high-weight pregnancy changes that subgroup mean by 0.25. This is a practical warning: nominally positive probabilities do not ensure a stable estimate.

A common mistake is to define a complete vector \((A_0,\ldots,A_{K-1})\) for every pregnancy and then include all treatment factors in a weight or g-formula. That reasoning silently assigns medication after delivery, when the decision does not exist. The correction is to define covariates and treatment only while \(R_t=1\), use event-history transition probabilities, and stop the treatment weight at the first delivery. If a different endpoint includes pregnancy loss or another competing event, its handling must be specified separately; it cannot be treated as an ordinary post-delivery covariate.

Key takeaway: In pregnancy analyses, the treatment strategy is applied only at decisions reached while the pregnancy remains ongoing. Correct marginal risks account for delivery as an event that ends subsequent treatment and covariate history, rather than pretending that every pregnancy completes every scheduled decision.

Check Your Understanding

Answer each question, then compare with the solutions.

  1. A pregnancy delivers before decision 2. Which medication factors appear in its weight for a strategy with four scheduled decisions?
  2. In the two-decision example, what is the risk for baseline-low pregnancies if the first-interval delivery probability were 0.10, while the survival probability and late risk stayed at 0.95 and 0.13?
  3. Why is a history with a 0.01 probability of the strategy’s medication concerning, even if the probability is not exactly zero?
  4. State one reason a direct regression adjustment for current symptoms may not estimate the desired marginal strategy risk.

Solutions. (1) Only factors for decisions actually reached, namely decisions 0 and 1 if delivery occurs after decision 1; there are no factors for decisions 2 or 3. (2) The risk is \(0.10+0.90(0.13)=0.217\), or 21.7%. (3) The inverse-probability factor is \(1/0.01=100\), so a small number of pregnancies can dominate the estimate, creating instability. (4) Current symptoms may be affected by earlier treatment while also confounding later treatment, so ordinary adjustment can block part of the earlier treatment effect or otherwise distort the marginal contrast.

Clinical Biostats