The DEEPCAUSAL Procedure
Example 14.2 Personalized Discount Policy for an Online Media Company
This example illustrates how a music subscription service from an online media company can offer targeted discounts through a personalized pricing plan based on many features that it observes about its customers to encourage them to buy more songs or become members. The main goal is to construct a policy that raises demand enough to boost overall revenue despite decreasing the price for some customers.
The data set is provided by the Microsoft research project ALICE and is available at https://msalicedatapublic.blob.core.windows.net/datasets/Pricing/pricing_sample.csv. The data set has 10,000 simulated observations that represent customers’ personal characteristics, such as age and log income, and online behavior history, such as previous purchase and previous online time per week. The treatment variable, t, is a binary variable that indicates whether or not a discount is applied. This variable is generated according to the values that the variable price takes in the data set. The value of t is 0 if the value of price is 1, indicating that no discount is given, and the value of t is 1 if the value of price is less than 1, indicating that a discount is applied. The outcome variable, revenue, is calculated by multiplying the number of songs purchased during the discount season by the price paid for the songs. Table 3 shows the names of the variables that are used in the model, their types, and their definitions. The type can be T (treatment), Y (outcome), (a covariate in the propensity score model), and/or
(a covariate in the outcome model).
Table 3: Model Variables
The following statements download the data set pricing_sample and create an ID variable that has a unique value for each observation, for the treatment variable (t), and for the outcome variable (revenue):
/*--- Download the data set ---*/
filename csvFile url
"https://msalicedatapublic.blob.core.windows.net/datasets/Pricing/pricing_sample.csv"
termstr=crlf;
proc import datafile=csvFile out=mycas.pricing_sample replace dbms=csv; run;
/*--- Create the ID, treatment, and outcome variables ---*/
data mycas.new_pricing_sample;
set mycas.pricing_sample;
id = put(_threadid_,8.) || '_' || Put(_n_,8.); * ID variable;
if price<1 then t=1; else t=0; * treatment variable;
revenue=price*demand; * outcome variable;
run;
The first step in policy evaluation and policy optimization is to estimate the effect of the treatment and to save to a specified output data table the details of the estimation, including ,
,
, the residual, and the influence functions for each unit. You can do this by using the following statements:
/*--- Estimate the treatment effect and save the estimation details ---*/
proc deepcausal data=mycas.new_pricing_sample;
id id;
psmodel t = account_age age avg_hours days_visited friends_count
has_membership is_US songs_purchased income /
dnn=(nodes=(32 32 32 32)
train=(optimizer=(miniBatchSize=500 regL1=0.0001 maxEpochs=32000
algorithm=adam) nthreads=20 seed=12345 recordseed=67890));
model revenue = account_age age avg_hours days_visited friends_count
has_membership is_US songs_purchased income /
dnn=(nodes=(32 32 32 32)
train=(optimizer=(miniBatchSize=500 regL1=0.001 maxEpochs=32000
algorithm=adam) nthreads=20 seed=12345 recordseed=67890));
infer out=mycas.oest outdetails=mycas.odetails;
run;
For this example, the same covariates are used in both the propensity score mode and the outcome model. The model estimation details are saved in the output data table odetails.
The estimation results are shown in Output 14.2.1. The estimate of the average treatment effect, ATE, is negative and statistically significant, suggesting that the discount, on average, causes revenue that is generated by the whole population to decrease. However, the estimate of the average treatment effect on the treated, ATT, reflects an insignificant effect of the discount on revenue rather than a negative effect. This could mean that the discount was given to some customers who really did not care about it, or that the discount was not given to some customers to whom it could have mattered. Identifying the characteristics of customers to whom the discount matters helps construct the optimum policy to use the least resources and get the most profit.
Output 14.2.1: Parameters of Interest
| Population Parameter Estimates | |||||||
|---|---|---|---|---|---|---|---|
| Parameter | Potential Outcome | Estimate | Standard Error | 95% Confidence Limits | Z | Pr > |Z| | |
| Average | 0 | 14.339947 | 0.074639 | 14.193658 | 14.486236 | 192.12 | <.0001 |
| Average | 1 | 13.581590 | 0.058128 | 13.467661 | 13.695518 | 233.65 | <.0001 |
| ATE | -0.758358 | 0.023595 | -0.804603 | -0.712113 | -32.14 | <.0001 | |
| Subpopulation Parameter Estimates | ||||||||
|---|---|---|---|---|---|---|---|---|
| Parameter | Potential Outcome | Treatment Level | Estimate | Standard Error | 95% Confidence Limits | Z | Pr > |Z| | |
| Conditional Average | 0 | 0 | 18.353066 | 0.230375 | 17.901539 | 18.804594 | 79.67 | <.0001 |
| Conditional Average | 0 | 1 | 11.255225 | 0.132778 | 10.994985 | 11.515466 | 84.77 | <.0001 |
| Conditional Average | 1 | 0 | 16.586494 | 0.203244 | 16.188143 | 16.984845 | 81.61 | <.0001 |
| Conditional Average | 1 | 1 | 11.271842 | 0.120335 | 11.035990 | 11.507693 | 93.67 | <.0001 |
| ATT | 1 | 0.016616 | 0.024141 | -0.030700 | 0.063933 | 0.69 | 0.4913 | |
| ATU | 0 | -1.766572 | 0.039504 | -1.843999 | -1.689146 | -44.72 | <.0001 | |
| Composition Effect | 1 | -5.314653 | 0.304349 | -5.911165 | -4.718140 | -17.46 | <.0001 | |
| Observed Difference | -7.081225 | 0.330048 | -7.728108 | -6.434342 | -21.46 | <.0001 | ||
In policy optimization, the goal is to maximize the expected utility of a policy. For the definition of the expected utility function and how it is estimated, as well as details such as the definition of a policy rule, see the section Policy Evaluation and Comparison. In this example, because a positive treatment effect is preferred, anyone whose value is positive should be given the treatment (that is, a discount). This function is sometimes referred to as the individual treatment effect (ITE).
The variable _beta_ in the data table odetails that is obtained during the previous estimation contains the estimated values for this function for each individual. You can construct an optimal policy by offering a discount to individuals whose _beta_ value is positive. For comparison, the following DATA steps create the optimal policy, s2, along with the other policies: s0, offer no one a discount; and s1, offer everyone a discount.
data mycas.discountPolicy;
set mycas.odetails;
s0 = 0; * treat none;
s1 = 1; * treat all;
s2 = _beta_>=0; * treat only individuals whose ITEs are positive;
keep id t account_age age avg_hours days_visited
friends_count has_membership is_US songs_purchased
income revenue s0 s1 s2;
run;
You can do policy evaluation by specifying the POLICY= option in the INFER statement and do policy comparison by specifying the POLICYCOMPARISON= option in the same statement. The following statements estimate the model and do policy evaluation and comparison:
/*--- Policy evaluation and comparison ---*/
proc deepcausal data=mycas.discountPolicy;
id id;
psmodel t = account_age age avg_hours days_visited friends_count
has_membership is_US songs_purchased income /
dnn=(nodes=(32 32 32 32)
train=(optimizer=(miniBatchSize=500 regL1=0.0001
maxEpochs=32000 algorithm=adam) nthreads=20
seed=12345 recordseed=67890));
model revenue = account_age age avg_hours days_visited friends_count
has_membership is_US songs_purchased income /
dnn=(nodes=(32 32 32 32)
train=(optimizer=(miniBatchSize=500 regL1=0.001
maxEpochs=32000 algorithm=adam) nthreads=20
seed=12345 recordseed=67890));
infer policy=(t s0 s1 s2) policyComparison=(base=(t)
compare=(s0 s1 s2))
out=mycas.oest2 outdetails=mycas.odetails2;
run;
The option POLICY=(t s0 s1 s2) requests that the policy evaluation be done for the initial discount policy (t), the policy of giving no one a discount (s0), the policy of giving everyone a discount (s1), and the personalized discount policy of giving a discount only to those whose _beta_ value is positive (s2). The suboption COMPARE=(s0 s1 s2) in the POLICYCOMPARISON= option indicates that the policies s0, s1, and s2 are to be compared to the base policy, t, which is specified by the suboption BASE=(t), also in the POLICYCOMPARISON= option.
The policy evaluation results are shown in Output 14.2.2.
Output 14.2.2: Policy Evaluation
| Policy Evaluation | ||||||
|---|---|---|---|---|---|---|
| Policy | Estimate | Standard Error | 95% Confidence Limits | Z | Pr > |Z| | |
| t | 14.359344 | 0.068878 | 14.224345 | 14.494342 | 208.47 | <.0001 |
| s0 | 14.316452 | 0.075257 | 14.168950 | 14.463953 | 190.23 | <.0001 |
| s1 | 13.582058 | 0.057873 | 13.468629 | 13.695488 | 234.69 | <.0001 |
| s2 | 14.836492 | 0.069824 | 14.699638 | 14.973345 | 212.48 | <.0001 |
The optimal policy, s2, indeed has the highest estimate. When the discount is given to those whose ITE is positive, the average outcome, which in this example is revenue, for each person increases to about 14.85 from about 14.56, which is obtained by the base policy. This is the largest revenue generated, and it is generated by the personalized discount policy.
Output 14.2.3 shows the output for the policy comparison. Policy s1, giving everyone the discount, is worse than the base policy, and s0, giving no one the discount, is slightly better than the base policy. As expected, s2, giving the discount to the right person, produces the best results.
Output 14.2.3: Policy Comparison
| Policy Comparison | |||||||
|---|---|---|---|---|---|---|---|
| Comparison Policy | Base Policy | Estimate | Standard Error | 95% Confidence Limits | Z | Pr > |Z| | |
| s0 | t | -0.042892 | 0.017138 | -0.076482 | -0.009302 | -2.50 | 0.0123 |
| s1 | t | -0.777285 | 0.017681 | -0.811940 | -0.742631 | -43.96 | <.0001 |
| s2 | t | 0.477148 | 0.015182 | 0.447392 | 0.506904 | 31.43 | <.0001 |