causalanalysis

caEffect

Description

The caEffect action provides model-agnostic methods for estimating potential outcome means and causal effects of categorical treatments. It supports several estimation methods, including inverse probability weighting (IPW), regression adjustment (REGADJ), augmented inverse probability weighting (AIPW), and targeted maximum likelihood estimation (TMLE). This action is essential for researchers and analysts who want to assess the impact of a treatment or intervention while controlling for confounding variables.

causalanalysis.caEffect / alpha=double difference={{evtLev=value, refLev=value}, ...} display={...} freq="variable-name" inference=boolean method="AIPW" | "IPW" | "REGADJ" | "TMLE" outcomeModel={...} outcomeVar={...} outputTables={...} pom={{...}, ...} pomCov=boolean pomInfo=boolean scaledIPWFlag=double table={...} treatVar={...} weight="variable-name";
Settings
ParameterDescription
alphaspecifies the significance level for the construction of all confidence intervals.
differencespecifies causal effects to estimate on the difference scale.
displayspecifies a list of results tables to send to the client for display.
freqnames the numeric variable that contains the frequency of occurrence for each observation.
inferencewhen set to True, computes standard errors and confidence intervals for the potential outcome mean and causal effect estimates.
methodspecifies the method to use for estimating potential outcome means (POMs).
outcomeModelspecifies the model to use for scoring predicted counterfactual outcomes.
outcomeVarspecifies information about the outcome variable.
outputTableslists the names of results tables to save as CAS tables on the server.
pomspecifies the potential outcomes to estimate.
pomCovwhen set to True, displays a covariance matrix of the potential outcome mean estimates.
pomInfowhen set to True, creates a table that summarizes the potential outcome specifications.
scaledIPWFlagspecifies a multiple of the expected inverse probability weight of an observation that is used to flag observations that have large weights.
tablespecifies the input data table.
treatVarspecifies information about the treatment variable.
weightnames the numeric variable to use for performing a weighted analysis of the data.
Data Preparation View data prep sheet
Data Creation for Causal Analysis

This example creates a dataset named 'treatment_data'. It contains an outcome variable 'outcome', a treatment variable 'treatment' (with levels 'Drug A' and 'Placebo'), and two confounding covariates 'covar1' and 'covar2'. This data will be used to estimate the causal effect of the drug.

Copied!
1DATA mycas.treatment_data;
2 DO i = 1 to 100;
3 covar1 = rand('UNIFORM');
4 covar2 = rand('NORMAL', 0, 1);
5 IF (covar1 + 0.5*covar2 > 0.5) THEN treatment = 'Drug A';
6 ELSE treatment = 'Placebo';
7 outcome = 10 + 5*(treatment='Drug A') + 3*covar1 + 2*covar2 + rand('NORMAL', 0, 2);
8 OUTPUT;
9 END;
10RUN;

Examples

This example first fits a linear regression model for the outcome. Then, it uses the `caEffect` action with the REGADJ method to estimate the potential outcome means (POMs) for each treatment level. This is a straightforward way to adjust for covariates.

SAS® / CAS Code Code awaiting community validation
Copied!
1PROC CAS;
2 regression.glm TABLE={name='treatment_data'}, class={'treatment'}, model={depvar='outcome', effects={'treatment', 'covar1', 'covar2'}}, store={name='reg_model', replace=true};
3 causalanalysis.caEffect TABLE={name='treatment_data'}, method='REGADJ', treatVar={name='treatment'}, outcomeVar={name='outcome', type='CONTINUOUS'}, outcomeModel={restore={name='reg_model'}, predName='P_outcome'}, pom={{trtLev='Drug A'}, {trtLev='Placebo'}};
4RUN;
Result :
The action will produce a 'POMs' table showing the estimated potential outcome mean for each treatment level ('Drug A' and 'Placebo'). Because `inference=false` (default), no standard errors or confidence intervals will be computed.

This example demonstrates the AIPW method, which is doubly robust. It requires two models: one for the outcome (like in REGADJ) and one for the treatment assignment (propensity score model). This example fits both models, then uses `caEffect` to estimate the potential outcome means and the average treatment effect (ATE) by specifying the `difference` parameter. It also enables inference to compute standard errors and confidence intervals.

SAS® / CAS Code Code awaiting community validation
Copied!
1PROC CAS;
2 regression.glm TABLE={name='treatment_data'}, class={'treatment'}, model={depvar='outcome', effects={'treatment', 'covar1', 'covar2'}}, store={name='out_model', replace=true};
3 logistic TABLE={name='treatment_data'}, class={'treatment'}, model={depvar='treatment', effects={'covar1', 'covar2'}}, store={name='ps_model', replace=true};
4 logistic.score TABLE={name='treatment_data'}, restore={name='ps_model'}, copyVars={'outcome', 'treatment', 'covar1', 'covar2'}, casout={name='scored_data', replace=true};
5 causalanalysis.caEffect TABLE={name='scored_data'}, method='AIPW', treatVar={name='treatment'}, outcomeVar={name='outcome', type='CONTINUOUS'}, outcomeModel={restore={name='out_model'}, predName='P_outcome'}, pom={{trtLev='Drug A', trtProb='P_treatmentDrug A'}, {trtLev='Placebo', trtProb='P_treatmentPlacebo'}}, difference={{evtLev='Drug A', refLev='Placebo'}}, inference=true, pomCov=true;
6RUN;
Result :
The output will include several tables: 'POMs' with potential outcome means, standard errors, and confidence intervals for each treatment group; 'CausalEffects' showing the estimated Average Treatment Effect (ATE) for 'Drug A' vs 'Placebo', along with its standard error and confidence interval; and 'POMCov' showing the covariance matrix for the POM estimates.

FAQ

What is the primary purpose of the caEffect action?
What estimation methods are available in the caEffect action?
What is the difference between the 'IPW', 'REGADJ', and 'AIPW' methods?
How do I specify the potential outcomes to be estimated?
How does the action handle different types of outcome variables?
Is it possible to get confidence intervals for the estimates?
What estimation methods can be used with the caEffect action?
How is the outcome variable specified in this action?
What is the role of the 'pom' parameter?
How can I obtain confidence intervals for the causal effect estimates?
What is the difference between the 'IPW' and 'AIPW' methods?