CAEFFECT Procedure

Example 6.3 Estimation by Doubly Robust Methods

(View the complete code for this example.)

This example uses the mylib.SmokingWeight data table from Estimation by Inverse Probability Weighting. The same causal question is examined, but this example uses the augmented inverse probability weighting (AIPW) and targeted maximum likelihood estimation (TMLE) methods.

The AIPW and TMLE methods are doubly robust methods, and they combine modeling of both the treatment and outcome variables. The following statements use the LOGSELECT procedure to fit a logistic model for the treatment variable Quit and create an output data table that contains the predictions from the fitted model:

proc logselect data=mylib.SmokingWeight;
   class Sex Race Education Exercise Activity;
   model Quit(Event='1') = Sex Race Education
         Exercise Activity Age YearsSmoke PerDay;
   output out=mylib.swDREstData pred=pTrt copyvars=(_ALL_);
run;

The EVENT= response variable option in the MODEL statement ensures that the LOGSELECT procedure models the probability that the variable Quit takes the value 1. In the OUTPUT statement, the PRED= option names the variable in the output data table that contains the predicted event probability, and the COPYVARS= option copies all variables from the input data table to the output data table.

The following DATA step creates the variable pCnt, which contains the predicted probability of being assigned to the control condition, Quit=0:

data mylib.swDREstData;
   set mylib.swDREstData;
   pCnt = 1 - pTrt;
run;

An alternative way to obtain the predicted treatment probabilities is to save the fitted treatment model as an analytic store and use the ASTORE procedure. This approach is demonstrated in Estimation by Inverse Probability Weighting.

The following statements use the BART procedure to fit a model for the outcome variable by using Bayesian additive regression trees (BART). The model for this example is fit by using an ensemble of 100 trees; 200 samples of the ensemble are saved for prediction, and the fitted model is saved in the analytic store bartOutMod.

proc bart data=mylib.swDREstData nTree=100 nMC=200 seed=2156;
   class Sex Race Education Exercise Activity Quit;
   model Change = Sex Race Education Exercise Quit Activity
         Age YearsSmoke PerDay;
   store out=mylib.bartOutMod;
run;

The following statements use the CAEFFECT procedure to estimate potential outcome means by using the AIPW estimation method and to compute the difference between the two potential outcomes:

proc caeffect data=mylib.swDREstData method=aipw;
   treatvar Quit;
   outcomevar Change;
   outcomemodel restore=mylib.bartOutMod predName=P_Change;
   pom treatLev=1 treatProb=pTrt;
   pom treatLev=0 treatProb=pCnt;
   difference evtLev=1;
run;

When you use PROC CAEFFECT, at least one POM statement is required in order to specify the potential outcomes of interest, and the TREATVAR statement is required in order to specify the treatment variable of interest. For the AIPW estimation method, you must also specify the outcome variable by using the OUTCOMEVAR statement. For each potential outcome specification, you use the TREATLEV= option to identify the level of treatment that defines the potential outcome, and you use the TREATPROB= option to specify the variable in the input data table that contains the predicted probability of being assigned to that level.

The AIPW estimation method also requires predicted counterfactual values for each observation. For each potential outcome of interest, the counterfactual predictions are obtained by replacing the observed treatment level with the level that defines the potential outcome. In this example, the previously fit BART model is specified by using the OUTCOMEMODEL statement, and the procedure uses the previously fit model to predict counterfactual outcome values. When you provide as input to PROC CAEFFECT an analytic store that contains a model for the outcome variable, the input data table must contain the predictor variables that the model requires, and you must specify the names of the variables created by the analytic store that contains the predicted values. If you do not know these variable names, you can use the DESCRIBE statement in PROC ASTORE to describe the store.

As an alternative to providing a previously fit outcome model as input to PROC CAEFFECT, you can specify variables in the input data table that contain predicted counterfactual outcome values for each treatment level of interest. You specify the names of these variables by using the PREDOUT= option for each potential outcome specification in a POM statement. An example of how you can use this alternative syntax and how you can obtain the necessary counterfactual predictions is provided by Estimation by Regression Adjustment.

The output from this analysis is displayed by default and is presented in Output 6.3.1 through Output 6.3.3.

The "Model Information" table in Output 6.3.1 summarizes important information, including the data source, treatment variable name, estimation method, type of outcome variable, and name of the analytic store used for outcome modeling.

Output 6.3.1: Model Information

The CAEFFECT Procedure

Model Information
Data SourceSWDRESTDATA
Treatment VariableQuit
Outcome VariableChange
Outcome TypeContinuous
Estimation MethodAIPW
Outcome Model StoreBARTOUTMOD


Output 6.3.2 displays the "Number of Observations" table. In this analysis, a number of observations are not used, because there are missing predicted treatment assignment probabilities. These probabilities are missing because there are missing values in the predictor variables and because a generalized linear model, in particular logistic regression, is used to model the treatment variable. The BART model that is used for the outcome variable can predict counterfactual outcome values even for observations that have missing predictor values.

Output 6.3.2: Number of Observations

Number of Observations Read1746
Number of Observations Used1566


Output 6.3.3 displays the potential outcome mean estimates and their difference. The "POM Estimates" table indicates the level of treatment that defines the potential outcome and the estimate of its mean. The "POM Differences" table shows the requested difference in potential outcome mean estimates. With the proper causal assumptions, the difference in potential outcome mean estimates corresponds to an estimate of the average treatment effect (ATE) of a weight change that is approximately 3.27 kilograms greater because the subjects quit smoking. This value is comparable to the estimate that is obtained in Estimation by Inverse Probability Weighting.

Output 6.3.3: Potential Outcome Mean and Difference Estimates

POM Estimates
Treatment
Level
Estimate
15.12356
01.78772

POM Differences
Treatment LevelsDifference
EventReference
103.3358


The TMLE method is a doubly robust method that you can use as an alternative to the AIPW method. The required inputs are the same for both methods. The following statements use PROC CAEFFECT to estimate potential outcome means by using the TMLE method and to compute the difference between the two potential outcomes:

proc caeffect data=mylib.swDREstData method=tmle;
   treatvar Quit;
   outcomevar Change;
   outcomemodel restore=mylib.bartOutMod predName=P_Change;
   pom treatLev=1 treatProb=pTrt;
   pom treatLev=0 treatProb=pCnt;
   difference evtLev=1;
run;

The syntax is identical to the syntax that is used to invoke the AIPW method, except that the METHOD= option now specifies the TMLE method.

As in the analysis that uses the AIPW method, the output from the analysis that uses the TMLE method is displayed by default.

The "Model Information" table in Output 6.3.4 summarizes important information, including the data source, treatment variable name, estimation method, type of outcome variable, and name of the analytic store used for outcome modeling.

Output 6.3.4: Model Information

The CAEFFECT Procedure

Model Information
Data SourceSWDRESTDATA
Treatment VariableQuit
Outcome VariableChange
Outcome TypeContinuous
Estimation MethodTMLE
Outcome Model StoreBARTOUTMOD


Output 6.3.5 displays the "Number of Observations" table. It is identical to the table that is produced by the analysis that uses the AIPW method.

Output 6.3.5: Number of Observations

Number of Observations Read1746
Number of Observations Used1566


Output 6.3.6 displays the potential outcome mean estimates and their difference. The values in these tables are almost the same as the values in the corresponding tables that are produced by the AIPW method.

Output 6.3.6: Potential Outcome Mean and Difference Estimates

POM Estimates
Treatment
Level
Estimate
15.12564
01.78811

POM Differences
Treatment LevelsDifference
EventReference
103.3375


Last updated: May 14, 2026