5D Library › Algorithmic Marketing, Multi-Touch Shapley Attribution and Stochastic Control of Acquisition Funnels · 中文

Preface: Attribution, Experiments and the Value of a Customer

Note

Purpose and risk notice: please read this first. This book presents mathematical models for teaching and research. It is not marketing, investment, financial or legal advice. Every user, path, conversion, advertising budget, customer and transaction in the book is fictional or simulated, not data from any real advertiser, platform, brand or customer; no data from the author’s businesses or their clients are used. Published studies are cited only for what they found under their own conditions and cannot be carried over directly to a reader’s business. The book recommends no advertising platform, attribution software or media-buying service, and offers no method that “guarantees”, “always wins”, “lifts conversion by X %” or is “proven optimal”. Its models hold only under the assumptions stated; real user behaviour, platform algorithms and competitors can violate them at any time. Advertising costs money, and any budget decision based on the book’s models can lose it.

A user sees a short video on social media, opens a promotional email a few days later, and finally types the brand’s name into a search engine, clicks an ad and buys. Which of these should get the credit for the sale? A marketing team usually has a report that answers the question, and the numbers in that report decide next quarter’s budget. The same team is running a dozen A/B tests at once and checks each morning whether a variant has become “significant”; the finance department multiplies “63 % first-year retention” forward to estimate what a customer is worth over a lifetime. This book asks which of these practices are supported by mathematics and evidence, which need qualifying, and which are wrong.

Answering takes four layers of tools. The first is causality: does a channel’s “contribution” mean that it appeared on the path to a conversion, or that without it the conversion would not have happened? The second is experimentation: how to look at results while the data accumulate without fooling oneself, and what learn-as-you-go algorithms such as bandits give up. The third is stochastic models of a customer base: when we cannot see a customer “leave”, how to infer from purchase records who is still active and how much they will buy, and why the retention rate of a group “rises” over time. The fourth is dynamic control: how the speed at which a new product diffuses relates to how an advertising budget should be spread, and whether a static optimality rule can be stretched across a whole life cycle.

What the book covers

Chapter 1 distinguishes rule-based attribution (last click, first click, linear) from incrementality and reviews the evidence from randomised holdouts and ghost ads; Chapter 2 treats Shapley-value attribution and the removal effect of an absorbing Markov chain, their dependence on the characteristic function, their disagreement on synergistic channels, and why on observational data they are still not causal increments; Chapter 3 computes exactly how optional stopping inflates the type I error, and covers group-sequential designs and always-valid inference; Chapter 4 treats Thompson-sampling bandits, how their goal differs from that of an A/B test, and the bias of estimates under adaptive allocation; Chapter 5 covers the BG/NBD and Gamma-Gamma models, the computation of the Gauss hypergeometric function, and the difference between “rising retention” caused by heterogeneity and Simpson’s paradox; Chapter 6 covers the Bass diffusion model, the Dorfman–Steiner condition and the author’s model of whole-life acquisition spend; Chapter 7 reads these beside the “Initial Estimates” and “Strategic Dispositions” chapters of the Sunzi; and Chapter 8 offers a four-step checklist and a pre-registered simulation benchmark.

The book neighbours several others in 5D Library; where they overlap, it only recaps briefly, cites the earlier book and does not repeat its programs. Book 6, The Economics of Attention, wrote the conversion funnel as an absorbing Markov chain and computed the elasticity of each stage (Chapter 2 borrows only the absorbing-chain computation, and its subject is attribution, not funnel elasticities). Book 25, Social Network Topology, Structural Holes and Mathematical Models of Complex Contagion, treated simple and complex contagion (the Bass model of Chapter 6 is its simplest, fully mixed version). Book 26, Probabilistic Judgement, Brier-Score Calibration and the Statistical Theory of the Wisdom of Crowds, treated probability judgement and calibration. Book 33, Scientific Methodology, Falsifiability and the Mathematical Statistics of the Replication Crisis, treated optional stopping, the researcher-degrees-of-freedom simulation of Simmons and co-authors, pre-registration and the statistical properties of decision rules (Chapter 3 gives only the exact optional-stopping curve, and Chapter 8 follows Book 33’s decision-rule format). Book 42, Bayesian Search, the Secretary Problem and Gittins Indices, treated the exploration–exploitation trade-off, Gittins indices, Thompson sampling and UCB (Chapter 4 only recaps, and concentrates on estimation bias in marketing experiments). Books 16 and 26 read the “Empty and Full”, “Planning Offensives”, “Nine Variations” and “Initial Estimates” chapters of the Sunzi; Chapter 7 reads only the sentence on shi in “Initial Estimates” and the chapter “Strategic Dispositions”.

Claims corrected after checking

Several points in the author’s framework needed correcting, supplementing or qualifying after checking. Each chapter says so where it arises, and the accompanying editorial notes list them together.

  1. “Shapley values and Markov removal effects are exact multi-touch attribution.” Last click is indeed biased, but on observational data Shapley values and removal effects are not causal increments either: they allocate a correlation, “appearing on the path to a conversion”. When ads are targeted at people who were more likely to buy anyway, observational Shapley values inherit that selection bias. In a fictional world with known true increments, the program shows that with targeting the observational Shapley shares are off by 13.1 percentage points and the Markov removal-effect shares by 13.7, the same order as last click’s 18.1; only when exposure is unrelated to purchase intent does the Shapley error fall to 2.0 points. The “exactness” of the Shapley value means only that, for a given characteristic function v(S)v(S), it satisfies exactly the four axioms of efficiency, symmetry, null player and additivity (Shapley 1953); how v(S)v(S) is estimated from observed paths determines what the result means (Dalessandro et al. 2012; Singal et al. 2022). The causal benchmark is a randomised incrementality experiment (Lewis and Rao 2015; Gordon et al. 2019; Johnson et al. 2017) (Chapters 1 and 2).
  2. “Peeking at A/B-test p-values sends false positives soaring to 25 %+.” Right in direction; the number needs qualifying. With a nominal two-sided α=0.05\alpha = 0.05, equally spaced looks and the critical value 1.96 at each look, the program computes by numerical integration: 8.3 % with 2 looks, 14.2 % with 5, 19.3 % with 10, 24.8 % with 20 and 37.4 % with 100, tending to 1 as the number of looks grows without bound (Armitage et al. 1969). So “25 % or more” holds only from about 20 looks; and looking is not itself the error, failing to fix a stopping rule in advance is. Group-sequential designs and always-valid inference allow interim looks while controlling the error rate (Pocock 1977; O’Brien and Fleming 1979; Johari et al. 2022) (Chapter 3).
  3. “Simpson’s paradox makes the aggregate retention curve appear to rise.” Period-by-period retention of a customer group rising over time is usually a sorting effect of heterogeneity: the customers most prone to churn leave first, those who remain are on average less prone, and no individual’s churn probability changes at all (Fader and Hardie 2007; Vaupel and Yashin 1985). It is related to Simpson’s paradox (both come from a change of composition) but is not the same thing: Simpson’s paradox is an association with the same direction in every subgroup that reverses when the subgroups are pooled (Simpson 1951). The program reproduces Fader and Hardie’s parameters exactly with the sBG model (α=0.704\alpha = 0.704, β=1.182\beta = 1.182), and separately builds a genuine Simpson’s paradox: retention falls by 5 points in both acquisition channels while pooled retention rises from 28.0 % to 45.0 % (Chapter 5).
  4. The sources and computation of BG/NBD and Gamma-Gamma. BG/NBD is from Fader, Hardie and Lee’s 2005 paper in Marketing Science (Fader et al. 2005a); the Gamma-Gamma spend model comes from the same three authors’ other 2005 paper, in the Journal of Marketing Research (Fader et al. 2005b), building on an idea of Colombo and Jiang (1999) (Colombo and Jiang 1999). The author’s framework cites them as one paper; they are separated. The 2F1(r,b;a+b−1;z)_2F_1(r, b; a+b-1; z) in the closed form for E[X(t)]E[X(t)] has z=t/(α+t)z = t/(\alpha+t) approaching 1 as tt grows, so the power series converges very slowly (21,479 terms at t=5,200t = 5{,}200 weeks); and Euler’s integral has an integrand that diverges at an endpoint when r<1r < 1, so the trapezoidal or Simpson’s rule cannot be applied directly. The program first moves zz to the negative half-line with Pfaff’s transformation and then changes variables; the two algorithms agree to better than one part in a million. Gamma-Gamma assumes that spend per transaction is independent of purchase frequency, and this assumption is written into the boundaries (Chapter 5).
  5. Thompson sampling “optimises conversion”. Multi-armed bandits are designed to reduce cumulative regret, not to estimate each variant’s effect accurately. The program shows that when two variants are identical, after Thompson allocation the mean sample conversion rate is 0.33 points too low and the nominal 95 % confidence interval covers zero only 82.5 % of the time; inverse-propensity weighting with the known allocation probabilities removes the bias (Nie et al. 2018; Hadad et al. 2021). Bandits and A/B tests answer different questions (Chapter 4).
  6. “Combining the Bass diffusion equation with the Dorfman–Steiner theorem to find the whole-life optimal acquisition spend.” The Bass equation dF/dt=(p+qF)(1−F)dF/dt = (p + qF)(1 – F) is as stated (Bass 1969). The Dorfman–Steiner condition, “the optimal advertising-to-sales ratio equals the advertising elasticity divided by the price elasticity”, checks out (Dorfman and Steiner 1954), but it is a static profit-maximisation condition with no diffusion dynamics in it and cannot by itself give a “whole-life” allocation; the dynamic problem needs advertising written into the state equation, as Nerlove and Arrow and Horsky and Simon did (Nerlove and Arrow 1962; Horsky and Simon 1983). The book’s whole-life model is the author’s model: with a concave advertising response, optimal spend is front-loaded, below 1 thousand from month 10 and zero by month 12, and earns 8.3 % more than spreading the same budget evenly; on one S-shaped response curve, alternate-month pulsing beats even spending at lower monthly budgets (up to 30 thousand) and even spending is better from 32.5 thousand, so the switch lies between 30 and 32.5 thousand, which is neither the inflection point of the curve (about 23.1 thousand) nor exactly the static break-even k/2k/\sqrt2 (about 28.3 thousand) (Chapter 6).
  7. The Sunzi quotation and its variant. “激水之疾,至于漂石者,势也;鸷鸟之疾,至于毁折者,节也” agrees with the common online transcriptions; the author’s framework has “故善战者,其势险,其节短”, whereas every common transcription checked reads “是故善战者”, and the missing 是 is restored (曹操 等 注,杨丙安 校理 1999). These quotations have been checked only against online transcriptions and await confirmation against Yang Bing’an’s printed edition. The author’s framework notes that 疾 “is also written 击”: the Daizhige transcriptions of the Sunzi (Siku edition) and of the Sunzi jizhu both read 疾, the Chinese Text Project transcription reads 擊, and, according to Giles’s annotated translation of 1910, the quotation in the Song encyclopaedia Taiping yulan reads 击 (Giles 1910). The book follows the Eleven Commentaries in reading 疾, and asks that the collation notes of Yang Bing’an’s edition be checked. Some online transcriptions read 扩弩 or 张弩, the former a faulty simplification of 彍; the book reads 彍弩. All ancient–modern comparisons are marked as analogies (Chapter 7).
  8. The Chapter 8 study. The book chooses a simulation benchmark rather than a holdout experiment with real advertisers, for reasons given in Chapter 8; the single primary outcome is “the difference between the mean absolute errors of last click and observational Shapley against the true incremental shares”. The study tests only how the methods perform in a simulated world whose truth is known; it tests the effect of no real advertising (Chapter 8).

How to read the boxes

As in the other books of 5D Library, statements of different kinds are marked separately.

Evidence

Evidence boxes report published research findings, with sources.

Calculation

Calculation boxes give short Python programs. Each runs as is in a standard Python 3 environment, uses only the standard library and fixed random seeds, and is followed by its actual output. Users, paths, conversions, spend and customers in the book are fictional or synthetic; parameters are illustrative values, not estimates for any real advertisement, platform or market.

Hypothesis · not established

Hypothesis boxes contain the author’s ideas, marked “not established”, with a statement of what result would show them to be wrong. The author’s own models and definitions are marked “the author’s model” in the text.

Source text

Source boxes quote classical texts, with a plain-language explanation.

Note

Note boxes give reminders and explain choices.

About this edition

This is version 1.0.0, the first complete edition: a preface and eight chapters, in Chinese and English. The book contains 16 Python programs and 5 vector figures. The text, boxes and code were drafted with an AI writing tool from the author’s title, framework and notes; the author is responsible for reviewing and revising them and for checking the sources. AI-drafted text can get bibliographic details wrong; corrections are welcome through the 5D Library website. The fictional user world of Chapter 1, the synergy world of Chapter 2, the whole-life spend model of Chapter 6, the goodwill-stock model of Chapter 7 and the pilot generator of Chapter 8 are the author’s models; their mathematical properties are not evidence about the effects of real advertising.

Disclosure

The author uses the works of 5D Library, including this book, as the methodological basis of his community courses, the 5D Ascension Cards (Dimensional Shift Card Decks) and the Yafu AI knowledge base, and therefore has a commercial interest in the subject of this book. The book promotes no course, card deck or service; the Chapter 8 trial is designed to be run and analysed by researchers independent of the author’s business and does not recruit from the author’s community, students or customers; all the code and the study protocol are published openly for anyone to check. The author founded and runs Asia Influencer X and Yafu Global, which work in influencer marketing, live-stream commerce and digital marketing (including ad buying, performance attribution and customer acquisition) and use the attribution and experimentation methods discussed in this book in their daily work, so he has a direct commercial interest in its subject; the book uses no data from these two companies or their clients as evidence and does not promote their services.

References

Armitage, P., C. K. McPherson, and B. C. Rowe. 1969. “Repeated Significance Tests on Accumulating Data.” Journal of the Royal Statistical Society, Series A 132 (2): 235–44.
Bass, Frank M. 1969. “A New Product Growth for Model Consumer Durables.” Management Science 15 (5): 215–27. https://doi.org/10.1287/mnsc.15.5.215.
Colombo, Richard, and Weina Jiang. 1999. “A Stochastic RFM Model.” Journal of Interactive Marketing 13 (3): 2–12.
Dalessandro, Brian, Claudia Perlich, Ori Stitelman, and Foster Provost. 2012. “Causally Motivated Attribution for Online Advertising.” Proceedings of the Sixth International Workshop on Data Mining for Online Advertising and Internet Economy (ADKDD ’12). https://doi.org/10.1145/2351356.2351363.
Dorfman, Robert, and Peter O. Steiner. 1954. “Optimal Advertising and Optimal Quality.” American Economic Review 44 (5): 826–36.
Fader, Peter S., and Bruce G. S. Hardie. 2007. “How to Project Customer Retention.” Journal of Interactive Marketing 21 (1): 76–90.
Fader, Peter S., Bruce G. S. Hardie, and Ka Lok Lee. 2005a. “‘Counting Your Customers’ the Easy Way: An Alternative to the Pareto/NBD Model.” Marketing Science 24 (2): 275–84. https://doi.org/10.1287/mksc.1040.0098.
Fader, Peter S., Bruce G. S. Hardie, and Ka Lok Lee. 2005b. “RFM and CLV: Using Iso-Value Curves for Customer Base Analysis.” Journal of Marketing Research 42 (4): 415–30.
Giles, Lionel. 1910. Sun Tzŭ on the Art of War: The Oldest Military Treatise in the World. Luzac; Co.
Gordon, Brett R., Florian Zettelmeyer, Neha Bhargava, and Dan Chapsky. 2019. “A Comparison of Approaches to Advertising Measurement: Evidence from Big Field Experiments at Facebook.” Marketing Science 38 (2): 193–225. https://doi.org/10.1287/mksc.2018.1135.
Hadad, Vitor, David A. Hirshberg, Ruohan Zhan, Stefan Wager, and Susan Athey. 2021. “Confidence Intervals for Policy Evaluation in Adaptive Experiments.” Proceedings of the National Academy of Sciences 118 (15).
Horsky, Dan, and Leonard S. Simon. 1983. “Advertising and the Diffusion of New Products.” Marketing Science 2 (1): 1–17. https://doi.org/10.1287/mksc.2.1.1.
Johari, Ramesh, Pete Koomen, Leonid Pekelis, and David Walsh. 2022. “Always Valid Inference: Continuous Monitoring of A/B Tests.” Operations Research 70 (3): 1806–21. https://doi.org/10.1287/opre.2021.2135.
Johnson, Garrett A., Randall A. Lewis, and Elmar I. Nubbemeyer. 2017. “Ghost Ads: Improving the Economics of Measuring Online Ad Effectiveness.” Journal of Marketing Research 54 (6): 867–84.
Lewis, Randall A., and Justin M. Rao. 2015. “The Unfavorable Economics of Measuring the Returns to Advertising.” Quarterly Journal of Economics 130 (4): 1941–73. https://doi.org/10.1093/qje/qjv023.
Nerlove, Marc, and Kenneth J. Arrow. 1962. “Optimal Advertising Policy under Dynamic Conditions.” Economica 29 (114): 129–42.
Nie, Xinkun, Xiaoying Tian, Jonathan Taylor, and James Zou. 2018. “Why Adaptively Collected Data Have Negative Bias and How to Correct for It.” Proceedings of the 21st International Conference on Artificial Intelligence and Statistics (AISTATS 2018), Proceedings of machine learning research 84, 1261–69.
O’Brien, Peter C., and Thomas R. Fleming. 1979. “A Multiple Testing Procedure for Clinical Trials.” Biometrics 35 (3): 549–56.
Pocock, Stuart J. 1977. “Group Sequential Methods in the Design and Analysis of Clinical Trials.” Biometrika 64 (2): 191–99.
Shapley, Lloyd S. 1953. “A Value for n-Person Games.” In Contributions to the Theory of Games, Volume II, edited by Harold W. Kuhn and Albert W. Tucker. Annals of Mathematics Studies 28. Princeton University Press.
Simpson, E. H. 1951. “The Interpretation of Interaction in Contingency Tables.” Journal of the Royal Statistical Society, Series B 13 (2): 238–41.
Singal, Raghav, Omar Besbes, Antoine Desir, Vineet Goyal, and Garud Iyengar. 2022. “Shapley Meets Uniform: An Axiomatic Framework for Attribution in Online Advertising.” Management Science 68 (10): 7457–79. https://doi.org/10.1287/mnsc.2021.4263.
Vaupel, James W., and Anatoli I. Yashin. 1985. “Heterogeneity’s Ruses: Some Surprising Effects of Selection on Population Dynamics.” American Statistician 39 (3): 176–85.
曹操 等 注,杨丙安 校理. 1999. 十一家注孙子校理. 《计篇》《势篇》. 新编诸子集成. 中华书局.

Fan, Y. (2026). Algorithmic Marketing, Multi-Touch Shapley Attribution and Stochastic Control of Acquisition Funnels: From Thompson Sampling Bandits and Absorbing Markov Chains to BG/NBD Customer Lifetime Value, Read Beside the Strategic Dispositions of the Sunzi [算法营销、多触点沙普利归因与获客漏斗的随机控制] (Version 1.0.0). 5D Library. https://doi.org/10.5281/zenodo.23836264 · Licensed under Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0).