What does Attribution, Bandits and Customer Lifetime Value conclude, in numbers, about “Shapley Values and Markov Removal Effects: Exact Allocations of an Inexact Question”?
Answer: The Shapley value is the only allocation satisfying efficiency, symmetry, null player and additivity, and under synergy it splits the interaction effect equally among participants; its meaning depends entirely on the characteristic function \(v(S)\). When \(v(S)\) is estimated from observed paths, it inherits the selection bias of targeted delivery: in the fictional world of Chapter 1, its share error is 13.1 points with targeting and 2.0 points without. The Markov removal effect has a similar error in that world (13.7), but in a world in which only two channels work together it gives more than half the credit to a wide-reach channel that does nothing. "Exact multi-touch attribution" in the author's framework should be qualified as "exact axiomatic allocation"; the end point of attribution is the incrementality experiment, not a more refined allocation formula.
Scope of the numbers: Which advertising channel should a sale be credited to? When may an A/B test stop? What is a customer still worth? This book presents mathematical models for teaching and research and is not marketing, investment or legal advice. Marked boxes separate published evidence, runnable Python calculations (16 programs), classical sources and the author's models and hypotheses; all data in the book are fictional or simulated.
Data table
The numbers below are printed verbatim by the chapter's Python program and can be reproduced by running it. standard-library Python onlyprinted values that match the answer: 13.1, 2.0
| A. three channels; v = conversions per 1,000 users exposed | |
| additive a 10.00 b | 4.00 c 2.00 (sum 16 = v(abc)) |
| a and b only work together a | 6.00 b 6.00 c 2.00 (sum 14 = v(abc)) |
| B. observational Shapley on the fictional journeys of p01 (share of credit) | |
| targeted (selection on intent) untargeted | |
| channel Shapley truth Shapley truth | |
| Search | 27.0% 11.0% 6.2% 6.3% |
| Social | 32.3% 51.2% 56.7% 57.0% |
| Display | 14.7% 22.0% 29.4% 25.3% |
| 26.0% 15.8% 7.7% 11.4% | |
| mean abs. error | 13.1% 2.0% |
| conversions credited to ads 5,994 (true 3,636); untargeted 3,160 (true 3,160) |
Key formula
Show the full program
# Shapley values for channel attribution. Part A: a three-channel game, showing that
# the answer depends on how v(S) is defined. Part B: the observational Shapley rule on
# the fictional journeys of p01, where v(S) = conversion rate of users whose exposure
# set is exactly S (estimated from the paths), credited per user relative to v(empty).
# With targeting (selection on intent) it inherits the bias; without, it is exact.
import itertools, math, random
# --- helpers repeated from earlier programs, so that this one runs on its own ---
CH = "SFDE"
P_HIGH = 0.20
EXPO = {"S": (0.60, 0.10), "F": (0.35, 0.30), "D": (0.50, 0.50), "E": (0.60, 0.15)}
BASE = (0.08, 0.005) # (high intent, low intent)
LIFT = {"S": 0.010, "F": 0.030, "D": 0.008, "E": 0.012}
WHEN = {"S": (0.6, 1.0), "F": (0.0, 0.7), "D": (0.0, 0.5), "E": (0.2, 1.0)}
def user(rng, sel=1.0):
"""One journey: (intent, channels in time order, converted)."""
hi = rng.random() < P_HIGH
touches = []
for c in CH:
p_hi, p_lo = EXPO[c]
p = p_lo + sel * (p_hi - p_lo) if hi else p_lo # sel = 0: no selection
if rng.random() < p:
touches.append((rng.uniform(*WHEN[c]), c))
path = [c for _, c in sorted(touches)]
p_conv = BASE[0 if hi else 1] + sum(LIFT[c] for c in path)
return hi, path, rng.random() < p_conv
def truth(n, sel=1.0):
"""Expected incremental conversions per channel (exact, from the model)."""
out = {}
for c in CH:
p_hi, p_lo = EXPO[c]
expo = P_HIGH * (p_lo + sel * (p_hi - p_lo)) + (1 - P_HIGH) * p_lo
out[c] = n * expo * LIFT[c]
return out
def shares(d):
tot = sum(d.values())
return {c: d[c] / tot for c in CH}
# --- end of repeated helpers ---
def shapley(players, v):
n, phi = len(players), {}
for i in players:
rest, s = [p for p in players if p != i], 0.0
for k in range(n):
w = math.factorial(k) * math.factorial(n - k - 1) / math.factorial(n)
for T in itertools.combinations(rest, k):
s += w * (v(frozenset(T) | {i}) - v(frozenset(T)))
phi[i] = s
return phi
def observational(data):
"""Total credit per channel: each user with exposure set S gets the Shapley
split of v(S) - v(empty) over the members of S, v = empirical rate by exact set."""
cnt, conv = {}, {}
for _, path, c in data:
S = frozenset(path); cnt[S] = cnt.get(S, 0) + 1; conv[S] = conv.get(S, 0) + c
rate = {S: conv[S] / cnt[S] for S in cnt}
v = lambda T: rate.get(T, 0.0) - rate[frozenset()]
credit = {c: 0.0 for c in CH}
for S, m in cnt.items():
if S:
for c, x in shapley(sorted(S), v).items():
credit[c] += m * x
return credit
if __name__ == "__main__":
print("A. three channels; v = conversions per 1,000 users exposed")
games = {"additive": {"": 0, "a": 10, "b": 4, "c": 2, "ab": 14, "ac": 12, "bc": 6,
"abc": 16},
"a and b only work together": {"": 0, "a": 0, "b": 0, "c": 2, "ab": 12,
"ac": 2, "bc": 2, "abc": 14}}
for name, g in games.items():
v = lambda T, g=g: g["".join(sorted(T))]
phi = shapley(["a", "b", "c"], v)
print(f" {name:28s} " + " ".join(f"{k} {x:5.2f}" for k, x in phi.items())
+ f" (sum {sum(phi.values()):.0f} = v(abc))")
print("B. observational Shapley on the fictional journeys of p01 (share of credit)")
names = {"S": "Search", "F": "Social", "D": "Display", "E": "Email"}
res = []
for sel in (1.0, 0.0):
rng = random.Random(2026)
data = [user(rng, sel) for _ in range(200_000)]
cr, tr = observational(data), truth(200_000, sel)
res.append((shares(cr), shares(tr), sum(cr.values()), sum(tr.values())))
print(" targeted (selection on intent) untargeted")
print(" channel Shapley truth Shapley truth")
for c in CH:
print(f" {names[c]:8s} {res[0][0][c]:6.1%} {res[0][1][c]:6.1%}"
f" {res[1][0][c]:6.1%} {res[1][1][c]:6.1%}")
mae = [sum(abs(r[0][c] - r[1][c]) for c in CH) / len(CH) for r in res]
print(f" mean abs. error {mae[0]:5.1%} {mae[1]:5.1%}")
print(f" conversions credited to ads {res[0][2]:,.0f} (true {res[0][3]:,.0f});"
f" untargeted {res[1][2]:,.0f} (true {res[1][3]:,.0f})")Single source and citation
Fan, Y. (2026). Algorithmic Marketing, Multi-Touch Shapley Attribution and Stochastic Control of Acquisition Funnels (Version 1.0.0), Chapter 2: Shapley Values and Markov Removal Effects: Exact Allocations of an Inexact Question. 5D Library. https://doi.org/10.5281/zenodo.23836264
DOI: 10.5281/zenodo.23836264 · Read the monograph · 5DL-B-048 · v1.0.0 · CC-BY-NC-ND-4.0
BibTeX
@book{fan2026048,
author = {Fan, Yafu},
title = {Algorithmic Marketing, Multi-Touch Shapley Attribution and Stochastic Control of Acquisition Funnels},
year = {2026},
publisher = {5D Library},
edition = {1.0.0},
doi = {10.5281/zenodo.23836264},
url = {https://doi.org/10.5281/zenodo.23836264}
}Other chapter answers in this book
- Chapter 1 · Attribution Is Not Incrementality: Last Click, Potential Outcomes and Randomised Holdouts
- Chapter 3 · The Price of Peeking: Optional Stopping, Group-Sequential Designs and Always-Valid Inference
- Chapter 4 · Learning While Earning: Thompson Sampling and the Bias of Adaptive Experiments
- Chapter 5 · What Is a Customer Still Worth? BG/NBD, Gamma-Gamma and the Illusion of Rising Retention
- Chapter 6 · Diffusion and Spend: the Bass Model, the Dorfman–Steiner Condition and Whole-Life Budgets
- Chapter 7 · Reading the Classics: *Shi* and *Jie* in the *Sunzi*
- Chapter 8 · Practice and a Pre-Registered Test