Tutorials › Marginal Structural Models › Empirical EIF Equations in Finite Samples

Longitudinal Targeted Maximum Likelihood · Tutorial 392 of 501

Empirical EIF Equations in Finite Samples

Calculate the empirical EIF from the final targeted fits, check whether its score equations are satisfied, and use residual patterns to diagnose finite-sample targeting problems.

Advanced 12 min read

What You'll Learn

  • Write the longitudinal EIF using treatment probabilities conditioned on the history available before each treatment.
  • Compute unit-level EIF contributions and their empirical mean from final nuisance fits.
  • Relate stage-specific weighted residual scores to the plug-in estimate.
  • Diagnose nonzero empirical scores caused by tolerances, constraints, or implementation choices.
  • Distinguish an EIF equation check from an asymptotic standard-error calculation.

Why Check the EIF Equation?

Longitudinal TMLE produces a plug-in estimate by evaluating a fitted sequence of regressions under a specified treatment regime and averaging the resulting predictions. Targeting is intended to make the empirical efficient influence function (EIF) equation hold, either exactly or to a stated numerical tolerance. Checking that equation is a direct way to find out whether the final fitted quantities actually satisfy the score conditions the implementation was designed to solve.

This is a finite-sample check, not a test of whether the causal assumptions are true. A small empirical EIF mean cannot establish consistency, exchangeability, or positivity. Conversely, a nonzero mean is useful evidence that the final estimates do not satisfy the intended empirical equation to the displayed precision. To make the check meaningful, compute it from the final targeted regressions and the same observations used by the targeting procedure; with cross-fitting, use the relevant held-out predictions and aggregate the resulting contributions consistently.

Longitudinal EIF and Empirical Scores

Use the observation order \(L_0,A_1,L_1,\ldots,A_K,L_K,Y\), and consider the deterministic regime \(\bar a=(a_1,\ldots,a_K)\). The treatment probability at time \(t\) is conditioned on the history available before \(A_t\). Define \(g_t(a_t\mid\bar L_{t-1},\bar A_{t-1})\) as the conditional probability of receiving \(a_t\) given that pre-treatment history. At \(t=1\), the history includes \(L_0\) and has no prior treatment.

Definition: Let \(Q_{K+1}(\bar l_K,\bar a_K)=E[Y\mid\bar L_K=\bar l_K,\bar A_K=\bar a_K]\). Recursively, for \(t=K,\ldots,1\), define \(Q_t(\bar l_{t-1},\bar a_{t-1})=E[Q_{t+1}(\bar L_t,\bar a_t)\mid\bar L_{t-1}=\bar l_{t-1},\bar A_{t-1}=\bar a_{t-1},A_t=a_t]\). The regime mean is \(\psi=E[Q_1(L_0)]\). The cumulative clever covariate is \(H_t^{\bar a}=I(\bar A_t=\bar a_t)/\prod_{s=1}^t g_s(a_s\mid\bar L_{s-1},\bar A_{s-1})\).

The recursion averages over \(L_t\), which is observed after \(A_t\), conditional on the pre-\(A_t\) history and the regime treatment at time \(t\). In particular, conditioning \(g_t\) on \(L_t\) would use a post-treatment variable and would not be the treatment mechanism for this observation order.

Under consistency, sequential exchangeability, positivity for the regime histories, and the usual integrability conditions, the longitudinal EIF for \(\psi\) is

$$ D^*(O)=\sum_{t=1}^K H_t^{\bar a} \left\{Q_{t+1}(\bar L_t,\bar a_t)-Q_t(\bar L_{t-1},\bar a_{t-1})\right\} +Q_1(L_0)-\psi . $$

Here the \(Q\)'s and \(H\)'s in a fitted analysis are their final estimated versions. Define the stage-\(t\) residual \(R_t=Q_{t+1}(\bar L_t,\bar a_t)-Q_t(\bar L_{t-1},\bar a_{t-1})\), evaluated for each observation. The empirical stage score is \(S_t=P_n(H_t^{\bar a}R_t)\), where \(P_n f=n^{-1}\sum_{i=1}^n f(O_i)\). The empirical EIF mean is the average of the unit-level EIF values, not the average of their absolute values or squares.

What the Finite-Sample Equation Says

Result: For fixed fitted \(Q\)'s and \(H\)'s, the empirical EIF mean at any candidate value \(\psi^\dagger\) is \(P_nD^*(\psi^\dagger)=\sum_{t=1}^K S_t+P_nQ_1-\psi^\dagger\). Consequently, at the plug-in estimate \(\hat\psi_{\mathrm{plug}}=P_nQ_1\), the empirical EIF mean equals \(\sum_t S_t\).

Proof. Substitute the definition of \(D^*\) into the empirical average. Linearity of the finite sum gives

$$ \begin{aligned} P_nD^*(\psi^\dagger) &=P_n\left[\sum_{t=1}^K H_t^{\bar a}R_t+Q_1(L_0)-\psi^\dagger\right]\\ &=\sum_{t=1}^K P_n(H_t^{\bar a}R_t)+P_nQ_1-\psi^\dagger\\ &=\sum_{t=1}^K S_t+P_nQ_1-\psi^\dagger . \end{aligned} $$ Setting \(\psi^\dagger=P_nQ_1\) yields the second assertion. No limit argument is involved: this is an exact identity for the specified finite data set and fitted functions. \(\square\)

This identity clarifies what is being checked. If the estimator is the plug-in estimate, a zero empirical EIF mean is equivalent to a zero sum of stage scores. Individual \(S_t\)'s need not be zero if the algorithm targeted only a combined score. If the implementation claims to solve each stage-specific score, inspect each \(S_t\) as well as their sum; opposite signs can otherwise conceal a stage-level failure.

Result: Holding the fitted \(Q\)'s and \(H\)'s fixed, the value that makes the empirical EIF mean zero is \(\hat\psi_{\mathrm{EIF}}=P_nQ_1+\sum_{t=1}^K S_t\). It equals the plug-in estimate if and only if the total empirical stage score is zero.

Proof. The preceding identity shows that \(P_nD^*(\psi^\dagger)=0\) exactly when \(\psi^\dagger=P_nQ_1+\sum_t S_t\). This solution is unique because the equation has coefficient \(-1\) on \(\psi^\dagger\). Comparing it with \(P_nQ_1\) proves the stated equivalence. This algebraic root is a diagnostic, not a direction to replace a targeted plug-in estimate: the correction can change the estimator's construction or violate a parameter's bounds. \(\square\)

Worked Calculations

Worked Example: A One-Time Regime with a Zero Score

There are \(n=4\) observations and one treatment \(A_1\); the regime sets \(A_1=1\). Suppose \(g_1(1\mid L_0)=0.5\) for everyone, and the targeted prediction \(Q_1(L_0)\) is \(0.5\) for everyone. The two observations with \(A_1=1\) have outcomes \(1\) and \(0\). For this one-time example \(Q_2=Y\), so their residuals are \(0.5\) and \(-0.5\). The other two observations have \(H_1=0\).

For each treated observation, \(H_1=1/0.5=2\). Thus \(S_1=\{2(0.5)+2(-0.5)+0+0\}/4=0\). The plug-in estimate is \(P_nQ_1=0.5\), so the empirical EIF mean is zero. The unit contributions are \(1\), \(-1\), \(0\), and \(0\): each equals \(H_1(Y-Q_1)+Q_1-\hat\psi_{\mathrm{plug}}\), and their average is indeed zero. The check concerns the empirical score; it does not imply that every contribution must itself be zero.

Worked Example: A Small Residual Score and Its Consequence

Suppose four observations have fitted \(Q_1\) values \(0.2,0.4,0.3,0.3\), whose average is \(0.3\). Their \(H_1\) values are \(2,2,0,0\), and their fitted residuals are \(0.10,-0.02,0,0\). Then

\(S_1=\{2(0.10)+2(-0.02)+0+0\}/4=(0.20-0.04)/4=0.04\). Therefore, at the plug-in value \(0.3\), the empirical EIF mean is \(0.04\), not zero. The individual EIF values are \(0.1,0.06,0,0\), which sum to \(0.16\) and average to \(0.04\).

Holding these fits fixed, the empirical EIF root is \(0.3+0.04=0.34\). This calculation does not show that \(0.34\) is the correct final TMLE: it shows exactly how far the fixed-fit equation is from zero. If the score was supposed to be solved, check the optimizer's stopping tolerance, convergence status, and whether the final predictions used in this calculation are the ones returned by the targeting step.

Worked Example: Two Treatment Times and the Correct History

Consider two observations and a two-time regime \((1,1)\). For both observations \(A_1=1\) and \(g_1(1\mid L_0)=0.5\). For observation 1, \(A_2=1\) and \(g_2(1\mid L_0,L_1,A_1)=0.25\); for observation 2, \(A_2=0\) and the probability of \(A_2=1\) at that observation's pre-treatment history is \(0.5\). Thus \(H_1=(2,2)\), while \(H_2=(8,0)\): the first observation has \(1/(0.5\cdot0.25)=8\), and the second fails the regime indicator at time 2.

Suppose the fitted residuals are \(R_1=(0.05,-0.03)\) and \(R_2=(-0.02,0)\), and \(Q_1=(0.4,0.6)\). Then \(S_1=\{2(0.05)+2(-0.03)\}/2=0.02\), and \(S_2=\{8(-0.02)+0(0)\}/2=-0.08\). The plug-in value is \(P_nQ_1=(0.4+0.6)/2=0.5\); therefore its empirical EIF mean is \(0.02-0.08=-0.06\).

Checking observation by observation gives the same answer. The first contribution is \(0.1-0.16+0.4-0.5=-0.16\); the second is \(-0.06+0+0.6-0.5=0.04\). Their average is \((-0.16+0.04)/2=-0.06\). This example also shows why the stage scores should be reported separately: their sum alone does not reveal that the second stage contributes most of the imbalance.

Interpreting Residual Imbalance

In an unconstrained, unpenalized fluctuation fit, a score equation is typically the derivative of the empirical loss with respect to a fluctuation parameter. If the relevant score is \(P_n(H_tR_t)\), a converged optimizer should make it zero up to numerical tolerance. That expectation depends on the actual fluctuation submodel and objective: it is not a universal guarantee that every algorithm called TMLE sets every \(S_t\) to zero.

A nonzero score can arise for several distinct reasons. A loose stopping tolerance or early termination leaves a numerical residual. A constrained or penalized fit may stop at a boundary or optimize a criterion whose score is not the unmodified EIF score. An implementation can also evaluate different fitted versions, use mismatched history indices, omit observations, or compute \(H_t\) with an incorrect treatment probability. These possibilities call for different remedies, so report the components rather than only the final aggregate.

A useful diagnostic record includes \(P_nD^*\), each \(S_t\), the plug-in value, the maximum absolute unit-level EIF contribution, the optimizer status, and the numerical tolerance. Also verify that the empirical average uses the intended observations and that each \(g_t\) conditions on \((\bar L_{t-1},\bar A_{t-1})\), not on \(L_t\). Large or highly variable clever covariates can make a score sensitive to a few observations; that is a warning to investigate the fitted weights and data, not proof by itself of a coding error.

The empirical EIF check differs from both an asymptotic standard-error calculation and a comparison with an alternative estimator. An influence-curve standard error uses the sample variability of the unit-level EIF values, typically through their empirical variance; it does not ask whether their mean is near zero. An inverse-probability-weighted estimator has its own estimating equation and may be useful as a comparison, but agreement or disagreement does not certify that TMLE's final targeting equation was solved. The EIF check is most informative as an implementation and fit diagnostic, not as a substitute for causal assumptions or statistical inference.

Common Mistake and Limitations

Wrong reasoning: “The empirical EIF mean is small, so the procedure is valid and the causal assumptions hold.” This confuses a fitted-sample equation with identification and asymptotic properties. Correction: a small mean only says that this particular fitted EIF equation is nearly satisfied on these observations. It does not verify the causal assumptions, guarantee good nuisance estimation, or establish stable inference. Likewise, a zero total score can result from cancellation across stages, so inspect stage-specific scores whenever the algorithm targets them separately.

Finite-sample score checks are sensitive to what is held fixed. Recomputing the EIF with rounded probabilities, different cross-fitting predictions, or pre-targeting regressions answers a different numerical question from evaluating the final targeted fits. Report enough precision to distinguish a genuine optimizer residual from display rounding, and state which predictions and observations were used. The central discipline is simple: compute the EIF from the final fitted quantities, verify its components, and interpret the result narrowly.

Check Your Understanding

Answer each question, then compare with the solutions below.

  1. With \(P_nQ_1=0.42\) and stage scores \(S_1=0.01\), \(S_2=-0.03\), what is the empirical EIF mean at the plug-in estimate?
  2. At time \(t\), under the stated observation order, which variables condition \(g_t\)? Why is \(L_t\) not included?
  3. Can a zero total empirical EIF mean imply that every stage score is zero? Explain.
  4. If the empirical EIF mean is \(0.02\) at the plug-in estimate, what is the fixed-fit value that solves the empirical EIF equation?

Solutions. (1) It is \(S_1+S_2=0.01-0.03=-0.02\). (2) Condition on the pre-treatment history \((\bar L_{t-1},\bar A_{t-1})\); \(L_t\) is measured after \(A_t\). (3) No. Stage scores can cancel, as \(0.02\) and \(-0.02\) do; inspect them separately if the procedure targets them separately. (4) Add the empirical mean to the plug-in estimate, giving \(0.42+0.02=0.44\). This is the root holding the fitted functions fixed, not necessarily a recommended replacement estimate.

Clinical Biostats