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 treatment variable, denoted by T, is binary (0 or 1).

  • The outcome variable, denoted by Y, is continuous.

  • There are 20 covariates: x Subscript j Baseline tilde Uniform left-parenthesis 0 comma 1 right-parenthesis for j equals 1 comma ellipsis comma 20.

  • Four of the covariates are randomly selected and used in the outcome model. The first selected variable is used in the propensity score model.

The outcome model is given as

StartLayout 1st Row 1st Column upper Y 2nd Column equals alpha left-parenthesis bold upper X right-parenthesis plus beta left-parenthesis bold upper X right-parenthesis t plus epsilon comma epsilon tilde Overscript iid Endscripts upper N left-parenthesis 0 comma 1 right-parenthesis 2nd Row 1st Column alpha left-parenthesis upper X right-parenthesis 2nd Column equals 1 plus cosine left-parenthesis 2 pi sigma-summation Underscript i equals 1 Overscript 4 Endscripts w Subscript i Baseline x Subscript s Sub Subscript i Subscript Baseline right-parenthesis 3rd Row 1st Column beta left-parenthesis upper X right-parenthesis 2nd Column equals sine left-parenthesis 2 pi sigma-summation Underscript i equals 1 Overscript 4 Endscripts w Subscript i Baseline x Subscript s Sub Subscript i Subscript Baseline right-parenthesis EndLayout

where left-brace s Subscript i Baseline right-brace Subscript i equals 1 Superscript 4 denotes the indices of the four covariates that are randomly selected from the 20 covariates and bold upper X denotes the covariates vector left-brace x Subscript j Baseline right-brace Subscript j equals 1 Superscript 20.

The propensity score model is given as

normal upper P normal r left-parenthesis upper T equals 1 vertical-bar bold upper X equals bold x right-parenthesis equals p left-parenthesis bold x right-parenthesis equals 0.1 plus 0.8 sine left-parenthesis 2 pi StartAbsoluteValue x Subscript s 1 Baseline minus 0.5 EndAbsoluteValue right-parenthesis

where T denotes the treatment variable.

The following statements simulate 20,000 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 10,000 observations in the data set deepEconDGP into the data table simCausal_train and the second 10,000 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 p left-parenthesis dot right-parenthesis, alpha left-parenthesis dot right-parenthesis, and beta left-parenthesis dot right-parenthesis 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 alpha left-parenthesis dot right-parenthesis estimation information to the data table outadata, and the OUTB= option writes the beta left-parenthesis dot right-parenthesis estimation information to the data table outbdata. The number of observations is shown in Figure 1.

Figure 1: Number of Observations

The DEEPCAUSAL Procedure

Number of Observations10000
Observations with Missing Covariates0
Observations with Missing Covariates for PS Model0
Observations with Missing Covariates for Outcome Model0
Observations with Missing Outcome0


The estimates of parameters of interest are shown in Figure 2.

Figure 2: Parameters of Interest

Population Parameter Estimates
ParameterPotential
Outcome
EstimateStandard
Error
95% Confidence LimitsZPr > |Z|
Average00.3519330.0162470.3200890.38377721.66<.0001
Average10.3612190.0152550.3313190.39111923.68<.0001
ATE 0.0092860.021574-0.0329980.0515700.430.6669

Subpopulation Parameter Estimates
ParameterPotential
Outcome
Treatment
Level
EstimateStandard
Error
95% Confidence LimitsZPr > |Z|
Conditional Average000.3635500.0176860.3288850.39821420.56<.0001
Conditional Average010.3442080.0165410.3117880.37662820.81<.0001
Conditional Average100.3683150.0186450.3317720.40485919.75<.0001
Conditional Average110.3565000.0166450.3238770.38912321.42<.0001
ATT 10.0122920.022012-0.0308500.0554350.560.5765
ATU 00.0047660.023280-0.0408630.0503940.200.8378
Composition Effect1 -0.0118150.017386-0.0458910.022261-0.680.4968
Observed Difference  -0.0070490.024815-0.0556860.041587-0.280.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
PolicyEstimateStandard
Error
95% Confidence LimitsZPr > |Z|
s10.6535670.0158920.6224190.68471541.13<.0001
s00.0595850.0150500.0300870.0890833.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
EstimateStandard
Error
95% Confidence LimitsZPr > |Z|
s0t-0.3065080.015133-0.336168-0.276848-20.25<.0001
s1t0.2874730.0147910.2584830.31646419.44<.0001


You can apply the previously saved propensity score model, the alpha left-parenthesis dot right-parenthesis estimation information, and the beta left-parenthesis dot right-parenthesis 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

The DEEPCAUSAL Procedure

Population Parameter Estimates
ParameterPotential
Outcome
EstimateStandard
Error
95% Confidence LimitsZPr > |Z|
Average00.3703380.0161740.3386370.40203822.90<.0001
Average10.3322230.0153080.3022200.36222721.70<.0001
ATE -0.0381150.021562-0.0803750.004146-1.770.0771

Subpopulation Parameter Estimates
ParameterPotential
Outcome
Treatment
Level
EstimateStandard
Error
95% Confidence LimitsZPr > |Z|
Conditional Average000.3840770.0178480.3490960.41905821.52<.0001
Conditional Average010.3614010.0163030.3294480.39335522.17<.0001
Conditional Average100.3518180.0189540.3146690.38896618.56<.0001
Conditional Average110.3194780.0164430.2872510.35170519.43<.0001
ATT 1-0.0419230.021779-0.0846090.000763-1.920.0542
ATU 0-0.0322600.023603-0.0785210.014002-1.370.1717
Composition Effect1 -0.0323390.017249-0.0661470.001468-1.870.0608
Observed Difference  -0.0645990.024768-0.113143-0.016055-2.610.0091

Policy Evaluation
PolicyEstimateStandard
Error
95% Confidence LimitsZPr > |Z|
s10.6461270.0157510.6152550.67699841.02<.0001
s00.0564340.0151830.0266750.0861933.720.0002

Policy Comparison
Comparison
Policy
Base
Policy
EstimateStandard
Error
95% Confidence LimitsZPr > |Z|
s0t-0.3022910.015035-0.331758-0.272824-20.11<.0001
s1t0.2874020.0148870.2582240.31658019.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.

Last updated: November 24, 2025