Tutorials › Marginal Structural Models › Empirical Probabilities for Discrete Treatment Histories

Inverse Probability of Treatment Weights · Tutorial 107 of 501

Empirical Probabilities for Discrete Treatment Histories

Estimate discrete treatment probabilities directly from observed history-by-treatment counts, calculate inverse-probability weights, and check when the resulting weights are unreliable.

Advanced 12 min read

What You'll Learn

  • Define empirical conditional treatment probabilities from history-by-treatment cell counts.
  • Calculate unstabilized and stabilized weights for observed treatment histories.
  • Derive the finite-sample balance property of cell-frequency weights.
  • Understand when empirical probabilities are consistent estimates of the treatment mechanism.
  • Diagnose zero cells, sparse histories, and extreme weights.
  • Compare saturated cell-frequency estimation with parametric treatment models.

Why Estimate Treatment Probabilities by Cell Frequencies?

When treatment and covariate histories take a small number of values, the treatment mechanism can be estimated directly from the observed proportions in each history cell. This saturated approach makes no assumption that treatment probabilities follow a logistic, multinomial, or other smooth functional form. Its simplicity is useful, but it also means that each history cell must be supported by data.

Let \(i=1,\ldots,n\) index independent individuals and \(t=1,\ldots,K\) index treatment decision times. At time \(t\), \(A_{it}\) is the treatment received and \(H_{it}\) is the observed history available just before that decision. The history may include baseline and time-varying covariates and past treatment. Assume, for now, that the histories and treatments are discrete and that treatment is observed at every decision time for every individual in the analysis.

Definition: For a history value \(h\) and treatment category \(a\), let \(N_t(h)\) be the number of individuals with \(H_{it}=h\), and let \(N_t(h,a)\) be the number with \(H_{it}=h\) and \(A_{it}=a\). If \(N_t(h)>0\), the empirical conditional treatment probability is $$ \hat p_t(a\mid h)=\frac{N_t(h,a)}{N_t(h)}. $$ It is the observed proportion receiving category \(a\) among individuals with history \(h\).

These estimates are saturated: a separate probability is estimated for every observed history cell. The estimated probability of an individual’s observed treatment at time \(t\) is \(\hat p_t(A_{it}\mid H_{it})\). Multiplying its reciprocal over decision times gives the unstabilized treatment weight $$ \hat W_i=\prod_{t=1}^{K}\frac{1}{\hat p_t(A_{it}\mid H_{it})}. $$ A stabilized version replaces each denominator probability with a ratio that includes a numerator probability. For example, if \(q_t(a\mid \bar a_{t-1})\) is a chosen treatment probability conditional on prior treatment history but not the current covariate history, its empirical counterpart is estimated by pooling over current covariate histories within the prior-treatment stratum. The resulting weight is $$ \hat W_i^{\,S}=\prod_{t=1}^{K}\frac{\hat q_t(A_{it}\mid \bar A_{i,t-1})}{\hat p_t(A_{it}\mid H_{it})}. $$ At the first decision, \(\bar A_{i,0}\) is empty, so the numerator can be the marginal treatment proportion. The numerator specification defines the stabilization target; it does not change how the denominator cell frequencies are calculated.

How the Cell-Frequency Estimator Behaves

The observed proportion is also the maximum-likelihood estimate in a model that assigns a separate categorical treatment distribution to each history cell. Its basic sampling properties follow from the conditional multinomial distribution of the treatment counts.

Result: Suppose individuals are independent and identically distributed, the treatment categories are finite, and \(P(H_t=h)>0\). Conditional on \(N_t(h)=m>0\), the count \(N_t(h,a)\) has a binomial marginal distribution with size \(m\) and success probability \(p_t(a\mid h)=P(A_t=a\mid H_t=h)\). Consequently, $$ E[\hat p_t(a\mid h)\mid N_t(h)=m]=p_t(a\mid h),\qquad \operatorname{Var}(\hat p_t(a\mid h)\mid N_t(h)=m)=\frac{p_t(a\mid h)\{1-p_t(a\mid h)\}}{m}. $$ Also, \(\hat p_t(a\mid h)\xrightarrow{p}p_t(a\mid h)\) as \(n\to\infty\).

Justification. Conditional on which \(m\) individuals have history \(h\), their treatment indicators for category \(a\) are independent Bernoulli variables with success probability \(p_t(a\mid h)\). Thus \(N_t(h,a)\) is binomial with mean \(mp_t(a\mid h)\) and variance \(mp_t(a\mid h)\{1-p_t(a\mid h)\}\). Dividing by \(m\) gives the displayed conditional mean and variance. For consistency, write $$ \hat p_t(a\mid h)= \frac{n^{-1}\sum_{i=1}^{n} I(H_{it}=h,A_{it}=a)} {n^{-1}\sum_{i=1}^{n} I(H_{it}=h)}. $$ By the law of large numbers, the numerator converges in probability to \(P(H_t=h,A_t=a)\) and the denominator to \(P(H_t=h)>0\). The ratio therefore converges in probability to \(P(A_t=a\mid H_t=h)\). The same cell-wise likelihood is maximized by the observed proportions: for counts \(N_t(h,a)\), the conditional log-likelihood is \(\sum_a N_t(h,a)\log p_t(a\mid h)\), subject to probabilities summing to one. Maximizing this multinomial likelihood gives \(p_t(a\mid h)=N_t(h,a)/N_t(h)\). \(\square\)

The consistency statement applies to a fixed history cell with positive population probability. It does not guarantee good finite-sample estimates when that cell is rare, nor does it justify estimating probabilities for histories absent from the sample. For causal weighting, positivity is also needed: treatment categories relevant to the target comparison must have positive probability in the histories where they are to be compared. Sampling zeros and genuine violations of positivity are different problems, even though both can leave a cell with no observed treatment in a particular sample.

Worked Example: One Decision and Two History Cells

Suppose 20 individuals have a binary history \(H\) and a binary treatment \(A\). Among the 10 with \(H=0\), 2 receive \(A=1\); among the 10 with \(H=1\), 8 receive \(A=1\). Compute the cell probabilities and the unstabilized weights.

For \(H=0\), the empirical probability of treatment is \(2/10=0.2\), and the probability of no treatment is \(8/10=0.8\). The weights are therefore \(1/0.2=5\) for each observed treated individual and \(1/0.8=1.25\) for each observed untreated individual.

For \(H=1\), the probabilities are \(8/10=0.8\) for treatment and \(2/10=0.2\) for no treatment. The corresponding weights are \(1/0.8=1.25\) for each treated individual and \(1/0.2=5\) for each untreated individual.

Thus the less common treatment category within each history cell receives the larger weight. The calculation uses the observed treatment proportion within the cell, not the overall treatment proportion.

Finite-Sample Balance Within a Cell

A useful exact property explains why the inverse of a cell frequency is used. Within any observed history cell, weighting by the reciprocal of the observed treatment proportion gives each observed treatment category the same total weight. This is a finite-sample identity, not an asymptotic approximation.

Result: If \(N_t(h)>0\) and \(N_t(h,a)>0\), then the total unstabilized weight at decision time \(t\) among individuals with \(H_{it}=h\) and \(A_{it}=a\) is $$ \sum_{i:H_{it}=h,\,A_{it}=a}\frac{1}{\hat p_t(a\mid h)} =\frac{N_t(h,a)}{N_t(h,a)/N_t(h)} =N_t(h). $$ It is the same for every treatment category observed in that history cell.

Proof. Each of the \(N_t(h,a)\) individuals in the sum has the same estimated probability \(\hat p_t(a\mid h)=N_t(h,a)/N_t(h)\). Summing their reciprocal weights gives \(N_t(h)\), as shown. If a category is not observed in the cell, its count and estimated probability are both zero, and the reciprocal is undefined; there is no empirical weighted mass for that category to balance. \(\square\)

With a stabilized numerator that is constant within the relevant history stratum, the same calculation yields total weight \(N_t(h)\hat q_t(a\mid\bar a_{t-1})\) for a cell with that prior treatment history. This balances the covariate-history cell to the numerator’s treatment distribution rather than assigning equal total mass to each category. The identity is local to one decision and its conditioning cells. It does not say that a product of weights across several times will exactly balance every joint covariate and treatment history in the final weighted data.

Worked Example: A Two-Time Stabilized Weight

Consider 12 individuals observed at two decision times. At time 1, there are 6 individuals with \(L_0=0\), of whom 2 receive \(A_1=1\), and 6 with \(L_0=1\), of whom 4 receive \(A_1=1\). At time 2, let \(H_2=(A_1,L_1)\), where \(L_1\) represents the measured covariate history available at that decision. Within each \(A_1\) group, histories \(L_1=x\) and \(L_1=y\) each contain 3 individuals. For \(A_1=1\), the counts receiving \(A_2=1\) are 2 in \(x\) and 1 in \(y\); for \(A_1=0\), those counts are 1 in \(x\) and 2 in \(y\). Calculate the stabilized weight for an individual with \(L_0=0,A_1=1,L_1=x,A_2=1\), using marginal treatment probabilities as numerators at time 1 and treatment probabilities conditional on \(A_1\) at time 2.

At time 1, the overall number receiving \(A_1=1\) is \(2+4=6\) out of 12, so \(\hat q_1(1)=6/12=0.5\). For this individual’s history \(L_0=0\), the denominator is \(\hat p_1(1\mid L_0=0)=2/6=1/3\). The time-1 stabilized factor is \(0.5/(1/3)=1.5\).

At time 2, among the 6 individuals with \(A_1=1\), 3 receive \(A_2=1\), so the numerator is \(\hat q_2(1\mid A_1=1)=3/6=0.5\). In the individual’s history cell \((A_1=1,L_1=x)\), 2 of 3 receive \(A_2=1\); the denominator is \(2/3\). The time-2 factor is \(0.5/(2/3)=0.75\).

Multiplying the two factors gives \(\hat W_i^{\,S}=1.5(0.75)=1.125\). For comparison, the unstabilized weight is \((1/(1/3))(1/(2/3))=3(1.5)=4.5\). The stabilized weight is smaller here because its numerator retains part of the treatment-history distribution instead of removing it entirely.

Empty Cells, Sparse Cells, and Alternatives

An empty cell has \(N_t(h)=0\), so its conditional probability cannot be estimated from these data. If \(N_t(h)>0\) but \(N_t(h,a)=0\), the empirical probability for category \(a\) is zero. No observed individual in that cell receives \(a\), so there is no observed inverse weight for that combination; nevertheless, the sample provides no direct estimate of the probability of receiving \(a\) there. A category observed only once has empirical probability \(1/N_t(h)\), which can produce a large inverse weight.

The empirical method is equivalent to fitting an unrestricted categorical treatment distribution separately in every history cell. A logistic or multinomial model instead imposes a functional form that can pool information across histories and may produce estimates in cells with few observations. That pooling can reduce variability, but its validity depends on the model specification. Cell frequencies avoid such a specification but cannot borrow strength or extrapolate. Smoothing sparse cells is a separate strategy; it changes the estimator and should not be silently substituted for the raw frequency.

Useful diagnostics include tabulating \(N_t(h)\) and \(N_t(h,a)\) at every time, identifying zero and very small counts, and examining the distribution of the resulting weights. An effective sample size summary is $$ \operatorname{ESS}=\frac{\left(\sum_{i=1}^{n}\hat W_i\right)^2}{\sum_{i=1}^{n}\hat W_i^2}. $$ A value much smaller than \(n\) indicates that a few individuals carry much of the total weight. This is a warning about instability, not proof of a particular modeling error. Also verify that each denominator uses the intended pre-treatment history and that numerator probabilities are calculated in the specified prior-treatment strata. Replacing conditional denominators with overall treatment proportions would discard the history information the weights are meant to address.

Key takeaway: Empirical probabilities are transparent and exactly defined by cell counts. They are most useful when histories are discrete and adequately represented; their main weakness is that sparse or unsupported cells directly become noisy, zero, or undefined probabilities.

Worked Example: What a Zero Cell Does and Does Not Show

In a sample of 8 individuals, 4 have \(H=0\) and 4 have \(H=1\). Among those with \(H=0\), 2 receive \(A=1\); among those with \(H=1\), none receive \(A=1\). What probabilities can be computed, and what can be concluded?

For \(H=0\), the empirical probabilities are \(\hat p(1\mid 0)=2/4=0.5\) and \(\hat p(0\mid 0)=2/4=0.5\). The observed treated and untreated individuals in that cell each receive weight \(1/0.5=2\).

For \(H=1\), the empirical probabilities are \(\hat p(1\mid 1)=0/4=0\) and \(\hat p(0\mid 1)=4/4=1\). The observed untreated individuals have empirical inverse weight \(1/1=1\). There is no observed treated individual in this cell, so there is no finite empirical inverse weight for an observed \(A=1,H=1\) individual.

The sample establishes that no treated individual with \(H=1\) was observed; it does not, by itself, establish that the population probability \(P(A=1\mid H=1)\) is exactly zero. The cell may reflect a population positivity failure or simply limited sampling. Either way, raw cell frequencies cannot supply a positive treatment probability for this combination.

Check Your Understanding

Work through the questions, then compare your reasoning with the solutions.

  1. In a history cell containing 15 individuals, 6 receive treatment category \(a\). What is the empirical probability and the inverse-probability weight for each observed individual receiving \(a\)?
  2. Why is the empirical conditional probability a maximum-likelihood estimate in a saturated cell-frequency model?
  3. For a cell with 5 individuals, 2 receiving \(a\), verify the total inverse-weighted mass for category \(a\).
  4. A history cell is observed, but a treatment category has count zero. What can be said about its empirical probability, and what cannot be concluded about its population probability from this fact alone?
  5. Name one advantage and one limitation of cell frequencies compared with a correctly specified parametric treatment model.

Solutions. (1) The probability is \(6/15=0.4\); each observed \(a\) individual has weight \(1/0.4=2.5\). (2) The cell-wise multinomial likelihood is maximized, subject to probabilities summing to one, by assigning each category its observed count divided by the cell total. (3) Each of the 2 individuals has weight \(1/(2/5)=2.5\), so the total is \(2(2.5)=5\), equal to the cell size. (4) Its empirical probability is zero, but a sample zero alone does not prove the population probability is zero. (5) Cell frequencies avoid a functional-form assumption, but they cannot pool information across sparse histories and may be undefined or unstable in poorly represented cells.

Clinical Biostats