bart bartScoreMargin

Standard Case: Analyzing Marketing Campaign Effectiveness

Scénario de test & Cas d'usage

Business Context

A retail company has launched a targeted marketing campaign and wants to measure the impact of offering a discount (15% vs. 0%) and the marketing channel used (Email vs. SMS) on the probability of a customer making a purchase. The goal is to isolate the effect of the discount, controlling for the channel and customer demographics.
About the Set : bart

Bayesian Additive Regression Trees models.

Discover all actions of bart
Data Preparation

Creates a customer dataset with demographic info, campaign exposure, and a purchase flag. Then, trains a BART model on this data to predict the purchase outcome.

Copied!
1DATA mycas.customer_campaign;
2 call streaminit(456);
3 DO i = 1 to 5000;
4 age = 20 + floor(rand('UNIFORM') * 45);
5 income = 40000 + floor(rand('UNIFORM') * 80000);
6 IF rand('UNIFORM') < 0.5 THEN channel = 'Email'; ELSE channel = 'SMS';
7 IF rand('UNIFORM') < 0.4 THEN discount_offered = 1; ELSE discount_offered = 0;
8 /* Interaction effect */
9 p = 1 / (1 + exp(-( -2 + 0.01*age + 0.00001*income + 1.5*discount_offered + (ifc(channel='SMS', 0.5, 0))) ));
10 purchased = rand('BERNOULLI', p);
11 OUTPUT;
12 END;
13RUN;
14 
15PROC CAS;
16 bart.bartProbit TABLE={name='customer_campaign'},
17 model={depVars={{name='purchased', levelType='BINARY'}},
18 effects={{vars={'age', 'income', 'channel', 'discount_offered'}}}},
19 store={name='campaign_model', replace=true};
20QUIT;

Étapes de réalisation

1
Calculate the predictive margins for customers who received a discount versus those who did not.
Copied!
1PROC CAS;
2 bart.bartScoreMargin
3 TABLE='customer_campaign',
4 model='campaign_model',
5 seed=123,
6 margins={{
7 name='margin_discount_15pct',
8 label='Margin with 15% Discount',
9 at={{var='discount_offered', value=1}}
10 },
11 {
12 name='margin_no_discount',
13 label='Margin with No Discount',
14 at={{var='discount_offered', value=0}}
15 }};
16QUIT;
2
Compute the difference between the two margins to quantify the direct impact of the discount offer and save the results.
Copied!
1PROC CAS;
2 bart.bartScoreMargin
3 TABLE='customer_campaign',
4 model='campaign_model',
5 seed=456,
6 margins={{
7 name='margin_discount_15pct',
8 at={{var='discount_offered', value=1}}
9 },
10 {
11 name='margin_no_discount',
12 at={{var='discount_offered', value=0}}
13 }},
14 differences={{
15 name='diff_discount_effect',
16 label='Effect of 15% Discount',
17 refMargin='margin_no_discount',
18 evtMargin='margin_discount_15pct'
19 }},
20 marginInfo=true,
21 casOut={name='campaign_margin_results', replace=true};
22QUIT;

Expected Result


The action should produce 'Margins' and 'MarginDifferences' tables. The business analyst can use the 'diff_discount_effect' result to state, with a credible interval, the average increase in purchase probability directly attributable to the discount offer, across the entire customer base.