MKTATTRIBUTION Procedure
Getting Started: MKTATTRIBUTION Procedure
This section provides a brief example of using the Markov attribution model that the MKTATTRIBUTION procedure supports.
Consider a market attribution model that has the following transition probability matrix (TPM) for five states :
It also has the following initial state probability vector (ISPV):
The following statements simulate the channel visit history, or the customer journey, for 100 customers from the previous model in order to provide test data for PROC MKTATTRIBUTION. The test data table has three columns: customerId is the ID of each customer, t is the time period that the customer was in, and c is the channel that the customer visited at time t. Column c takes value i for channel i, 1, 2, and 3, and takes a value of 0 when customer conversion occurs. For a customer, if the last column
c value is not 0, this means that the customer is not converted, which also means that the customer is in the null state. Note that, the channel variable takes the natural numbers sequentially from 1 and can’t skip any numbers.
%let seed=1234;
%let T=10; *the maxsimustep for each customer;
%let nCustomers=100; *the number of customers;
data simu(keep = customerId t c);
call streaminit(&seed);
array p0[5] _temporary_ (0.3, 0.3, 0.4, 0, 0.0);
array p1[5] _temporary_ (0, 0.2, 0.4, 0.3, 0.1);
array p2[5] _temporary_ (0.1, 0, 0.4, 0.5, 0.0);
array p3[5] _temporary_ (0.3, 0.2, 0, 0.3, 0.2);
do customerId = 1 to &nCustomers;
c_last=0;
t=0;
c=1;
do while(t < &T. and 0<c<=3);
c_last=c;
t+1;
if t=1 then
c = rand("Table", of p0[*]);
else do;
if c_last=1 then
c = rand("Table", of p1[*]);
else if c_last=2 then
c = rand("Table", of p2[*]);
else if c_last=3 then
c = rand("Table", of p3[*]);
end;
if c=4 then c=0;
if c ne 5 then
output;
end; *for each customer;
end; *for all simulations;
run;
proc print data=simu (obs=10) noobs; run;
data mylib.marketData; set simu; run;
The first 10 observations of the simulated data are shown in Figure 1.
Figure 1: Simulated Data
| customerId | t | c |
|---|---|---|
| 1 | 1 | 3 |
| 1 | 2 | 0 |
| 2 | 1 | 1 |
| 2 | 2 | 3 |
| 3 | 1 | 1 |
| 3 | 2 | 3 |
| 3 | 3 | 0 |
| 4 | 1 | 1 |
| 4 | 2 | 3 |
| 4 | 3 | 1 |
The following statements estimate the Markov attribution model that has three channels:
proc mktattribution data=mylib.marketData;
id section=customerId time=t;
model c / nchannel=3;
run;
The model information and number of observations are shown in Figure 2.
Figure 2: Model Information and Number of Observations
| Model Information | |
|---|---|
| Model Type | Markov Attribution |
| Number of Channels | 3 |
| Number of Observations | 288 |
|---|---|
| Number of Missing Observations | 0 |
The estimates of the initial state probability vector are shown in Figure 3.
Figure 3: Estimates of Initial State Probability Vector
| Initial State Probability Vector | |
|---|---|
| State | Estimate |
| Channel 1 | 0.32000 |
| Channel 2 | 0.30000 |
| Channel 3 | 0.38000 |
| Conversion | 0.00000 |
| Null | 0.00000 |
The estimated transition probability matrix is shown in Figure 4.
Figure 4: Estimated Transition Probability Matrix
| Estimated Transition Probability Matrix | |||||
|---|---|---|---|---|---|
| State | Channel 1 | Channel 2 | Channel 3 | Conversion | Null |
| Channel 1 | 0.00000 | 0.22388 | 0.47761 | 0.22388 | 0.07463 |
| Channel 2 | 0.10345 | 0.00000 | 0.39655 | 0.50000 | 0.00000 |
| Channel 3 | 0.31183 | 0.13978 | 0.00000 | 0.27957 | 0.26882 |
| Conversion | 0.00000 | 0.00000 | 0.00000 | 1.00000 | 0.00000 |
| Null | 0.00000 | 0.00000 | 0.00000 | 0.00000 | 1.00000 |
The conversion rates are shown in Figure 5.
Figure 5: Conversion Rates
| Conversion Rates | |
|---|---|
| Method | Rate |
| Data Based | 0.70000 |
| Markov Chain | 0.70000 |
The value in the Data Based row is calculated from the input data. The value in the Markov Chain row is calculated by the estimated TPM. The removal effect of a channel is the decrease in the probability of overall conversion if the channel were removed.
The removal effects are shown in Figure 6.
Figure 6: Removal Effects
| Removal Effects | |
|---|---|
| Channel | Effect |
| 1 | 0.36540 |
| 2 | 0.40962 |
| 3 | 0.42932 |
The contributions are the normalized removal effects to indicate each channel’s contribution to the conversion. The contributions of each channel through the Markov attribution model and the other three heuristic attribution models are shown in Figure 7.
Figure 7: Channel Contributions
| Channel Contributions | ||||||
|---|---|---|---|---|---|---|
| Channel | Markov Chain | First Touch | Last Touch | Linear | Position Based | Time Decay |
| 1 | 0.30340 | 0.30000 | 0.21429 | 0.27088 | 0.26352 | 0.26259 |
| 2 | 0.34012 | 0.35714 | 0.41429 | 0.36942 | 0.37595 | 0.37726 |
| 3 | 0.35648 | 0.34286 | 0.37143 | 0.35969 | 0.36052 | 0.36015 |