Causal inference / E137

When the holdout leaks: bounding ad lift without assuming away defiers

Type
Advanced worked example - read, run, modify
Data
Simulated with a known truth: a randomised video campaign test on 1,000,000 users (half in a holdout) with leakage both ways, drawn from the 16 response types of a binary instrument, treatment and outcome, with 3% defiers. No public ad test records which users would have been exposed in the other arm, so only a simulation can grade a method whose whole subject is those unseen types
You will learn
Why a randomised ad test with two-sided noncompliance does not identify the effect of seeing the ad · the four principal strata and why the Wald / IV ratio needs monotonicity (no defiers) · the cross-world correlation $\rho = \mathrm{Corr}(T(0), T(1))$ and the defier share as one sensitivity parameter (Tian, Liu, Liu & Wu 2026) · closed-form sharp bounds for the ATE and the LATE at each $\rho$, checked against an exact linear program over response types · Balke-Pearl bounds as a special case · thresholds where the ATE bounds tighten and where the Wald ratio leaves the identified set · a Dirichlet-multinomial posterior in PyMC with bounds as deterministics, checked against the conjugate posterior · a feasibility guard for draws that contradict monotonicity · why a prior on the compliance types answers with the prior · how to report a lift test to someone who has to act on it
import os

for v_ in ("OMP_NUM_THREADS", "OPENBLAS_NUM_THREADS", "MKL_NUM_THREADS"):
    os.environ[v_] = "1"  # nutpie runs chains as threads: a BLAS pool per chain would fight over the cores

import itertools
import logging
import sys
import time
import warnings

import arviz as az
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import pymc as pm
import pytensor.tensor as pt
from scipy import optimize

RANDOM_SEED = 137
rng = np.random.default_rng(RANDOM_SEED)
az.style.use("arviz-variat")
logging.getLogger("pymc").setLevel(logging.WARNING)
warnings.filterwarnings("ignore", category=FutureWarning)
warnings.filterwarnings("ignore", category=UserWarning, module="arviz")
warnings.filterwarnings("ignore", category=RuntimeWarning, message="All-NaN slice")
sys.modules.pop("jax", None)  # arviz leaves a lazy jax stub that makes matplotlib import all of JAX
pd.set_option("display.width", 160)
T_START = time.time()

BLUE, ORANGE, AQUA, PURPLE, RED = "#2a78d6", "#eb6834", "#1baf7a", "#8c5ac8", "#c8384e"
INK, MUTED, LIGHT = "#222222", "#8a8984", "#d9d8d3"
print(f"PyMC {pm.__version__}, ArviZ {az.__version__}")
PyMC 6.3.2, ArviZ 1.3.0

The setting

The measurement lead at a connected-fitness brand has a clean-looking experiment to read. For four weeks a social platform ran the brand's new online video to a randomly chosen half of a million-user audience and held the other half out. The outcome is simple and binary: did the user visit the brand's site during the flight. Whether the campaign worked is only half the question. The lead wants the effect of actually seeing the video, per reached user, because that number goes into the marketing mix model as the calibration point for the video channel, and next quarter's video budget will be set from the MMM's return curve. A number that is 15% too low moves money to other channels for a whole quarter.

The test is not as clean as it looks. A retail media partner, the ad network of a large retailer that sells the brand's bikes, runs the same video to its own shoppers and does not honour the platform's holdout list, so about a fifth of the holdout sees the video anyway. That much is the usual leakage, and the textbook handles it: treat random assignment $Z$ as an instrument for exposure $T$, and divide the intent-to-treat difference by the difference in exposure rates. This Wald ratio identifies the effect among compliers, the users who see the video because they were assigned to it (Imbens & Angrist 1994; Angrist, Imbens & Rubin 1996), as long as there are no defiers: nobody may be exposed when held out and unexposed when assigned. The partner breaks that too. It deduplicates against the platform's target list to avoid paying twice for the same person, so test-arm users on that list are suppressed at the partner, and some of them the platform never reaches before the budget runs out. In the holdout the same users would have been on no list and the partner would have shown them the video. They are defiers, and nothing in the data marks them.

The sharp bounds for this problem without monotonicity are old: Balke & Pearl (1997) derived them by linear programming, and imposing monotonicity does not tighten them for the average effect over all users (Balke & Pearl 1997; Bai et al. 2026). They are also wide, because a randomised test says nothing about what the never-reached would have done if reached. Earlier work used the share of defiers as a sensitivity parameter (Huber 2014; Noack 2021; Swanson & Hernán 2018). Tian, Liu, Liu & Wu (2026), "Partial Identification under Imperfect Compliance via Cross-World Correlation Restriction" (arXiv 2611.32615), index everything by one number: the correlation $\rho$ between a user's exposure in the two worlds, $T(0)$ and $T(1)$. Given the two exposure rates, $\rho$ fixes the shares of all four compliance types; monotonicity is its largest feasible value. They derive closed-form sharp bounds for the average treatment effect (ATE) and the complier effect (LATE) at every $\rho$, show that the ATE bounds tighten as $\rho$ falls (more defiers, oddly, can mean tighter bounds), that the LATE bounds need not move monotonically, and give the value of $\rho$ below which the Wald ratio is no longer even a possible answer. Their paper reports plug-in estimates on four trials; here we put a posterior under the same formulas.

E101 measured ad exposure with one-sided noncompliance: the Criteo holdout never saw an ad, so defiers were impossible by design and the Wald ratio was the right tool. This notebook is what happens when the holdout leaks.

part question tool
A What does a test with leakage both ways look like? a simulation from the 16 response types with a known answer
B What do the usual estimates say? exposed against unexposed, intent-to-treat, the Wald ratio
C What do the data identify without monotonicity? the cross-world correlation, Theorems 1 and 2, a linear program as the answer key, a trap in the formulas
D How uncertain are the cells? a Dirichlet-multinomial posterior in PyMC, prior check, diagnostics, the conjugate posterior
E How do the bounds move with the defier share? bounds as PyMC deterministics on a grid, posterior bands, Propositions 2 and 3
F What is outside knowledge about defiers worth? bounds over a range of defier shares
G Can a prior on the compliance types do the work? a latent 16-type model under two priors
H What changes in a survey-sized test? the same analysis with 5,000 users per arm
I What should go to the MMM and the stakeholder? a report indexed by the defier share

A · A test that leaks both ways

Each user has two potential exposures, $T(0)$ in the holdout and $T(1)$ in the test arm, and two potential visits, $Y(0)$ unexposed and $Y(1)$ exposed. The pair of exposures sorts users into four principal strata. Never-takers are out of reach in both arms (they rarely use the platform and do not shop at the retailer). Compliers see the video only if assigned. Always-takers see it either way: the platform reaches them in the test arm and the partner in the holdout. Defiers see it only in the holdout, through the partner, and are suppressed and missed in the test arm. Exclusion holds by construction: assignment changes a user's visit only through exposure, since a suppression no one sees has no effect of its own.

We choose shares and visit probabilities that a media planner would find plausible. Defiers are retail-media shoppers close to purchase, so they visit often and respond strongly; never-takers are light users who barely move. Within each stratum the ad never lowers anyone's chance of a visit, which fixes the 16 response types $(T(0), T(1), Y(0), Y(1))$.

STRATA = ["never", "complier", "defier", "always"]
T_OF = {"never": (0, 0), "complier": (0, 1), "defier": (1, 0), "always": (1, 1)}  # (T(0), T(1))
SHARES = np.array([0.15, 0.65, 0.03, 0.17])
VISIT = {"never": (0.08, 0.10), "complier": (0.12, 0.17), "defier": (0.22, 0.42), "always": (0.28, 0.34)}  # (Y(0), Y(1))

TYPES = list(itertools.product([0, 1], repeat=4))  # response types (T(0), T(1), Y(0), Y(1))


def type_weights(shares, visit):
    """Share of each of the 16 response types; the ad never lowers anyone's chance of a visit."""
    w = np.zeros(16)
    for s, name in zip(shares, STRATA):
        q0, q1 = visit[name]
        for (y0, y1), pr in {(1, 1): q0, (0, 1): q1 - q0, (0, 0): 1 - q1}.items():
            w[TYPES.index((*T_OF[name], y0, y1))] += s * pr
    return w


W_TRUE = type_weights(SHARES, VISIT)
TRUE_LATE = VISIT["complier"][1] - VISIT["complier"][0]
TRUE_ATE = sum(s * (VISIT[k][1] - VISIT[k][0]) for s, k in zip(SHARES, STRATA))
TRUE_PID = SHARES[2]
truth = pd.DataFrame({"share": SHARES, "visit if unexposed": [VISIT[k][0] for k in STRATA],
                      "visit if exposed": [VISIT[k][1] for k in STRATA]}, index=STRATA)
truth["effect"] = truth["visit if exposed"] - truth["visit if unexposed"]
print(truth.round(3).to_string())
print(f"\ntrue effect among compliers (LATE) {TRUE_LATE:.3f}; true effect over all users (ATE) {TRUE_ATE:.4f}; "
      f"defier share {TRUE_PID:.2f}")
          share  visit if unexposed  visit if exposed  effect
never      0.15                0.08              0.10    0.02
complier   0.65                0.12              0.17    0.05
defier     0.03                0.22              0.42    0.20
always     0.17                0.28              0.34    0.06

true effect among compliers (LATE) 0.050; true effect over all users (ATE) 0.0517; defier share 0.03

The true complier effect is 5.0 visit points (12% to 17%), the true average effect over all users is 5.2 points, and 3% of users are defiers whose effect, 20 points, is four times the compliers'. We assign a million users at random, draw each one's response type, and record only what a real test records: arm, exposure and visit. The eight cell counts below are all the data there are.

N_USERS = 1_000_000
CELLS = ["no visit, unexposed", "visit, unexposed", "no visit, exposed", "visit, exposed"]  # index y + 2 t
z = rng.integers(0, 2, N_USERS)  # 1 = test arm, 0 = holdout
kind = rng.choice(16, size=N_USERS, p=W_TRUE)
tt = np.array(TYPES)[kind]
t = np.where(z == 1, tt[:, 1], tt[:, 0])
y = np.where(t == 1, tt[:, 3], tt[:, 2])
counts = np.zeros((2, 4), dtype=int)
np.add.at(counts, (z, y + 2 * t), 1)
N_ARM = counts.sum(axis=1)
tab = pd.DataFrame(counts, index=["holdout (Z=0)", "test (Z=1)"], columns=CELLS)
tab["users"] = N_ARM
print(tab.to_string())
del z, kind, tt, t, y
               no visit, unexposed  visit, unexposed  no visit, exposed  visit, exposed   users
holdout (Z=0)               354977             45306              64386           35509  500178
test (Z=1)                   80387              9231             325841           84363  499822
fig, ax = plt.subplots(figsize=(10, 2.8))
cols = {"never": LIGHT, "complier": BLUE, "defier": RED, "always": PURPLE}
for row, arm in enumerate([0, 1]):
    left = 0.0
    for s, k in zip(SHARES, STRATA):
        exposed = T_OF[k][arm] == 1
        ax.barh(row, s, left=left, color=cols[k], edgecolor="white", hatch="" if exposed else "///", alpha=1 if exposed else 0.45)
        if s > 0.025:
            ax.text(left + s / 2, row, f"{k}\n{s:.0%}", ha="center", va="center", fontsize=9, color=INK)
        left += s
    ax.text(1.01, row, f"{sum(SHARES[i] for i, k in enumerate(STRATA) if T_OF[k][arm]):.0%} exposed", va="center", fontsize=9)
ax.set_yticks([0, 1], ["holdout", "test arm"])
ax.set_xlim(0, 1)
ax.set_xlabel("share of users (solid = exposed to the video, hatched = not exposed)")
ax.set_title("Who is exposed in each arm: the four compliance types of the simulated test");
Figure

B · Four quick answers

Write $p_{yt|z} = \Pr(Y=y, T=t \mid Z=z)$, $\lambda_z = \Pr(T=1 \mid Z=z)$ for the exposure rates, and $\Delta_Y$ for the difference in visit rates between the arms. The platform's own dashboard compares exposed with unexposed users, pooled over both arms. The analyst knows better and computes the intent-to-treat difference $\Delta_Y$, which randomisation identifies with no further assumption, and the Wald ratio $w = \Delta_Y / (\lambda_1 - \lambda_0)$, the textbook per-exposure effect.

P = counts / N_ARM[:, None]  # p_{yt|z} with cells indexed y + 2 t


def quick_answers(P):
    lam0, lam1 = P[0, 2] + P[0, 3], P[1, 2] + P[1, 3]
    itt = (P[1, 1] + P[1, 3]) - (P[0, 1] + P[0, 3])
    as_treated = (P[0, 3] + P[1, 3]) / (lam0 + lam1) - (P[0, 1] + P[1, 1]) / (2 - lam0 - lam1)
    return {"lambda0": lam0, "lambda1": lam1, "itt": itt, "wald": itt / (lam1 - lam0), "as_treated": as_treated}


qa = quick_answers(P)
for k, v in qa.items():
    print(f"{k:11s} {v:.4f}")
print(f"\ntruth: LATE {TRUE_LATE:.3f}, ATE {TRUE_ATE:.4f}")
lambda0     0.1997
lambda1     0.8207
itt         0.0257
wald        0.0414
as_treated  0.1237

truth: LATE 0.050, ATE 0.0517

The exposed-versus-unexposed comparison says 12.4 points, two and a half times the truth: the exposed are mostly always-takers and compliers, who visit more whether or not they see anything, while the unexposed are heavy with never-takers. The intent-to-treat lift is 2.6 points, an honest answer to "what did running this campaign do", including the partner exposures it cancelled. The Wald ratio, 4.1 points, is the number that would go into the MMM. It is 17% below the true complier effect of 5.0, and with half a million users per arm it will come with a tight interval.

The reason is arithmetic. With defiers, $\Delta_Y = \pi_c\,\tau_c - \pi_d\,\tau_d$ and $\lambda_1 - \lambda_0 = \pi_c - \pi_d$, where $\pi$ are stratum shares and $\tau$ stratum effects. The defiers' effect enters with a minus sign, because assignment takes their exposure away. Here $(0.65 \cdot 0.05 - 0.03 \cdot 0.20)/(0.65 - 0.03) = 0.043$ in the population, and our sample of a million lands at 0.041. Nothing in the eight cells warns of this: the four inequalities that monotonicity implies for observable data (Kitagawa 2015) all hold comfortably, as we check below.

C · The cross-world correlation and the defier share

The cross-world correlation fixes the strata

Randomisation identifies the marginal exposure rates $\lambda_0$ and $\lambda_1$, but not how $T(0)$ and $T(1)$ are paired within a user. Tian et al. parameterise that pairing by $\rho = \mathrm{Corr}(T(0), T(1))$. With $\gamma = \sqrt{\lambda_0(1-\lambda_0)\lambda_1(1-\lambda_1)}$,

$$\pi_n = (1-\lambda_0)(1-\lambda_1) + \rho\gamma,\quad \pi_c = (1-\lambda_0)\lambda_1 - \rho\gamma,\quad \pi_d = \lambda_0(1-\lambda_1) - \rho\gamma,\quad \pi_a = \lambda_0\lambda_1 + \rho\gamma .$$

The feasible range runs from $L_\rho = -\min\{(1-\lambda_0)(1-\lambda_1), \lambda_0\lambda_1\}/\gamma$ to $U_\rho = \lambda_0(1-\lambda_1)/\gamma$, and $\rho = U_\rho$ exactly when $\pi_d = 0$, which is monotonicity (their Proposition 1). Since $\pi_d = \gamma(U_\rho - \rho)$, the defier share and $\rho$ carry the same information once the exposure rates are known. We index by $\pi_d$ in the code and on the main axis of the plots: it is the number a stakeholder can argue about ("how many users could the partner's deduplication have cost us?"), and it avoids dividing by $\gamma$, which is zero under one-sided noncompliance, the E101 setting. The $\rho$ scale sits on the top axis.

Sharp bounds at a fixed defier share

At a fixed $\rho$ the strata shares are known, but the visit probabilities within strata are not: the never-takers' $Y(1)$ and the always-takers' $Y(0)$ are never observed. Theorem 1 gives the sharp ATE bounds as the maximum and minimum of nine linear terms each in the cells $p_{yt|z}$; the first four do not depend on $\rho$, the other five depend on it only through $\pi_d$, and they move so that the lower bound falls and the upper bound rises as $\rho$ rises. At $\pi_d = 0$ they are the Balke-Pearl bounds. Theorem 2 gives the LATE bounds as nine terms each divided by the complier share $\pi_c = \Delta_T + \pi_d$; at $\pi_d = 0$ both collapse to the Wald ratio, and their ninth terms give an outer envelope $(\Delta_Y - \pi_d)/(\Delta_T + \pi_d) \le L \le U \le (\Delta_Y + \pi_d)/(\Delta_T + \pi_d)$. We write the eighteen terms once, as a function that runs on NumPy arrays and on PyTensor tensors, so the same code serves the checks here and the PyMC model in part D.

def cell_dict(p):
    """p_{yt|z} keyed 'yt_z' from an array indexed [z, y + 2 t] (NumPy draws or a PyTensor matrix)."""
    return {f"{yv}{tv}_{zv}": p[..., zv, yv + 2 * tv] for zv in (0, 1) for yv in (0, 1) for tv in (0, 1)}


def sharp_bounds(c, g, xp):
    """Theorem 1 (ATE) and Theorem 2 (LATE) of Tian, Liu, Liu & Wu (2026) at defier share g.

    c: cell probabilities from cell_dict, g: defier share pi_d; xp is numpy or pytensor.tensor.
    The formulas do not check that g is compatible with the data: mask g < v and g > pd_max yourself.
    """
    zero = 0 * g + 0 * c["00_0"]
    stack = lambda terms: xp.stack([tm + zero for tm in terms], axis=0)
    p = c
    dT = (p["01_1"] + p["11_1"]) - (p["01_0"] + p["11_0"])
    dY = (p["10_1"] + p["11_1"]) - (p["10_0"] + p["11_0"])
    ate_lo = xp.max(stack([
        -p["10_0"] - p["01_0"], -p["10_1"] - p["01_1"], p["00_0"] + p["11_1"] - 1, p["11_0"] + p["00_1"] - 1,
        g - p["00_1"] - p["10_1"] + p["00_0"] - p["01_0"] - p["01_1"], g - p["10_1"] - p["01_0"] - p["01_1"],
        g - p["10_1"] - p["10_0"] - p["01_0"], g - p["00_1"] + p["00_0"] - 2 * p["10_1"] - p["01_1"],
        2 * g - p["00_1"] - 2 * p["10_1"] + p["00_0"] - p["01_0"] - p["01_1"]]), axis=0)
    ate_hi = xp.min(stack([
        p["00_1"] + p["11_1"], p["00_0"] + p["11_0"], 1 - p["10_0"] - p["01_1"], 1 - p["01_0"] - p["10_1"],
        -g + p["00_1"] + p["10_1"] + p["11_0"] + p["11_1"] - p["10_0"], -g + p["00_1"] + p["11_0"] + p["11_1"],
        -g + p["00_1"] + p["00_0"] + p["11_0"], -g + 2 * p["00_1"] + p["10_1"] + p["11_1"] - p["10_0"],
        -2 * g + 2 * p["00_1"] + p["10_1"] + p["11_0"] + p["11_1"] - p["10_0"]]), axis=0)
    pc = dT + g  # share of compliers
    late_lo = xp.max(stack([
        -p["01_1"], -p["10_0"], p["00_0"] - p["00_1"] - p["01_1"], p["00_0"] + p["01_0"] + p["11_1"] - 1,
        -pc, pc - p["10_0"] - p["01_1"], -pc + p["00_0"] - p["00_1"], -pc + p["11_1"] - p["11_0"], -g + dY]), axis=0) / pc
    late_hi = xp.min(stack([
        p["00_0"], p["11_1"], p["00_0"] + p["01_0"] - p["01_1"], p["11_1"] + p["10_1"] - p["10_0"],
        pc, pc + p["01_0"] - p["01_1"], pc + p["10_1"] - p["10_0"], -pc + p["00_0"] + p["11_1"], g + dY]), axis=0) / pc
    return {"ate_lo": ate_lo, "ate_hi": ate_hi, "late_lo": late_lo, "late_hi": late_hi}


def compliance_range(c, xp):
    """Smallest defier share the data allow (v, our own derivation, checked by LP below) and the largest."""
    lam0, lam1 = c["01_0"] + c["11_0"], c["01_1"] + c["11_1"]
    v = xp.maximum(xp.maximum(xp.maximum(c["00_1"] - c["00_0"], c["10_1"] - c["10_0"]),
                              xp.maximum(c["01_0"] - c["01_1"], c["11_0"] - c["11_1"])), 0.0)
    return v, xp.minimum(lam0, 1 - lam1)


def thresholds(c, xp):
    """Defier shares above which the ATE set shrinks inside Balke-Pearl (Prop. 2) and the Wald ratio
    leaves the LATE set (Prop. 3), both written as d = gamma * (U_rho - rho_bar)."""
    lam0, lam1 = c["01_0"] + c["11_0"], c["01_1"] + c["11_1"]
    w = ((c["10_1"] + c["11_1"]) - (c["10_0"] + c["11_0"])) / (lam1 - lam0)
    d_tau = xp.minimum(xp.minimum(c["00_1"], c["01_0"]), xp.minimum(c["10_1"], c["11_0"]))
    ratio = lambda a, b: xp.where(b > 0, a / xp.where(b > 0, b, 1.0), np.inf)
    terms = [lam0, 1 - lam1, ratio(c["00_1"] + c["11_0"], 1 + w), ratio(c["01_0"] + c["10_1"], 1 - w),
             ratio(xp.minimum(c["00_1"], c["11_0"]), xp.maximum(w, 0.0)), ratio(xp.minimum(c["01_0"], c["10_1"]), xp.maximum(-w, 0.0))]
    d_tauc = terms[0]
    for tm in terms[1:]:
        d_tauc = xp.minimum(d_tauc, tm)
    return d_tau, d_tauc


c_hat = cell_dict(P)
v_hat, pdmax_hat = compliance_range(c_hat, np)
lam0, lam1 = qa["lambda0"], qa["lambda1"]
gam = np.sqrt(lam0 * (1 - lam0) * lam1 * (1 - lam1))
U_rho, L_rho = lam0 * (1 - lam1) / gam, -min((1 - lam0) * (1 - lam1), lam0 * lam1) / gam
print(f"feasible rho in [{L_rho:.3f}, {U_rho:.3f}]; gamma {gam:.3f}; rho = U_rho - defier share / gamma")
print(f"defier share the data allow: [{v_hat:.3f}, {pdmax_hat:.3f}]  (true {TRUE_PID:.2f}, true rho {U_rho - TRUE_PID / gam:.3f})")
for g_ in (0.0, 0.01, TRUE_PID, 0.05, 0.10):
    b_ = sharp_bounds(c_hat, np.float64(g_), np)
    print(f"defier share {g_:.2f} (rho {U_rho - g_ / gam:+.3f}): ATE [{b_['ate_lo']:+.3f}, {b_['ate_hi']:+.3f}]   "
          f"LATE [{b_['late_lo']:+.4f}, {b_['late_hi']:+.4f}]")
feasible rho in [-0.936, 0.233]; gamma 0.153; rho = U_rho - defier share / gamma
defier share the data allow: [0.000, 0.179]  (true 0.03, true rho 0.038)
defier share 0.00 (rho +0.233): ATE [-0.122, +0.258]   LATE [+0.0414, +0.0414]
defier share 0.01 (rho +0.168): ATE [-0.122, +0.258]   LATE [+0.0249, +0.0566]
defier share 0.03 (rho +0.038): ATE [-0.110, +0.258]   LATE [+0.0111, +0.0855]
defier share 0.05 (rho -0.093): ATE [-0.090, +0.258]   LATE [+0.0108, +0.1128]
defier share 0.10 (rho -0.419): ATE [-0.040, +0.228]   LATE [+0.0100, +0.1341]

The share of defiers consistent with the data runs from 0 to 18% ($\rho$ from 0.23 down to $-0.94$); the true 3% sits at $\rho = 0.04$. At 3% the ATE bounds move from Balke-Pearl's $[-12.2, +25.8]$ points to $[-11.0, +25.8]$, while the LATE interval opens from the single Wald value to $[1.1, 8.6]$ points.

The formulas are long and easy to mistype, so we check them against an answer key with no algebra in it: a linear program over the 16 response-type shares, with the eight observed cells and the defier share as equality constraints and the ATE or the complier effect as the objective.

def lp_bounds(P, g=None, target="ate"):
    """Exact bounds by linear programming over the 16 response types (no closed form involved)."""
    A, b = [], []
    for zv, yv, tv in itertools.product([0, 1], repeat=3):
        A.append([float((ty[zv] == tv) and (ty[2 + tv] == yv)) for ty in TYPES])
        b.append(P[zv, yv + 2 * tv])
    is_def = np.array([float(ty[0] == 1 and ty[1] == 0) for ty in TYPES])
    if g is not None:
        A.append(list(is_def))
        b.append(g)
    if target == "ate":
        obj = np.array([ty[3] - ty[2] for ty in TYPES], float)
    elif target == "defiers":
        obj = is_def
    else:
        obj = np.array([(ty[3] - ty[2]) * (ty[0] == 0 and ty[1] == 1) for ty in TYPES], float)
    lo = optimize.linprog(obj, A_eq=A, b_eq=b, bounds=(0, 1), method="highs")
    hi = optimize.linprog(-obj, A_eq=A, b_eq=b, bounds=(0, 1), method="highs")
    if lo.status != 0:
        return np.nan, np.nan
    scale = 1.0 if target != "late" else 1.0 / (P[1, 2] + P[1, 3] - P[0, 2] - P[0, 3] + g)
    return lo.fun * scale, -hi.fun * scale


# 1. the closed forms against the LP at the observed shares, on a grid of defier shares
diffs = []
for g_ in np.linspace(0, pdmax_hat, 25):
    b_ = sharp_bounds(c_hat, np.float64(g_), np)
    diffs += [abs(b_["ate_lo"] - lp_bounds(P, g_)[0]), abs(b_["ate_hi"] - lp_bounds(P, g_)[1]),
              abs(b_["late_lo"] - lp_bounds(P, g_, "late")[0]), abs(b_["late_hi"] - lp_bounds(P, g_, "late")[1])]
print(f"closed form vs LP at 25 defier shares: largest gap {max(diffs):.1e}")
# 2. Balke-Pearl (no restriction on defiers) and the range of defier shares the data allow, by LP
print(f"Balke-Pearl by LP: [{lp_bounds(P)[0]:+.4f}, {lp_bounds(P)[1]:+.4f}]; Theorem 1 at the smallest share: "
      f"[{sharp_bounds(c_hat, v_hat, np)['ate_lo']:+.4f}, {sharp_bounds(c_hat, v_hat, np)['ate_hi']:+.4f}]")
print(f"defier share by LP: [{lp_bounds(P, target='defiers')[0]:.4f}, {lp_bounds(P, target='defiers')[1]:.4f}]")
closed form vs LP at 25 defier shares: largest gap 2.2e-16
Balke-Pearl by LP: [-0.1215, +0.2575]; Theorem 1 at the smallest share: [-0.1215, +0.2575]
defier share by LP: [0.0000, 0.1793]

Closed form and LP agree to rounding error at every defier share we tried, and the LP confirms that the Balke-Pearl bounds equal Theorem 1 at the smallest defier share the data allow. That smallest share needs a word, because the paper does not state it. The LP shows it to be

$$v = \max\{0,\; p_{00|1}-p_{00|0},\; p_{10|1}-p_{10|0},\; p_{01|0}-p_{01|1},\; p_{11|0}-p_{11|1}\},$$

zero exactly when Kitagawa's four inequalities hold. This is our own derivation; we confirmed it, and the equality of Balke-Pearl with Theorem 1 at $\pi_d = v$, by LP on 190 random data-generating distributions (140 of them violating the inequalities) before writing this notebook. It matters because the formulas do not know when they are being asked an impossible question. Below is a small table in which more exposed users visit in the holdout than in the test arm ($p_{11|0} > p_{11|1}$), which no population without defiers can produce. At $\pi_d = 0$ the LP is infeasible, yet Theorem 2 returns a "set" whose lower end lies above its upper end; at $\pi_d = v = 0.02$ formula and LP agree again. The paper checks the inequalities before computing its thresholds; a posterior that draws cells near the boundary needs the same guard on every draw, so the model below masks every defier share below $v$ (and above the largest feasible share, $\min\{\lambda_0, 1-\lambda_1\}$).

# A table that violates one of Kitagawa's inequalities: more exposed visitors in the holdout than in the test arm
P_bad = np.array([[0.62, 0.08, 0.20, 0.10],
                  [0.30, 0.02, 0.60, 0.08]])
c_bad = cell_dict(P_bad)
v_bad, pdmax_bad = compliance_range(c_bad, np)
print(f"v = {v_bad:.3f}; LP: smallest defier share {lp_bounds(P_bad, target='defiers')[0]:.3f}")
for g_ in (0.0, v_bad):
    b_ = sharp_bounds(c_bad, np.float64(g_), np)
    print(f"defier share {g_:.2f}: formula LATE [{b_['late_lo']:+.3f}, {b_['late_hi']:+.3f}], "
          f"LP LATE {np.round(lp_bounds(P_bad, g_, 'late'), 3)}")
v = 0.020; LP: smallest defier share 0.020
defier share 0.00: formula LATE [-0.158, -0.211], LP LATE [nan nan]
defier share 0.02: formula LATE [-0.200, -0.150], LP LATE [-0.2  -0.15]

D · A posterior for the eight cells

The bounds are functions of eight cell probabilities, four per arm. With 500,000 users per arm those cells are pinned down to a few hundredths of a point, but a survey-sized test is a different matter (part H), and in any case the uncertainty should travel through the maximum and minimum of nine terms rather than be bolted on afterwards. The model is the simplest one that does this: a flat Dirichlet prior on the four cells of each arm and a multinomial likelihood for the counts. It is conjugate, so we know the exact posterior, $\mathrm{Dirichlet}(1 + \text{counts})$, and can check NUTS against it. Every bound is a PyTensor deterministic on a grid of 81 defier shares from 0 to 16%, masked where the share is incompatible with that draw.

Relative to the paper, three things are ours. The paper reports plug-in estimates with no inference; the posterior is our addition. We index by the defier share rather than by $\rho$, which is equivalent once the exposure rates are fixed, and we add the feasibility guard. We do not use Theorem 3's conditions for point identification of the LATE (none of them holds in this test), and for a range of defier shares we take extremes over grid points rather than over the continuum.

The prior check is quick and slightly sobering. A flat prior on cells puts half its mass on the test arm being exposed less than the holdout and half on Wald ratios beyond $\pm 1$. A million users overwhelm that, but in a small test where the posterior of $\Delta_T$ straddles zero the paper's convention of relabelling the arms so that $\Delta_T > 0$ cannot be applied draw by draw.

GRID = np.round(np.linspace(0.0, 0.16, 81), 4)


def cells_model(counts):
    coords = {"arm": ["holdout", "test"], "cell": CELLS, "defier_share": GRID}
    with pm.Model(coords=coords) as m:
        p = pm.Dirichlet("p", a=np.ones((2, 4)), dims=("arm", "cell"))
        pm.Multinomial("counts", n=counts.sum(axis=1), p=p, observed=counts, dims=("arm", "cell"))
        c = cell_dict(p)
        lam0, lam1 = c["01_0"] + c["11_0"], c["01_1"] + c["11_1"]
        itt = pm.Deterministic("itt", (c["10_1"] + c["11_1"]) - (c["10_0"] + c["11_0"]))
        pm.Deterministic("delta_t", lam1 - lam0)
        pm.Deterministic("wald", itt / (lam1 - lam0))
        pm.Deterministic("as_treated", (c["11_0"] + c["11_1"]) / (lam0 + lam1) - (c["10_0"] + c["10_1"]) / (2 - lam0 - lam1))
        v, pd_max = compliance_range(c, pt)
        pm.Deterministic("v", v)
        pm.Deterministic("pd_max", pd_max)
        gam = pt.sqrt(lam0 * (1 - lam0) * lam1 * (1 - lam1))
        pm.Deterministic("gamma", gam)
        pm.Deterministic("U_rho", lam0 * (1 - lam1) / gam)
        g = pt.as_tensor_variable(GRID)
        feasible = (g >= v) & (g <= pd_max)
        for k_, val in sharp_bounds(c, g, pt).items():
            pm.Deterministic(k_, pt.where(feasible, val, np.nan), dims="defier_share")
        bp = sharp_bounds(c, v, pt)  # Balke-Pearl = Theorem 1 at the smallest compatible defier share
        pm.Deterministic("bp_lo", bp["ate_lo"])
        pm.Deterministic("bp_hi", bp["ate_hi"])
        d_tau, d_tauc = thresholds(c, pt)
        pm.Deterministic("d_tau", d_tau)
        pm.Deterministic("d_tauc", d_tauc)
    return m


model = cells_model(counts)
with model:
    prior = pm.sample_prior_predictive(draws=2000, random_seed=RANDOM_SEED)
pr = prior.prior
fig, axs = plt.subplots(1, 3, figsize=(12, 3.2))
axs[0].hist(pr["delta_t"].values.ravel(), bins=50, color=MUTED)
axs[0].axvline(qa["lambda1"] - qa["lambda0"], color=INK, ls="--")
axs[0].set_title("exposure gap $\\lambda_1-\\lambda_0$")
axs[1].hist(pr["itt"].values.ravel(), bins=50, color=MUTED)
axs[1].axvline(qa["itt"], color=INK, ls="--")
axs[1].set_title("intent-to-treat lift $\\Delta_Y$")
axs[2].hist(np.clip(pr["wald"].values.ravel(), -3, 3), bins=60, color=MUTED)
axs[2].axvline(qa["wald"], color=INK, ls="--")
axs[2].set_title("Wald ratio (clipped to $\\pm 3$)")
fig.suptitle("Prior implied by a flat Dirichlet on the four cells of each arm (dashed: observed)");
print(f"prior share with lambda1 < lambda0: {(pr['delta_t'].values < 0).mean():.2f}; "
      f"prior share with |Wald| > 1: {(np.abs(pr['wald'].values) > 1).mean():.2f}")
prior share with lambda1 < lambda0: 0.51; prior share with |Wald| > 1: 0.50
Figure

We sample with nutpie, PyMC's default here, with four chains of 1,000 draws after 400 tuning steps.

t0 = time.time()
with model:
    idata = pm.sample(random_seed=RANDOM_SEED, progressbar=False)
print(f"sampled in {time.time() - t0:.1f} s; tuning steps {idata.posterior.attrs.get('tuning_steps')}; "
      f"divergences {int(idata.sample_stats['diverging'].sum())}")
print(az.summary(idata, var_names=["p"], round_to=4).to_string())
summ = pd.concat([az.summary(idata, var_names=[k_], round_to=4) for k_ in ["itt", "wald", "as_treated", "bp_lo", "bp_hi", "d_tau", "d_tauc"]])
print(summ.to_string())
sampled in 9.3 s; tuning steps 400; divergences 0
                                   mean      sd  eti89_lb  eti89_ub   ess_bulk   ess_tail   r_hat  mcse_mean  mcse_sd
p[holdout, no visit, unexposed]  0.7097  0.0006    0.7086    0.7107  2437.3974  1652.3441  1.0005        0.0      0.0
p[holdout, visit, unexposed]     0.0906  0.0004    0.0899    0.0912  2108.3119  1435.7695  1.0043        0.0      0.0
p[holdout, no visit, exposed]    0.1287  0.0005    0.1280    0.1295  2237.6789  1427.0795  1.0013        0.0      0.0
p[holdout, visit, exposed]       0.0710  0.0004    0.0705    0.0716  2756.9840  1522.0571  0.9996        0.0      0.0
p[test, no visit, unexposed]     0.1608  0.0005    0.1600    0.1616  2183.3046  1653.9800  1.0004        0.0      0.0
p[test, visit, unexposed]        0.0185  0.0002    0.0182    0.0188   969.8121  1048.3018  1.0021        0.0      0.0
p[test, no visit, exposed]       0.6519  0.0007    0.6509    0.6530  2293.6882  1797.1547  1.0012        0.0      0.0
p[test, visit, exposed]          0.1688  0.0005    0.1679    0.1696  2630.4051  1628.4498  1.0002        0.0      0.0
              mean      sd  eti89_lb  eti89_ub   ess_bulk   ess_tail   r_hat  mcse_mean  mcse_sd
itt         0.0257  0.0007    0.0245    0.0269  2075.3629  1709.1677  1.0016        0.0      0.0
wald        0.0413  0.0012    0.0394    0.0433  2052.5806  1687.6982  1.0015        0.0      0.0
as_treated  0.1237  0.0007    0.1225    0.1249  2377.0682  1645.3570  1.0026        0.0      0.0
bp_lo      -0.1215  0.0008   -0.1228   -0.1202  2407.9920  1928.1650  0.9995        0.0      0.0
bp_hi       0.2575  0.0008    0.2563    0.2588  2222.6937  1565.2154  1.0039        0.0      0.0
d_tau       0.0185  0.0002    0.0182    0.0188   969.8121  1048.3018  1.0021        0.0      0.0
d_tauc      0.1535  0.0006    0.1526    0.1545  1897.3151  1611.8171  0.9998        0.0      0.0

No divergences, $\hat R$ at most 1.005, bulk ESS of roughly 800 or more for every cell. The posterior of the Wald ratio is 4.1 points with a standard deviation of about 0.12; its 89% interval, 3.9 to 4.3, sits well below the true 5.0. This is the failure in its purest form: the estimate is precise, the experiment is randomised and large, and the answer is wrong, because the one assumption that turns a ratio of two identified differences into a causal effect is false. More data would only make the wrong answer more confident.

Two checks before we trust the machinery. Exact draws from the conjugate Dirichlet posterior match NUTS for the derived quantities to the third significant figure in means and within a few percent in standard deviations, and the PyTensor deterministics agree with the NumPy formulas on the same draws to rounding error.

post = az.extract(idata, var_names=["p"]).transpose("sample", "arm", "cell").values  # (S, 2, 4)
exact = np.stack([rng.dirichlet(1 + counts[a], size=post.shape[0]) for a in (0, 1)], axis=1)
def derived(q):
    c = cell_dict(q)
    b = sharp_bounds({k_: v_[:, None] for k_, v_ in c.items()}, np.array([0.02]), np)
    lam0, lam1 = c["01_0"] + c["11_0"], c["01_1"] + c["11_1"]
    itt = (c["10_1"] + c["11_1"]) - (c["10_0"] + c["11_0"])
    return {"ITT": itt, "Wald": itt / (lam1 - lam0), "LATE lower at 2%": b["late_lo"][:, 0], "LATE upper at 2%": b["late_hi"][:, 0]}


d_nuts, d_exact = derived(post), derived(exact)
chk = pd.DataFrame({"NUTS mean": {k_: v_.mean() for k_, v_ in d_nuts.items()}, "exact mean": {k_: v_.mean() for k_, v_ in d_exact.items()},
                    "NUTS sd": {k_: v_.std() for k_, v_ in d_nuts.items()}, "exact sd": {k_: v_.std() for k_, v_ in d_exact.items()}})
print(chk.round(5).to_string())
k2 = int(np.argmin(np.abs(GRID - 0.02)))
pyt = az.extract(idata, var_names=["late_lo"]).values[k2]
print(f"PyTensor deterministic vs NumPy on the same draws, LATE lower bound at 2%: largest gap {np.abs(pyt - d_nuts['LATE lower at 2%']).max():.1e}")
                  NUTS mean  exact mean  NUTS sd  exact sd
ITT                 0.02568     0.02570  0.00075   0.00077
Wald                0.04135     0.04139  0.00120   0.00122
LATE lower at 2%    0.01123     0.01128  0.00113   0.00117
LATE upper at 2%    0.07126     0.07130  0.00116   0.00118
PyTensor deterministic vs NumPy on the same draws, LATE lower bound at 2%: largest gap 2.6e-16

E · Bounds indexed by the defier share

Now the main figure. For every defier share on the grid we plot the posterior median of each bound with a 94% band, the true effects, and the reference lines: Balke-Pearl for the ATE, the Wald ratio and the outer envelope for the LATE. The third panel turns the posterior into statements: the probability that a lower bound is above zero, or above 3 visit points, which is the media team's bar (a reached user must add three visits per hundred for video to beat paid search on cost per visit).

def bands(idata, name):
    x = az.extract(idata, var_names=[name]).values  # (grid, sample)
    return np.nanquantile(x, [0.03, 0.5, 0.97], axis=1)


post_mean = {k_: float(idata.posterior[k_].mean()) for k_ in ["U_rho", "gamma", "wald", "bp_lo", "bp_hi", "d_tau", "d_tauc", "itt"]}
to_rho = lambda x: post_mean["U_rho"] - x / post_mean["gamma"]
to_pd = lambda r: (post_mean["U_rho"] - r) * post_mean["gamma"]

fig, axs = plt.subplots(1, 3, figsize=(15, 4.6))
ax = axs[0]
for nm, col in [("ate_lo", BLUE), ("ate_hi", BLUE)]:
    q = bands(idata, nm)
    ax.fill_between(GRID, q[0], q[2], color=col, alpha=0.25, lw=0)
    ax.plot(GRID, q[1], color=col)
ax.axhline(post_mean["bp_lo"], color=MUTED, ls="--", label="Balke-Pearl")
ax.axhline(post_mean["bp_hi"], color=MUTED, ls="--")
ax.axhline(TRUE_ATE, color=INK, lw=1.5, label="true ATE")
ax.axvline(post_mean["d_tau"], color=ORANGE, ls=":", label="Prop. 2 threshold")
ax.set_title("ATE bounds (all users)")
ax = axs[1]
for nm in ("late_lo", "late_hi"):
    q = bands(idata, nm)
    ax.fill_between(GRID, q[0], q[2], color=AQUA, alpha=0.3, lw=0)
    ax.plot(GRID, q[1], color=AQUA)
ax.axhline(post_mean["wald"], color=PURPLE, ls="--", label="Wald ratio")
ax.axhline(TRUE_LATE, color=INK, lw=1.5, label="true LATE")
ax.plot(GRID, (post_mean["itt"] - GRID) / (post_mean["itt"] / post_mean["wald"] + GRID), color=MUTED, lw=1, ls="-.", label="outer envelope")
ax.plot(GRID, (post_mean["itt"] + GRID) / (post_mean["itt"] / post_mean["wald"] + GRID), color=MUTED, lw=1, ls="-.")
ax.axvline(TRUE_PID, color=RED, lw=1, alpha=0.6, label="true defier share")
ax.axvline(post_mean["d_tauc"], color=ORANGE, ls=":", label="Prop. 3 threshold")
ax.set_ylim(-0.08, 0.2)
ax.set_title("LATE bounds (compliers)")
for a_ in axs[:2]:
    a_.set_xlabel("defier share $\\pi_d$")
    a_.legend(fontsize=8, loc="upper center", bbox_to_anchor=(0.5, -0.27), ncol=3)
    sec = a_.secondary_xaxis("top", functions=(to_rho, to_pd))
    sec.set_xlabel("cross-world correlation $\\rho$", fontsize=9)
axs[0].axvline(TRUE_PID, color=RED, lw=1, alpha=0.6, label="true defier share")
ax = axs[2]
lo_a = az.extract(idata, var_names=["ate_lo"]).values
lo_l = az.extract(idata, var_names=["late_lo"]).values
hi_l = az.extract(idata, var_names=["late_hi"]).values
ax.plot(GRID, (lo_a > 0).mean(axis=1), color=BLUE, label="P(ATE lower bound > 0)")
ax.plot(GRID, (lo_l > 0).mean(axis=1), color=AQUA, lw=4, alpha=0.5, label="P(LATE lower bound > 0)")
ax.plot(GRID, (lo_l > 0.03).mean(axis=1), color=AQUA, ls="--", label="P(LATE lower bound > 0.03)")
ax.plot(GRID, ((lo_l <= TRUE_LATE) & (hi_l >= TRUE_LATE)).mean(axis=1), color=INK, ls=":", label="P(set contains true LATE)")
ax.set_xlabel("defier share $\\pi_d$")
ax.set_ylim(-0.03, 1.03)
ax.legend(fontsize=8, loc="upper center", bbox_to_anchor=(0.5, -0.27), ncol=2)
ax.set_title("What the posterior lets us claim")
fig.suptitle("Sharp bounds as the defier share grows (bands: 94% posterior intervals of each endpoint)");
Figure
def at(name, g_):
    x = az.extract(idata, var_names=[name]).values[int(np.argmin(np.abs(GRID - g_)))]
    return np.nanquantile(x, [0.03, 0.5, 0.97])


for g_ in (0.0, 0.005, 0.01, 0.02, TRUE_PID, 0.05, 0.10, 0.15):
    print(f"defier share {g_:.3f}: ATE [{at('ate_lo', g_)[1]:+.3f}, {at('ate_hi', g_)[1]:+.3f}]  "
          f"LATE [{at('late_lo', g_)[1]:+.4f}, {at('late_hi', g_)[1]:+.4f}]  "
          f"(outer 94%: [{at('late_lo', g_)[0]:+.4f}, {at('late_hi', g_)[2]:+.4f}])")
print(f"\nthresholds (posterior mean): ATE tightens beyond {post_mean['d_tau']:.4f}, "
      f"Wald leaves the LATE set beyond {post_mean['d_tauc']:.4f}; LATE sign envelope needs < ITT {post_mean['itt']:.4f}")
print(f"in rho: {to_rho(post_mean['d_tau']):.3f} and {to_rho(post_mean['d_tauc']):.3f}; monotonicity at rho = {post_mean['U_rho']:.3f}")
print(f"draws with v > 0 (data look incompatible with monotonicity): {(az.extract(idata, var_names=['v']).values > 0).mean():.3f}")
contains = ((lo_l <= TRUE_LATE) & (hi_l >= TRUE_LATE)).mean(axis=1)
print(f"the set first contains the true LATE (posterior probability > 0.5) at defier share {GRID[np.argmax(contains > 0.5)]:.3f}; "
      f"P(LATE lower bound > 0.03) falls below 0.5 at {GRID[np.argmax((lo_l > 0.03).mean(axis=1) < 0.5)]:.3f}; "
      f"P(ATE lower bound > 0) passes 0.5 at {GRID[np.argmax((lo_a > 0).mean(axis=1) > 0.5)]:.3f}")
defier share 0.000: ATE [-0.122, +0.258]  LATE [+0.0414, +0.0414]  (outer 94%: [+0.0391, +0.0436])
defier share 0.005: ATE [-0.122, +0.258]  LATE [+0.0347, +0.0475]  (outer 94%: [+0.0324, +0.0498])
defier share 0.010: ATE [-0.122, +0.258]  LATE [+0.0248, +0.0565]  (outer 94%: [+0.0226, +0.0588])
defier share 0.020: ATE [-0.120, +0.258]  LATE [+0.0112, +0.0713]  (outer 94%: [+0.0091, +0.0735])
defier share 0.030: ATE [-0.110, +0.258]  LATE [+0.0111, +0.0855]  (outer 94%: [+0.0090, +0.0877])
defier share 0.050: ATE [-0.090, +0.258]  LATE [+0.0107, +0.1128]  (outer 94%: [+0.0087, +0.1149])
defier share 0.100: ATE [-0.040, +0.229]  LATE [+0.0100, +0.1341]  (outer 94%: [+0.0081, +0.1359])
defier share 0.150: ATE [+0.031, +0.179]  LATE [+0.0369, +0.1254]  (outer 94%: [+0.0350, +0.1271])

thresholds (posterior mean): ATE tightens beyond 0.0185, Wald leaves the LATE set beyond 0.1535; LATE sign envelope needs < ITT 0.0257
in rho: 0.113 and -0.768; monotonicity at rho = 0.234
draws with v > 0 (data look incompatible with monotonicity): 0.000
the set first contains the true LATE (posterior probability > 0.5) at defier share 0.006; P(LATE lower bound > 0.03) falls below 0.5 at 0.008; P(ATE lower bound > 0) passes 0.5 at 0.136

With half a million users per arm the bands are thinner than the lines: what we see is identification, not noise. Four things stand out.

The LATE set opens quickly and contains the truth almost at once. At $\pi_d = 0$ it is the Wald point, 4.1. By 1% defiers it is $[2.5, 5.7]$ points, and the truth enters at about 0.6%, a share so small that no one could rule it out. At the true 3% the set is $[1.1, 8.6]$. Its lower end then flattens at about one point for all shares up to 13%, so the sign of the complier effect is identified whatever the defier share: the posterior probability that the lower bound is positive is one everywhere on the grid. The envelope (dash-dot) would have allowed a negative effect beyond 2.6% defiers (the ITT lift); one of the other eight terms binds first. Past 13% the lower bound rises again, and by 16% it has climbed to the truth and the set starts to exclude it: the sets at different $\rho$ are not nested, as the paper's Remark 1 warns, and the truth is only guaranteed to lie in the set at the true share.

The 3-point bar is safe only under monotonicity or nearly so. The probability that the lower bound clears 3 points drops below one half at about 0.8% defiers. The Wald ratio clears the bar comfortably, and so does the truth; the data alone, without the no-defier assumption, do not.

The ATE barely moves, and only for a reason that sounds backwards. Proposition 2 says the ATE set is strictly inside Balke-Pearl exactly when $\pi_d > d_\tau = \min\{p_{00|1}, p_{01|0}, p_{10|1}, p_{11|0}\}$, here 1.85% ($\rho = 0.11$). Below that, allowing defiers costs nothing; above it, believing in more defiers tightens the bounds, because a defier's outcomes are observed in both exposure states (one in each arm) while never-takers and always-takers each hide one. At the true 3% the lower bound rises from $-12.2$ to $-11.0$ points; the bounds exclude zero only past about 13.5% defiers. With 15% of users unreachable and 17% exposed regardless, the average effect over all users is out of reach of this experiment.

The Wald ratio stays a possible answer far beyond where it is right. Proposition 3 gives the share above which the Wald ratio leaves the LATE set, $d_{\tau_c}$, here 15.4% ($\rho = -0.77$). The ordering of Proposition 4 holds ($d_{\tau_c} \ge d_\tau$). So the data never contradict the Wald number in any plausible range: it is inside the identified set and 17% from the truth at the same time. Being consistent with the data is a much weaker property than being identified by them.

No posterior draw had $v > 0$, so the feasibility guard never bit; Kitagawa's inequalities hold here with a wide margin. As a last check we solve the LP at the posterior-mean cells for every grid point.

p_mean = idata.posterior["p"].mean(("chain", "draw")).values
c_mean = cell_dict(p_mean)
gaps = []
for g_ in GRID[GRID <= float(compliance_range(c_mean, np)[1])]:
    b_ = sharp_bounds(c_mean, np.float64(g_), np)
    la, ll = lp_bounds(p_mean, g_), lp_bounds(p_mean, g_, "late")
    gaps.append(max(abs(b_["ate_lo"] - la[0]), abs(b_["ate_hi"] - la[1]), abs(b_["late_lo"] - ll[0]), abs(b_["late_hi"] - ll[1])))
print(f"{len(gaps)} grid points checked against the LP at the posterior mean cells: largest gap {max(gaps):.1e}")
81 grid points checked against the LP at the posterior mean cells: largest gap 2.7e-15

F · What the partner's logs are worth

The partner's logs give the measurement lead something better than a guess. They show that about 9% of test-arm users sat on the deduplication list and never got a platform impression, and the partner reaches roughly a third of the shoppers it targets. That makes defiers something like 3%, and the lead is comfortable defending somewhere between 1% and 5%. A range restriction is what Assumption 4 of the paper formalises. For the ATE the bounds are monotone in $\rho$, so the sharp set over a range is the set at its upper end in $\rho$, its smallest defier share (Corollary 1). For the LATE, which is not monotone, the sharp set is the smallest lower bound and the largest upper bound over the range; we take them over the grid points inside it, draw by draw. The "outer 94%" columns take the 3rd percentile of the lower bound and the 97th of the upper, a simple way to fold sampling noise into an identified set; it is a convenience, not a calibrated inference procedure.

def range_set(idata, lo_g, hi_g):
    """Sharp sets when the defier share is only known to lie in [lo_g, hi_g] (Corollary 1 and Section 3.3)."""
    sel = (GRID >= lo_g - 1e-9) & (GRID <= hi_g + 1e-9)
    ex = {k_: az.extract(idata, var_names=[k_]).values[sel] for k_ in ["ate_lo", "ate_hi", "late_lo", "late_hi"]}
    return {"ATE": (ex["ate_lo"][0], ex["ate_hi"][0]),  # ATE: the bounds at the SMALLEST defier share of the range
            "LATE": (np.nanmin(ex["late_lo"], axis=0), np.nanmax(ex["late_hi"], axis=0))}


rows = []
for lab, (a_, b_) in {"monotonicity (no defiers)": (0, 0), "logs: 1% to 5%": (0.01, 0.05), "logs: 2% to 4%": (0.02, 0.04),
                      "anything the data allow": (0, 0.16)}.items():
    rs = range_set(idata, a_, b_)
    for est, (lo, hi) in rs.items():
        rows.append({"assumption": lab, "estimand": est, "lower (median)": np.median(lo), "upper (median)": np.median(hi),
                     "outer 94% low": np.quantile(lo, 0.03), "outer 94% high": np.quantile(hi, 0.97),
                     "contains truth": (np.median(lo) <= (TRUE_ATE if est == "ATE" else TRUE_LATE) <= np.median(hi))})
print(pd.DataFrame(rows).round(4).to_string(index=False))
               assumption estimand  lower (median)  upper (median)  outer 94% low  outer 94% high  contains truth
monotonicity (no defiers)      ATE         -0.1215          0.2575        -0.1230          0.2590            True
monotonicity (no defiers)     LATE          0.0414          0.0414         0.0391          0.0436           False
           logs: 1% to 5%      ATE         -0.1215          0.2575        -0.1230          0.2590            True
           logs: 1% to 5%     LATE          0.0107          0.1128         0.0087          0.1149            True
           logs: 2% to 4%      ATE         -0.1200          0.2575        -0.1216          0.2590            True
           logs: 2% to 4%     LATE          0.0109          0.0994         0.0088          0.1015            True
  anything the data allow      ATE         -0.1215          0.2575        -0.1230          0.2590            True
  anything the data allow     LATE          0.0096          0.1395         0.0078          0.1414            True

G · Putting a prior on the compliance types

The range from 1% to 5% gives the complier effect as 1.1 to 11.3 points (outer 94%: 0.9 to 11.5), which contains the truth and excludes zero but does not decide the 3-point bar. Narrowing the range to 2-4% trims the top to 9.9 points and leaves the bottom where it was, since the lower bound is flat there. The ATE does not move at all, because Corollary 1 evaluates it at the low end of the range, 1%, which is below $d_\tau$: for the ATE only a confident lower limit on defiers above 1.85% helps, and the partner's logs do not provide one.

A Bayesian modeller will want to do better than an interval: put a prior on the compliance types, let the data update it, and report a posterior for the LATE. E101 did exactly that with a principal-strata model, and there it was fine, because with one-sided noncompliance the strata are identified. Here we write the latent version directly: a Dirichlet prior over the shares of the 16 response types, with the eight observed cells as linear functions of them and the same multinomial likelihood. We fit it twice, once with a flat prior over types and once with a prior sceptical of defiers (concentration 0.1 on the four defier types, 1 elsewhere). The data constrain only eight linear combinations of the 16 shares; along the other directions the posterior is the prior, conditioned on the data being reproduced. We sample with nutpie's low-rank mass matrix, which handles the thin ridge the likelihood leaves. The sparse Dirichlet of the second prior gave 94 divergences with default settings in a first run, so it gets 1,000 tuning steps and a target acceptance of 0.95.

M_TYPES = np.zeros((2, 4, 16))
for i, ty in enumerate(TYPES):
    for zv in (0, 1):
        tv = ty[zv]
        M_TYPES[zv, ty[2 + tv] + 2 * tv, i] = 1.0
IS_DEF = np.array([ty[0] == 1 and ty[1] == 0 for ty in TYPES])
IS_COMP = np.array([ty[0] == 0 and ty[1] == 1 for ty in TYPES])
EFF = np.array([ty[3] - ty[2] for ty in TYPES], float)


def types_model(counts, alpha):
    with pm.Model() as m:
        w = pm.Dirichlet("w", a=alpha)
        cells = pt.stack([pt.dot(M_TYPES[0], w), pt.dot(M_TYPES[1], w)])
        pm.Multinomial("counts", n=counts.sum(axis=1), p=cells, observed=counts)
        pm.Deterministic("defier_share", pt.dot(IS_DEF.astype(float), w))
        pm.Deterministic("late", pt.dot(EFF * IS_COMP, w) / pt.dot(IS_COMP.astype(float), w))
        pm.Deterministic("ate", pt.dot(EFF, w))
    return m


fits = {}
for lab, alpha in {"flat over 16 types": np.ones(16), "sceptical of defiers": np.where(IS_DEF, 0.1, 1.0)}.items():
    extra = {} if lab.startswith("flat") else {"tune": 1000, "target_accept": 0.95}  # sparse Dirichlet: see text
    t0 = time.time()
    with types_model(counts, alpha):
        pri = pm.sample_prior_predictive(draws=4000, random_seed=RANDOM_SEED).prior
        fit = pm.sample(random_seed=RANDOM_SEED, progressbar=False, nuts={"adaptation": "low_rank"}, **extra)
    fits[lab] = (pri, fit)
    s_ = az.summary(fit, var_names=["defier_share", "late", "ate"], round_to=4)
    print(f"{lab}: {time.time() - t0:.0f} s, divergences {int(fit.sample_stats['diverging'].sum())}, "
          f"max r_hat {s_['r_hat'].max():.3f}, min bulk ESS {s_['ess_bulk'].min():.0f}")
    print(s_[["mean", "sd", "eti89_lb", "eti89_ub"]].to_string())
flat over 16 types: 16 s, divergences 0, max r_hat 1.003, min bulk ESS 669
                mean      sd  eti89_lb  eti89_ub
defier_share  0.0618  0.0301    0.0212    0.1170
late          0.0585  0.0214    0.0319    0.0994
ate           0.0832  0.0497    0.0017    0.1633
sceptical of defiers: 20 s, divergences 0, max r_hat 1.005, min bulk ESS 225
                mean      sd  eti89_lb  eti89_ub
defier_share  0.0068  0.0095    0.0000    0.0269
late          0.0436  0.0094    0.0355    0.0616
ate           0.0618  0.0618   -0.0356    0.1647
fig, axs = plt.subplots(1, 2, figsize=(12, 3.8))
for (lab, (pri, fit)), col in zip(fits.items(), [BLUE, ORANGE]):
    pd_post = fit.posterior["defier_share"].values.ravel()
    axs[0].hist(pd_post, bins=60, range=(0, 0.2), density=True, color=col, alpha=0.5, label=f"{lab}: posterior")
    pd_prior = pri["defier_share"].values.ravel()
    axs[0].hist(pd_prior[pd_prior < 0.2], bins=60, range=(0, 0.2), density=True, histtype="step", color=col, lw=1.5,
                label=f"{lab}: prior, cut at 0.2")
    axs[1].hist(fit.posterior["late"].values.ravel(), bins=60, range=(0, 0.14), density=True, color=col, alpha=0.5, label=lab)
axs[0].axvline(TRUE_PID, color=RED, lw=1.5, label="true share")
axs[0].axvline(float(idata.posterior["pd_max"].mean()), color=MUTED, ls="--", label="largest share the data allow")
axs[0].set_xlabel("defier share")
axs[0].set_ylim(0, 60)
axs[0].legend(fontsize=7, loc="upper right")
axs[1].axvline(TRUE_LATE, color=INK, lw=1.5, label="true LATE")
axs[1].axvline(post_mean["wald"], color=PURPLE, ls="--", label="Wald")
rs_all = range_set(idata, 0, 0.16)["LATE"]
axs[1].axvspan(np.median(rs_all[0]), np.median(rs_all[1]), color=LIGHT, alpha=0.5, label="identified set (any share)")
axs[1].set_xlabel("effect among compliers")
axs[1].legend(fontsize=7)
fig.suptitle("A latent-type model answers with its prior: two priors, the same million users");
Figure

Both fits sample cleanly in the end (no divergences, $\hat R \le 1.005$, bulk ESS above 200), and both look like ordinary, well-behaved posteriors. They should not be read as such. Under the flat prior the defier share comes back at 6% (89% interval 2% to 12%), twice the truth, with almost no mass on the monotone case, and the complier effect at 5.9 points (3.2 to 9.9). Under the sceptical prior the defier share is 0.7% (0 to 2.7%) and the complier effect 4.4 points (3.6 to 6.2), hugging the Wald ratio. The million users are the same; only the prior changed, and it moved the answer by a point and a half and cut its width by more than half. The flat-prior fit also gives an average effect of 8.3 points with an 89% interval of 0.2 to 16.3, which excludes zero, while the identified set for that quantity runs from $-12$ to $+26$ points. The prior made that interval.

The left panel shows why. The data fix the cells and with them the range of feasible defier shares, 0 to 18% (dashed line); within that range the posterior takes whatever shape the prior gives it, conditional on reproducing the cells. Put the prior instead on the position of $\rho$ within its feasible range, independent of the cells, and the posterior returns that prior unchanged, because the likelihood does not contain it. A prior on the compliance types is a legitimate way to state a belief, but what comes out is the belief, propagated. The honest display is the one in part E: the identified set as a function of the sensitivity parameter, with the belief stated separately, as a range a reader can dispute.

H · A survey-sized replay

Not every lift test has a million users. Brand lift studies run on survey panels of a few thousand respondents, and many advertisers' conversion tests are not much bigger. We draw a new test from the same population with 5,000 users per arm and rerun the cells model unchanged.

N_SMALL = 5_000
counts_small = np.array([rng.multinomial(N_SMALL, cellp) for cellp in [W_TRUE @ M_TYPES[0].T, W_TRUE @ M_TYPES[1].T]])
with cells_model(counts_small):
    idata_small = pm.sample(random_seed=RANDOM_SEED, progressbar=False)
print(f"divergences {int(idata_small.sample_stats['diverging'].sum())}; max r_hat p "
      f"{float(az.rhat(idata_small, var_names=['p'])['p'].max()):.3f}")
print(az.summary(idata_small, var_names=["wald"], round_to=4).to_string())
print(f"draws with v > 0: {(az.extract(idata_small, var_names=['v']).values > 0).mean():.3f}")
fig, ax = plt.subplots(figsize=(8, 4.2))
for idt, col, lab in [(idata_small, ORANGE, f"{N_SMALL:,} per arm"), (idata, AQUA, "about 500,000 per arm")]:
    for nm in ("late_lo", "late_hi"):
        q = bands(idt, nm)
        ax.fill_between(GRID, q[0], q[2], color=col, alpha=0.3, lw=0, label=lab if nm == "late_lo" else None)
        ax.plot(GRID, q[1], color=col)
ax.axhline(TRUE_LATE, color=INK, lw=1.5, label="true LATE")
ax.set_xlabel("defier share $\\pi_d$")
ax.set_ylabel("LATE bounds")
ax.legend(fontsize=8)
ax.set_title("Sampling noise against identification: LATE bounds at two sample sizes");
for g_ in (0.0, 0.03):
    k_ = int(np.argmin(np.abs(GRID - g_)))
    lo_ = az.extract(idata_small, var_names=["late_lo"]).values[k_]
    hi_ = az.extract(idata_small, var_names=["late_hi"]).values[k_]
    print(f"small test, defier share {g_:.2f}: LATE [{np.median(lo_):+.4f}, {np.median(hi_):+.4f}], "
          f"outer 94% [{np.quantile(lo_, 0.03):+.4f}, {np.quantile(hi_, 0.97):+.4f}]")
divergences 0; max r_hat p 1.007
        mean      sd  eti89_lb  eti89_ub   ess_bulk   ess_tail   r_hat  mcse_mean  mcse_sd
wald  0.0462  0.0122    0.0268    0.0655  1959.1311  1690.4856  1.0006     0.0003   0.0002
draws with v > 0: 0.000
small test, defier share 0.00: LATE [+0.0464, +0.0464], outer 94% [+0.0235, +0.0687]
small test, defier share 0.03: LATE [+0.0196, +0.0906], outer 94% [-0.0026, +0.1118]
Figure

At this size the Wald ratio is 4.6 points with a standard deviation of 1.2 (89% interval 2.7 to 6.6). It covers the truth, and its 0.7-point bias in the population is buried in noise. A small test hides the monotonicity failure that the large one exposed; the bias does not shrink with the sample, it only stops being visible. The bounds widen by the sampling noise: at 3% defiers the median set is $[2.0, 9.1]$ points, but its outer 94% interval, $[-0.3, 11.2]$, now reaches below zero. Noise and partial identification add up: in a survey-sized test the noise is the larger part at small defier shares, and by 2% the identified set is already wider than the noise band. No draw violated Kitagawa's inequalities here either; in tests with rare outcomes or small arms they can, and the guard from part C then masks the defier shares a draw cannot support.

I · What to report

The measurement lead started with one number for the MMM and ends with three, and the three are more useful than the one.

What the campaign did is identified. Running the platform campaign, as it was run, raised the visit rate of the assigned audience by 2.6 points (89% interval 2.45 to 2.69), net of the partner exposures that deduplication cancelled. That is the quantity an MMM should be calibrated against in spend terms: incremental visits per dollar is this lift times the assigned audience divided by the platform spend, and it needs no assumption about defiers. Calibrating on this rather than on a per-exposure effect sidesteps the whole problem.

What seeing the video does depends on a number the test cannot measure. If no one was a defier, a reached user's visit probability rose by 4.1 points. If 1% were, the data allow 2.5 to 5.7; at 3%, 1.1 to 8.6; over the partner's plausible range of 1% to 5%, 1.1 to 11.3. The direction is safe at any share. Whether the effect clears the team's 3-point bar is decided only if defiers are below about 0.8% of users, about one in 120. If the MMM's structure needs a per-exposure prior, it should spread over the identified set at the stated range, not sit at 4.1 with a standard deviation of 0.13; the latter is a confident statement about something the experiment did not measure.

The sensitivity parameter has to be spoken in the stakeholder's units. Nobody has an intuition for a correlation of 0.04 between two exposures in parallel worlds; anyone in the room can argue about "out of every hundred users, how many could the partner's deduplication have switched from exposed to unexposed". The defier share is $\gamma(U_\rho - \rho)$, so the translation is exact, and the tipping-point sentence writes itself: "the effect of a reached user is positive whatever the overlap with the partner; it beats paid search only if fewer than about one user in 120 was suppressed by the partner and then missed by the platform, and the partner's logs put that at one to five in a hundred." The fix for the next test is in the design rather than the analysis: get the partner to honour the holdout list, or have it log suppressions in both arms so the defiers can be counted.

The same structure appears in geo tests. A holdout region reached by national TV or by a neighbour's spill-in is an always-taker; a test region whose local buy displaces a national flight that would otherwise have reached it is a defier. Wherever assignment can take exposure away from someone, the Wald ratio's precision is borrowed from an assumption, and the bounds above are the price of repaying it.

Summary

  • The Wald ratio was precise and wrong. With 3% defiers whose effect (20 points) is four times the compliers', a randomised test of a million users gave a Wald ratio of 4.1 visit points with a posterior standard deviation of about 0.12, against a true complier effect of 5.0. The data passed every observable check of monotonicity. Limit: the size of the bias depends on how different the defiers are, which the data cannot tell.
  • Exposed against unexposed was off by a factor of two and a half (12.4 points), and the intent-to-treat lift (2.6 points) was the only per-user number identified without extra assumptions; it is the right calibration target for an MMM in spend terms.
  • Bounds indexed by the defier share contained the truth from about 0.6% defiers on, and identified the sign at every share. The complier effect lay in 2.5 to 5.7 points at 1% defiers, 1.1 to 8.6 at the true 3% and 1.1 to 11.3 over a 1% to 5% range; the 3-point bar was safe only below about 0.8%. Limit: the sets are not nested, and at implausible shares (16%) the set no longer contains the truth.
  • The ATE was out of reach and the correlation restriction barely helped. Balke-Pearl gave $-12$ to $+26$ points; the bounds tighten only above a 1.85% defier share (Proposition 2), reached $-11$ to $+26$ at the true 3%, and exclude zero only past 13.5%. Only a confident lower limit on defiers helps the ATE. Limit: driven by the 15% never-reached and 17% always-exposed users of this design.
  • The closed forms were right and the guard is needed. Theorems 1 and 2 matched an exact linear program over the 16 response types to $10^{-15}$ at every grid point; the smallest feasible defier share $v$ (our derivation, LP-verified) marks where they stop meaning anything, since the formulas return numbers, even inverted intervals, for impossible shares.
  • A prior on the compliance types answered with the prior. The same million users gave a complier effect of 5.9 (3.2 to 9.9) under a flat prior on 16 types and 4.4 (3.6 to 6.2) under a prior sceptical of defiers, and an ATE interval that excluded zero although the identified set runs from $-12$ to $+26$ points. Limit: one simulated design and two priors.
  • In a survey-sized test (5,000 per arm) the Wald bias hid in the noise (4.6 ± 1.2 points), and the posterior bounds at 3% defiers reached below zero once sampling noise was folded in.

Try it yourself

  1. Defiers who respond like compliers. Set the defiers' visit probabilities to those of the compliers (12% and 17%) and rerun parts A to E. The Wald ratio is now unbiased although monotonicity still fails. Do the bounds change at all, and what does that say about what the bounds can and cannot know?
  2. A conversion outcome. Divide every visit probability in VISIT by ten, so the outcome is a purchase at around 1 to 3%. Recompute the Proposition 2 and 3 thresholds and the defier share at which the complier effect loses its sign. Which conclusions of part E survive when the lift is a fraction of a point?
  3. Make the guard bite. Shrink the test to 1,000 users per arm and raise the defier share to 8% with a defier visit probability of 60% when exposed, so that some posterior draws violate Kitagawa's inequalities. What share of draws has $v > 0$, how do the bands look near $\pi_d = 0$, and what would a plot without the mask have shown?
print(f"total run time: {time.time() - T_START:.0f} s")
total run time: 57 s