DEEPCAUSAL Procedure
Simulation Study
This example illustrates how the DEEPCAUSAL procedure estimates the parameters of interest and performs policy evaluation and policy comparison. It also demonstrates how you can save the model information and use it later to score other new data. A simulated data set is generated, based on the following assumptions:
The outcome model is given as
where denotes the indices of the four covariates that are randomly selected from the 20 covariates and
denotes the covariates vector
.
The propensity score model is given as
where T denotes the treatment variable.
The following statements simulate samples that are based on the propensity score and outcome models that were just presented:
%macro deepEconGenerateData(n,d,eff,seed);
data deepEconDGP;
array x[&d.] x1-x&d.;
array w[&d.] w1-w&d.;
array selectedX[&eff.] selectedX1-selectedX&eff.;
retain w;
call streaminit('pcg', &seed.);
* weights;
sumw = 0;
do i = 1 to &eff.;
w[i] = rand('Uniform');
sumw = sumw + w[i];
end;
do i = 1 to &eff.;
w[i] = w[i] / sumw;
end;
* select x;
do i = 1 to &eff.;
selectedX[i] = ceil(&d.*rand('Uniform'));
end;
do i = 1 to &n.;
* covariates;
do j = 1 to &d.;
x[j] = rand('Uniform');
end;
* treatment assignment;
u = rand('Uniform');
sumx = 0;
do j = 1 to &eff.;
sumx = sumx + w[j]*x[selectedX[j]];
end;
px = (0.1 + 0.8*sin(2*abs(x[selectedX[1]]-0.5)*3.1415926));
if(u<=px) then t=1;
else t=0;
* outcome;
eps = rand('Normal');
mu = 1 + cos(sumx*2*3.1415926);
tau = sin(sumx*2*3.1415926);
y = mu + tau*t + eps;
s1=(tau>0);
s0=1-s1;
output;
end;
run;
%mend;
%let n=20000;
%let d=20;
%let eff=4;
%let seed=12346;
%deepEconGenerateData(&n.,&d.,&eff.,&seed.);
The following DATA steps load the first observations in the data set
deepEconDGP into the data table simCausal_train and the second observations into the data table
simCausal_test in your session that is associated with the mylib libref. The DATA step assumes that your libref is named mylib, but you can substitute any appropriately defined libref.
data mylib.simCausal_train;
set deepEconDGP(obs=10000 keep=i x1-x20 t y px mu tau s0 s1
selectedX1-selectedX4);
run;
data mylib.simCausal_test;
set deepEconDGP(firstobs=10001 keep=i x1-x20 t y px mu tau s0 s1
selectedX1-selectedX4);
run;
The unknown functions ,
, and
are estimated through two DNNs by using the data set
simCausal_train. The parameters of interest, policy evaluation, and policy comparison are then estimated. The following statements use PROC DEEPCAUSAL to get these estimates and store the model information and parameter learning results:
proc deepcausal data=mylib.simCausal_train;
id i;
psmodel t=x1-x20 / dnn=(nodes=(32 32 32 32)
train=(optimizer=(miniBatchSize=2000 regL1=0.0001 maxEpochs=1000
algorithm=adam(learningRate=0.0001)) nthreads=5 seed=12345));
model y=x1-x20 / dnn=(nodes=(32 32 32 32)
train=(optimizer=(miniBatchSize=2000 regL1=0.001 maxEpochs=1000
algorithm=adam) nthreads=5 seed=12345));
infer policy=(s1 s0) policyComparison=(base=(t) compare=(s0 s1))
out=mylib.oest outdetails=mylib.odetails;
score outps=mylib.outpsdata outa=mylib.outadata outb=mylib.outbdata;
run;
The OUTPS= option writes the propensity score model information to the data table outpsdata, the OUTA= option writes the estimation information to the data table
outadata, and the OUTB= option writes the estimation information to the data table
outbdata. The number of observations is shown in Figure 1.
Figure 1: Number of Observations
| Number of Observations | 10000 |
|---|---|
| Observations with Missing Covariates | 0 |
| Observations with Missing Covariates for PS Model | 0 |
| Observations with Missing Covariates for Outcome Model | 0 |
| Observations with Missing Outcome | 0 |
The estimates of parameters of interest are shown in Figure 2.
Figure 2: Parameters of Interest
| Population Parameter Estimates | |||||||
|---|---|---|---|---|---|---|---|
| Parameter | Potential Outcome | Estimate | Standard Error | 95% Confidence Limits | Z | Pr > |Z| | |
| Average | 0 | 0.351933 | 0.016247 | 0.320089 | 0.383777 | 21.66 | <.0001 |
| Average | 1 | 0.361219 | 0.015255 | 0.331319 | 0.391119 | 23.68 | <.0001 |
| ATE | 0.009286 | 0.021574 | -0.032998 | 0.051570 | 0.43 | 0.6669 | |
| Subpopulation Parameter Estimates | ||||||||
|---|---|---|---|---|---|---|---|---|
| Parameter | Potential Outcome | Treatment Level | Estimate | Standard Error | 95% Confidence Limits | Z | Pr > |Z| | |
| Conditional Average | 0 | 0 | 0.363550 | 0.017686 | 0.328885 | 0.398214 | 20.56 | <.0001 |
| Conditional Average | 0 | 1 | 0.344208 | 0.016541 | 0.311788 | 0.376628 | 20.81 | <.0001 |
| Conditional Average | 1 | 0 | 0.368315 | 0.018645 | 0.331772 | 0.404859 | 19.75 | <.0001 |
| Conditional Average | 1 | 1 | 0.356500 | 0.016645 | 0.323877 | 0.389123 | 21.42 | <.0001 |
| ATT | 1 | 0.012292 | 0.022012 | -0.030850 | 0.055435 | 0.56 | 0.5765 | |
| ATU | 0 | 0.004766 | 0.023280 | -0.040863 | 0.050394 | 0.20 | 0.8378 | |
| Composition Effect | 1 | -0.011815 | 0.017386 | -0.045891 | 0.022261 | -0.68 | 0.4968 | |
| Observed Difference | -0.007049 | 0.024815 | -0.055686 | 0.041587 | -0.28 | 0.7764 | ||
The policy evaluation estimates the expected utility of a policy. The policy evaluation results are shown in Figure 3.
Figure 3: Policy Evaluation
| Policy Evaluation | ||||||
|---|---|---|---|---|---|---|
| Policy | Estimate | Standard Error | 95% Confidence Limits | Z | Pr > |Z| | |
| s1 | 0.653567 | 0.015892 | 0.622419 | 0.684715 | 41.13 | <.0001 |
| s0 | 0.059585 | 0.015050 | 0.030087 | 0.089083 | 3.96 | <.0001 |
The policy comparison estimates the difference in expected utility of two policies. The policy comparison results are shown in Figure 4.
Figure 4: Policy Comparison
| Policy Comparison | |||||||
|---|---|---|---|---|---|---|---|
| Comparison Policy | Base Policy | Estimate | Standard Error | 95% Confidence Limits | Z | Pr > |Z| | |
| s0 | t | -0.306508 | 0.015133 | -0.336168 | -0.276848 | -20.25 | <.0001 |
| s1 | t | 0.287473 | 0.014791 | 0.258483 | 0.316464 | 19.44 | <.0001 |
You can apply the previously saved propensity score model, the estimation information, and the
estimation information to a new data set by specifying the INPS=, INA=, and INB= options in the SCORE statement. The following statements use the
outpsdata, outadata, and outbdata data tables as input data tables and estimate the parameters of interest, policy evaluation, and policy comparison by using the simCausal_test data set:
proc deepcausal data=mylib.simCausal_test;
id i;
infer policy=(s1 s0) policyComparison=(base=(t) compare=(s0 s1))
out=mylib.oest2 outdetails=mylib.odetails2;
score inps=mylib.outpsdata ina=mylib.outadata inb=mylib.outbdata;
run;
When you specify the INPS=, INA=, and INB= options in the SCORE statement, you do not need to specify the PSMODEL or MODEL statement. The estimates of parameters of interest, policy evaluation, and policy comparison are shown in Figure 5.
Figure 5: Parameters of Interest, Policy Evaluation, and Policy Comparison
| Population Parameter Estimates | |||||||
|---|---|---|---|---|---|---|---|
| Parameter | Potential Outcome | Estimate | Standard Error | 95% Confidence Limits | Z | Pr > |Z| | |
| Average | 0 | 0.370338 | 0.016174 | 0.338637 | 0.402038 | 22.90 | <.0001 |
| Average | 1 | 0.332223 | 0.015308 | 0.302220 | 0.362227 | 21.70 | <.0001 |
| ATE | -0.038115 | 0.021562 | -0.080375 | 0.004146 | -1.77 | 0.0771 | |
| Subpopulation Parameter Estimates | ||||||||
|---|---|---|---|---|---|---|---|---|
| Parameter | Potential Outcome | Treatment Level | Estimate | Standard Error | 95% Confidence Limits | Z | Pr > |Z| | |
| Conditional Average | 0 | 0 | 0.384077 | 0.017848 | 0.349096 | 0.419058 | 21.52 | <.0001 |
| Conditional Average | 0 | 1 | 0.361401 | 0.016303 | 0.329448 | 0.393355 | 22.17 | <.0001 |
| Conditional Average | 1 | 0 | 0.351818 | 0.018954 | 0.314669 | 0.388966 | 18.56 | <.0001 |
| Conditional Average | 1 | 1 | 0.319478 | 0.016443 | 0.287251 | 0.351705 | 19.43 | <.0001 |
| ATT | 1 | -0.041923 | 0.021779 | -0.084609 | 0.000763 | -1.92 | 0.0542 | |
| ATU | 0 | -0.032260 | 0.023603 | -0.078521 | 0.014002 | -1.37 | 0.1717 | |
| Composition Effect | 1 | -0.032339 | 0.017249 | -0.066147 | 0.001468 | -1.87 | 0.0608 | |
| Observed Difference | -0.064599 | 0.024768 | -0.113143 | -0.016055 | -2.61 | 0.0091 | ||
| Policy Evaluation | ||||||
|---|---|---|---|---|---|---|
| Policy | Estimate | Standard Error | 95% Confidence Limits | Z | Pr > |Z| | |
| s1 | 0.646127 | 0.015751 | 0.615255 | 0.676998 | 41.02 | <.0001 |
| s0 | 0.056434 | 0.015183 | 0.026675 | 0.086193 | 3.72 | 0.0002 |
| Policy Comparison | |||||||
|---|---|---|---|---|---|---|---|
| Comparison Policy | Base Policy | Estimate | Standard Error | 95% Confidence Limits | Z | Pr > |Z| | |
| s0 | t | -0.302291 | 0.015035 | -0.331758 | -0.272824 | -20.11 | <.0001 |
| s1 | t | 0.287402 | 0.014887 | 0.258224 | 0.316580 | 19.31 | <.0001 |
For more information about the estimates of parameters of interest, policy evaluation, and policy comparison, see the sections Full-Population Average Effect Parameters, Subpopulation Average Effect Parameters, and Policy Evaluation and Comparison.