# Markov Chain and Removal Effect [closed]

Based on this article I'm trying to use within R the Channel Attribution package to leverage on the Markov Chain in order to attribute conversion between several marketing channel.

On one point the author suggest:

" When using one-order Markov chains, a subsequence of the same channels in a path (duplicates) can be reduced to one channel (for example C2 in the path C1 → C2 → C2 → C2 → C3 can be reduced to C1 → C2 → C3). Because, mathematically, it doesn’t matter how many times each C2 goes through the loop with itself in the transition matrix, it will be in the C3 state finally. Therefore, we will obtain different transition matrices but the same Removal Effect for channels with or without subsequent duplicates ".

Now, I utilized another set to validate the package result. Specifically: If I take the example in the picture, where I simulated an hypothetical set of paths, with both number of conversions and not conversions represented in the coloured cells (in the green and red cells respectively)

Doing the math by hand I get the following transition probabilities for the 1st order Markov chain: However, when I do the calculation by hand to get the removal_effect and total_conversion, I do not get the same results of the package for each channel.

According to the theory and the example in the article, the total probability of conversion of the model should be = (1*0.1008*0.5455*0.1261) + (0.1765*0.2605*0.0323) +(0.2605*0.3226*0.1818) + 0.1261=0.1498

Then the removal effects:

instagram=1-((0.0069+0.1261)/0.1498)=0.1121

Then to compute the share of conversion, let's say of google

share google=1/(1+0.1482+0.1121)=0.7935 * 20 conversions =15.87

while the attribution channel package give me different results as per below I think I'm missing something in my calculation respect to what the code does.

Does anyone with some experience with Markov chain help with identifying what is not right in the manual computation?

Many thanks D

## closed as off-topic by mkt - Reinstate Monica, Peter Flom - Reinstate Monica♦Sep 24 at 10:52

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question appears to be off-topic because EITHER it is not about statistics, machine learning, data analysis, data mining, or data visualization, OR it focuses on programming, debugging, or performing routine operations within a statistical computing platform. If the latter, you could try the support links we maintain." – mkt - Reinstate Monica, Peter Flom - Reinstate Monica
If this question can be reworded to fit the rules in the help center, please edit the question.

The transitional probabilities that you have calculated are not matching with the R output, because you need to remove the line item google to google (row 3 in your table). I have eliminated the line item and my output is in line with the R output. Please see image below. However, I am not able to get the same removal effects, as the R output. Still trying. Please let me know if you have any success.

• Hi Anitha. Yes, my transition probabilites are different but that's not an issue, as keeping the "google-google" loop should not affect the final removal effect computation as " mathematically, it doesn’t matter how many times each google goes through the loop with itself in the transition matrix. Therefore, we will obtain different transition matrices but the same Removal Effect for channels with or without subsequent duplicates." analyzecore.com/2017/05/31/… – davide cortellino Jan 17 at 14:56

According to the official documentation of the package ChannelAttribution:

The approach basically follows the one presented in Eva Anderl, Ingo Becker, Florian v. Wangenheim, Jan H. Schumann (2014). Differently for them, we solved the estimation process using stochastic simulations. In this way it is also possible to take into account conversion values and their variability in the computation of the channel importance.

So, although there is no clear documentation about the computational steps, I think the flow is:

• 1) calculation of conversion rate for each channel;
• 2) for all the channels $$C_1, C_2, \dots, C_n$$:
• 2.1) remove the channel $$C_i$$ from the graph ;
• 2.2) recalibrate transitional probabilities (not sure if this is actually done);
• 2.3) according to the new transitional probabilities, simulate $$N_{sim}$$ paths (in the package, there is the nsim parameter in the markov_model function) and from these new paths, calculate the new conversion rate;
• 3) calculate the removal effects of each channel.