The Long Run
← Back to Data Driven Attribution - Markov Chain

Data Driven Attribution - Markov Chain

Markov Chain Attribution Jargon Checklist

Plain-English definitions of the terms used across the series. The examples come from the series itself: the weather, a game of Snakes and Ladders, traffic in the fictional city of Sampur and customer journeys at the fictional brand Kesari Threads. The holdout test terms come from the Markov Attribution and Holdout Tests series and its fictional grocery delivery service, VeggieMart.

Markov chain basics

TermPlain meaningExample
Markov chainExplained in Part 1A model of something that moves from one situation to another, one step at a time, where the chance of each next step depends only on where it is right now.The daily weather moving between Sunny, Cloudy and Rainy.
StateExplained in Part 1One of the distinct situations the process can be in. In attribution, each marketing channel is a state.Sunny in the weather example, a square on the Snakes and Ladders board, or Market Square in Sampur.
TransitionExplained in Part 1A move from one state to the next at each step. Staying in the same state also counts as a transition."Sunny today, Rainy tomorrow", or a car driving from City entry to Ring Road.
Transition probabilityExplained in Part 1The chance of one particular transition. The probabilities leaving any one state always add up to 1, because something has to happen next.After a sunny day: 0.6 Sunny, 0.3 Cloudy and 0.1 Rainy, which add up to 1.
Markov property (memorylessness)Explained in Part 1The rule that the next step depends only on the current state, not on how the process got there.A car at Ring Road behaves the same whether it came straight from City entry or by way of Market Square.
Absorbing stateExplained in Part 1A state that cannot be left: once reached, the journey ends there. In attribution, the absorbing states are purchase and abandonment.Square 25 on the board, or the Airport and Left city in Sampur.
Transient stateExplained in Part 2A state the process passes through and eventually leaves for good.City entry, Market Square, Ring Road and the Flyover.
Starting pointExplained in Part 2The state every journey begins in. Together with the TPM, it describes the chain completely.Every car in Sampur begins at City entry.
Path probabilityExplained in Part 1The chance of one specific sequence of moves, found by multiplying the transition probabilities along it. When several paths lead to the same place, their chances are added.Sunny, then Cloudy, then Rainy: 0.3 × 0.4 = 0.12. A sunny Monday reaches a rainy Wednesday by any path with 0.06 + 0.12 + 0.05 = 0.23.
SimulationExplained in Part 1Using random numbers to play out many journeys that follow the transition probabilities, then counting the outcomes. The counts vary slightly from one run to the next.In one run of 10,000 simulated cars, 4,878 reached the airport; the expected number is 4,947.

Building the TPM from data

TermPlain meaningExample
Transition Probability Matrix (TPM)Explained in Part 2A table that holds every transition probability of a Markov chain. Each row is the current state, each column is the next state, and each row adds up to 1.The Ring Road row: 0.1 to Market Square, 0.3 to the Flyover, 0.2 to the Airport and 0.4 out of the city.
Trip log (sample data)Explained in Part 2A record of journeys, one row per trip, listing the states in the order they were visited. The trip log in this series is sample data created for the articles.Trip 2: City entry > Ring Road > Flyover > Airport, one of 2,000 sample trips.
Move (transition count)Explained in Part 2One step from a state to the next inside a journey. A trip that visits k locations has k − 1 moves. Counting each kind of move is the first step in building a TPM.The trip log has 5,329 moves, including 1,226 from City entry to Market Square.
Row totalExplained in Part 2The total number of moves out of one state. Dividing each count in a row by its row total turns counts into probabilities.Cars left Market Square 1,330 times; 659 of them took the flyover, so 659 ÷ 1,330 = 0.495.
Random seedExplained in Part 2A fixed starting number for a random-number generator, so the same "random" results come out every time the code runs.Seed 7 recreates exactly the same 2,000 sample trips.
n-step probability (Pⁿ)Explained in Part 2Multiplying the TPM by itself n times gives the chance of being in each state after n moves.After two moves, 8% of cars are at the airport, 34% have left the city and 58% are still on the road.

Chain order

TermPlain meaningExample
First-order chainExplained in Part 3A chain where the next move depends only on the current state. This is the Markov property, and the default in Markov attribution.Of all the cars at Ring Road, 10.1% go to Market Square next, wherever they came from.
Second-order chainExplained in Part 3A chain where the next move depends on the current state and the one before it. It can capture more behaviour, but it needs far more data because each state is split by where the journey came from.Cars reaching Ring Road from City entry take the flyover 32.0% of the time; those from Market Square, 25.7%.
Chi-square test of independenceExplained in Part 3A statistical test that checks whether two categories are related, here whether the previous location changes where a car goes next.At Ring Road the test gives p ≈ 0.11, so a first-order chain is good enough for Sampur.
p-valueExplained in Part 3The chance of seeing a difference at least as large as the one observed if there were really no effect. A small p-value, often below 0.05, suggests the difference is real.p ≈ 0.11 means gaps this large would turn up about 11% of the time by chance alone.

Attribution and the removal effect

TermPlain meaningExample
Data-driven attributionExplained in Part 1Attribution that learns how much credit each channel deserves from real customer journeys, instead of a rule chosen in advance. It is a type of multi-touch attribution (MTA).The Markov chain model and Shapley values.
Rule-based attribution modelExplained in Part 1A model that splits credit across touchpoints by a fixed rule, without looking at how customers actually move between channels.First click, last click, last non-direct click, linear, time decay and position based. See the Marketing Attribution Jargon Checklist.
Shapley valueExplained in Part 1A method from game theory that gives each player, here each channel, its average extra contribution across all possible combinations of players. It is another form of data-driven attribution and is not covered in detail in this series.Mentioned in Part 1 as the main alternative to the Markov chain model.
Removal effectExplained in Part 1The share of successful journeys lost when one state is removed: 1 − (success rate with the state removed ÷ success rate with everything in place).Closing the flyover drops airport arrivals from 49.47% to 10.61%, a removal effect of 78.5%.
Share of creditExplained in Part 3Removal effects scaled so they add up to 100%. Raw removal effects usually add up to more than 100%, because most journeys depend on several states at once.The three removal effects add up to 194.4%; the Flyover gets 78.5 ÷ 194.4 = 40.4% of the credit.

Matrix maths (Part 4)

TermPlain meaningExample
Absorbing Markov chainExplained in Part 4A Markov chain with at least one absorbing state, where every transient state can eventually reach an absorbing state.Sampur: every trip ends at the Airport or by leaving the city.
Canonical formExplained in Part 4The TPM reordered so transient states come first and absorbing states last. It splits the TPM into four blocks: Q, R, O and I.P = [ Q R ; O I ], with the four junctions first and the Airport and Left city last.
Q (transient block)Explained in Part 4The part of the TPM that holds the probabilities of moving from one transient state to another.Market Square → Ring Road, 0.2.
R (absorption block)Explained in Part 4The part of the TPM that holds the probabilities of moving from a transient state straight to an absorbing state, ending the journey in one move.Flyover → Airport, 0.8.
O (null block)Explained in Part 4The part of the TPM for moves from absorbing states back to transient states. Every entry is 0, because a finished journey never restarts.A car at the Airport never returns to a junction.
Identity matrix (I)Explained in Part 4A square matrix with 1s on the diagonal and 0s everywhere else: the matrix version of the number 1.In the canonical form, I says the Airport stays the Airport and Left city stays Left city.
Matrix inverse (⁻¹)Explained in Part 4The matrix version of "1 divided by a number". Multiplying a matrix by its inverse gives the identity matrix. In practice it is computed with software.np.linalg.inv(I − Q) in Python gives the fundamental matrix.
Geometric seriesExplained in Part 4The sum 1 + x + x² + x³ + …, which equals 1 ÷ (1 − x) when x is between 0 and 1. The fundamental matrix is the matrix version of this sum.A car at Market Square loops back with probability 0.02, so it visits Market Square 1 ÷ (1 − 0.02) = 1.02 times on average.
Fundamental matrix (F)Explained in Part 4F = (I − Q)⁻¹. Each entry is the expected number of visits to a transient state before the journey ends, and each row total is the expected number of moves.A car entering Sampur uses the Flyover 0.486 times on average and makes 2.67 moves.
Probability of absorption (FR)Explained in Part 4FR = F × R. The probability that a journey starting in each transient state finally ends in each absorbing state.From City entry, 49.47% of cars reach the Airport; from the Flyover, 80%.

Customer journeys (Parts 5 and 6)

TermPlain meaningExample
TouchpointExplained in Part 5One visit to the site, labelled by the channel that brought the customer in. In a Markov attribution model, each channel is a transient state that customers pass through.A customer clicks an Instagram ad and lands on the Kesari Threads site: one Instagram Ads touchpoint.
Conversion pathExplained in Part 5A customer journey that ends with a purchase, in the Conversion absorbing state. These are the only journeys rule-based models look at.Start → Instagram Ads → Google Shopping → Conversion.
Null pathExplained in Part 5A customer journey that ends without a purchase, in the Null absorbing state. It is the marketing version of a car leaving Sampur, and most journeys end this way.46,794 of Kesari Threads' 50,000 simulated journeys are null paths.
Conversion probability (from a touchpoint)Explained in Part 5The chance that a customer at a given touchpoint goes on to buy before the journey ends. It is the probability of absorption in Conversion, and it can only be calculated when null paths are included.12.2% from Brand Search and 3.0% from Influencer, against 6.4% for a journey that has just started.
Holdout testExplained in Part 6An experiment that pauses a channel for some customers or regions and compares their sales with the rest. It measures what would have happened without the channel, which a Markov model cannot.Pausing Brand Search ads in a few cities for six weeks and comparing orders with similar cities where the ads kept running.

Holdout tests (Markov Attribution and Holdout Tests)

TermPlain meaningExample
VisitExplained in Markov Attribution and Holdout TestOne arrival on the site or app from a channel. One customer can make several visits before ordering.VeggieMart records 100,674 visits in one month, such as a click on a Meta ad. See the Marketing Attribution Jargon Checklist.
Customer journeyExplained in Markov Attribution and Holdout TestAll of one customer's visits, in order, until they order or drop out.VeggieMart has 60,000 journeys in one month, with 100,674 ÷ 60,000 ≈ 1.68 visits each on average.
Conversion rate (CVR)Explained in Markov Attribution and Holdout TestOrders ÷ customer journeys. It is counted per journey, not per visit, because a customer who visits three times and orders once has placed one order.VeggieMart: 4,249 ÷ 60,000 = 7.1%.
Multi-touch attribution (MTA)Explained in Markov Attribution and Holdout TestAny method that splits the credit for an order across several channels on the customer journey. Data-driven attribution, such as a Markov model, is one type.A Markov model sharing one VeggieMart order between Meta Ads, Brand Search and Direct.
Last non-direct click (LNDC)Explained in Markov Attribution and Holdout TestA rule that gives all the credit to the last channel before the order, skipping Direct visits. If every visit was Direct, Direct gets the credit.LNDC credits VeggieMart's Coupon Sites with 1,454 orders; Markov credits them with 854. See the Marketing Attribution Jargon Checklist.
Markov creditExplained in Markov Attribution and Holdout TestThe orders a Markov model gives a channel: total orders split by each channel's share of credit, which comes from its removal effect.Markov credits VeggieMart's Brand Search with 739 of the 4,249 orders in a month.
City holdout (geo holdout)Explained in Markov Attribution and Holdout TestA holdout test where the groups are cities: the channel is switched off in some cities and kept on in similar ones.Pausing VeggieMart's brand search ads in 10 of its 30 cities for six weeks.
Extra orders (incremental orders)Explained in Markov Attribution and Holdout TestOrders that happened only because of the channel, and would be lost without it.The Brand Search test finds 222 extra orders a month.
Incrementality ratioExplained in Markov Attribution and Holdout TestExtra orders measured in a holdout test ÷ orders Markov credits to the channel. 1 means Markov is right, below 1 too much credit, above 1 too little.Brand Search: 222 ÷ 739 = 0.30. Meta Ads: 878 ÷ 675 = 1.30.
Likely range (90%)Explained in Markov Attribution and Holdout TestThe range the true ratio most likely falls in, given how much orders vary from week to week. A wide range means the test needs more time or more cities.Brand Search: 0.30, with a likely range of 0.15 to 0.45.
Baseline demandExplained in Markov Attribution and Holdout TestOrders that would happen without paying for any of the tested channels. It is the gap left when Markov credits are adjusted by their incrementality ratios.Customers who would order from VeggieMart anyway, through the free search result or the app.
Marketing mix modelling (MMM)Explained in Markov Attribution and Holdout TestA statistical model that estimates each channel's contribution from aggregated spend and sales over time, usually weekly over two to three years. It covers offline channels such as TV.Weekly VeggieMart orders modelled on weekly spend by channel, with festive seasons. See the Marketing Attribution Jargon Checklist.
MMM calibrationExplained in Markov Attribution and Holdout TestUsing a holdout test result to correct an MMM, so the model's estimate for the tested channel matches what the test measured.Telling the model that Brand Search caused about 222 extra orders a month.

Back to the series