Average Treatment Effects

Introduction

Let Y be a binary response, A a categorical treatment, and W a vector of confounders. Assume that we have observed n i.i.d. observations (Yi, Wi, Ai) ∼ P, i = 1, …, n. In the following we are interested in estimating the target parameter ψ(P) = (E[Y(a)], where Y(a) is the potential outcome we would have observed if treatment a had been administered, possibly contrary to the actual treatment that was observed, i.e., Y = Y(A).

Under the following assumptions

  1. Stable Unit Treatment Values Assumption (the treatment of a specific subject is not affecting the potential outcome of other subjects)
  2. Positivity, P(A ∣ W) > ϵ for some ϵ > 0.
  3. No unmeasured confounders, Y(a)⊥    ⊥ A|W

the target parameter can be identified from the observed data distribution as E(E[Y|W, A = a]) = E(E[Y(a)|W]) = E[Y(a)] or E[YI(A = a)/P(A = a|W)] = E[Y(a)].

This suggests estimation via either outcome regression (OR, g-computation) or inverse probability weighting (IPW). These can eventually also be combined to a doubly-robust augmented inverse probability weighted (AIPW) estimator.

Simulation

As an illustration we simulate from the following model Y ∼ Bernoulli(expit {A + X + Z}) A ∼ Bernoulli(expit {X + Z}) Z ∼ 𝒩(X, 1)

m <- lvm(Y ~ A+X+Z, A~X+Z, Z~X)
m <- distribution(m, ~A+Y, binomial.lvm())
d <- sim(m, 1e3, seed=1)
head(d)
#>   Y A          X          Z
#> 1 0 0 -0.6264538  0.5085113
#> 2 1 1  0.1836433  1.2955752
#> 3 0 0 -0.8356286 -1.7064062
#> 4 1 1  1.5952808  1.8060124
#> 5 1 0  0.3295078  0.3989034
#> 6 0 0 -0.8204684 -2.4831172

Estimation

The target parameter, E[Y(a)] can be estimated with the targeted::ate function:

args(ate)
#> function (formula, data = parent.frame(), weights, offset, family = stats::gaussian(identity), 
#>     nuisance = NULL, propensity = nuisance, all, labels = NULL, 
#>     ...) 
#> NULL

The formula should be specified as formula = response ~ treatment, and the outcome regression specified as nuisance = ~ covariates, and propensity model propensity = ~ covariates. Alternatively, the formula can be specified with the notation formula = response ~ treatment | OR-covariates | propensity-covariates. Parametric models are assumed for both the outcome regression and the propensity model which defaults to be logistic regression models (as in the simulation). A linear model can be used for the outcome regression part by setting binary=FALSE.

To illustrate this, we can estimate the (non-causal) marginal mean of each treatment value

ate(Y ~ A, data=d, nuisance=~1, propensity=~1)
#>     Estimate Std.Err   2.5%  97.5%   P-value
#> A=0   0.2937 0.02029 0.2539 0.3334 1.741e-47
#> A=1   0.8367 0.01660 0.8042 0.8692 0.000e+00

or equivalently

ate(Y ~ A | 1 | 1, data=d)
#>     Estimate Std.Err   2.5%  97.5%   P-value
#> A=0   0.2937 0.02029 0.2539 0.3334 1.741e-47
#> A=1   0.8367 0.01660 0.8042 0.8692 0.000e+00

In this simulation we can compare the estimates to the actual expected potential outcomes which can be approximated by Monte Carlo integration by simulating from the model where we intervene on A (i.e., break the dependence on X, Z):

mean(sim(intervention(m, "A", 0), 2e5)$Y)
#> [1] 0.500625
mean(sim(intervention(m, "A", 1), 2e5)$Y)
#> [1] 0.63801

The IPW estimator can then be estimated

ate(Y ~ A | 1 | X+Z, data=d)
#>     Estimate Std.Err   2.5%  97.5%   P-value
#> A=0   0.4793 0.02678 0.4268 0.5318 1.278e-71
#> A=1   0.6669 0.03263 0.6029 0.7308 7.528e-93

Similarly, the OR estimator is obtained by

ate(Y ~ A | A*(X+Z) | 1, data=d)
#>     Estimate Std.Err   2.5%  97.5%    P-value
#> A=0   0.4858 0.02796 0.4310 0.5406  1.243e-67
#> A=1   0.7213 0.02600 0.6703 0.7723 2.248e-169

Both estimates are in this case consistent though we can see that the OR estimate is much more efficient compared to the IPW estimator. However, both of these models rely on correct model specifications.

ate(Y ~ A | 1 | X, data=d)
#>     Estimate Std.Err   2.5%  97.5%   P-value
#> A=0   0.4208 0.02706 0.3678 0.4739 1.543e-54
#> A=1   0.7072 0.03366 0.6412 0.7731 5.204e-98
ate(Y ~ A | A*X | 1, data=d)
#>     Estimate Std.Err   2.5%  97.5%    P-value
#> A=0   0.4240 0.02617 0.3727 0.4752  4.794e-59
#> A=1   0.7474 0.02411 0.7001 0.7946 5.297e-211

In contrast, the doubly-robust AIPW estimator is consistent in the intersection model where either the propensity model or the outcome regression model is correctly specified

a <- ate(Y ~ A | A*X | X+Z, data=d)
summary(a)
#> 
#> Augmented Inverse Probability Weighting estimator
#>   Response Y (Outcome model: gaussian):
#>   Y ~ A * X 
#>   Exposure A (Propensity model: logistic regression):
#>   A ~ X + Z 
#> 
#>                    Estimate Std.Err    2.5%    97.5%    P-value
#>  A=0               0.492322 0.02609  0.4412  0.54346  2.028e-79
#>  A=1               0.663735 0.03068  0.6036  0.72386 8.429e-104
#> Outcome model:                                                 
#>  (Intercept)       0.426675 0.02498  0.3777  0.47563  2.048e-65
#>  A                 0.322545 0.03399  0.2559  0.38916  2.303e-21
#>  X                 0.232605 0.01825  0.1968  0.26837  3.266e-37
#>  A:X              -0.075738 0.02609 -0.1269 -0.02461  3.693e-03
#> Propensity model:                                              
#>  (Intercept)      -0.006421 0.08337 -0.1698  0.15699  9.386e-01
#>  X                -0.863004 0.12123 -1.1006 -0.62539  1.091e-12
#>  Z                -1.005211 0.09080 -1.1832 -0.82725  1.742e-28
#> 
#> Average Treatment Effect (constrast: 'A=1' - 'A=0'):
#> 
#>     Estimate Std.Err    2.5%  97.5%   P-value
#> ATE   0.1714 0.03661 0.09967 0.2432 2.831e-06

From the summary output we also get the estimates of the Average Treatment Effects expressed as a causal relative risk (RR), causal odds ratio (OR), or causal risk difference (RD) including the confidence limits.

From the model object a we can extract the estimated coefficients (expected potential outcomes) and corresponding asympotic variance matrix with the coef and vcov methods. The estimated influence function can extracted with the iid method:

coef(a)
#>       A=0       A=1 
#> 0.4923220 0.6637346
vcov(a)
#>              A=0          A=1
#> A=0 0.0006807275 0.0001409887
#> A=1 0.0001409887 0.0009411920
head(iid(a))
#>             A=0           A=1
#> 1 -0.0012182867 -0.0002821609
#> 2  0.0002438822  0.0002898771
#> 3 -0.0004583641 -0.0002555994
#> 4  0.0003753253  0.0002567340
#> 5  0.0011971267  0.0001267515
#> 6 -0.0004585485 -0.0001710518

Multiple treatments

As an example with multiple treatment levels, we simulate from a new model where the outcome is continuous and the treatment follows a proportional odds model

m <- lvm(y ~ a+x, a~x)
m <- ordinal(m, K=4, ~a)
d <- transform(sim(m, 1e4), a=factor(a))

The AIPW estimator is obtained by estimating a logistic regression model for each treatment level (vs all others) in the propensity model (here a correct model is specified for both the OR and IPW part)

summary(a2 <- ate(y ~ a | a*x | x, data=d, binary=FALSE))
#> 
#> Augmented Inverse Probability Weighting estimator
#>   Response y (Outcome model: gaussian):
#>   y ~ a * x 
#>   Exposure a (Propensity model: logistic regression):
#>   a ~ x 
#> 
#>     Estimate Std.Err    2.5%   97.5%    P-value
#> a=0  -1.5267 0.04694 -1.6187 -1.4347 4.379e-232
#> a=1  -0.8159 0.04282 -0.8999 -0.7320  6.149e-81
#> a=2  -0.5189 0.03327 -0.5842 -0.4537  7.802e-55
#> a=3   0.7713 0.02567  0.7210  0.8216 2.627e-198
#> 
#> Average Treatment Effect (constrast: 'a=1' - 'a=0'):
#> 
#>     Estimate Std.Err   2.5%  97.5%   P-value
#> ATE   0.7107 0.06152 0.5902 0.8313 7.048e-31

Choosing a different contrast for the association measures:

summary(a2, contrast=c(2,4))
#> 
#> Augmented Inverse Probability Weighting estimator
#>   Response y (Outcome model: gaussian):
#>   y ~ a * x 
#>   Exposure a (Propensity model: logistic regression):
#>   a ~ x 
#> 
#>     Estimate Std.Err    2.5%   97.5%    P-value
#> a=0  -1.5267 0.04694 -1.6187 -1.4347 4.379e-232
#> a=1  -0.8159 0.04282 -0.8999 -0.7320  6.149e-81
#> a=2  -0.5189 0.03327 -0.5842 -0.4537  7.802e-55
#> a=3   0.7713 0.02567  0.7210  0.8216 2.627e-198
#> 
#> Average Treatment Effect (constrast: 'a=1' - 'a=3'):
#> 
#>     Estimate Std.Err   2.5%  97.5%    P-value
#> ATE   -1.587 0.04693 -1.679 -1.495 9.052e-251
head(iid(a2))
#>             a=0           a=1           a=2           a=3
#> 1 -7.698132e-06  5.071150e-06  5.647753e-06 -3.460307e-04
#> 2 -4.764602e-05 -2.308980e-05 -2.285740e-05 -3.653052e-04
#> 3  8.025770e-06 -1.467194e-04 -1.493977e-04 -2.134071e-04
#> 4 -1.087875e-04 -1.955786e-04 -1.636055e-04 -2.390980e-04
#> 5  1.851275e-04  1.327037e-04  1.339996e-04  9.980451e-05
#> 6 -3.869502e-05 -1.650754e-05  3.998003e-04 -6.511661e-06
estimate(a2, function(x) x[2]-x[4])
#>     Estimate Std.Err   2.5%  97.5%    P-value
#> a=1   -1.587 0.04693 -1.679 -1.495 9.052e-251

SessionInfo

sessionInfo()
#> R version 4.4.2 (2024-10-31)
#> Platform: x86_64-pc-linux-gnu
#> Running under: Ubuntu 24.04.1 LTS
#> 
#> Matrix products: default
#> BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
#> LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so;  LAPACK version 3.12.0
#> 
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=C              
#>  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
#>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
#> 
#> time zone: Etc/UTC
#> tzcode source: system (glibc)
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] targeted_0.6 lava_1.8.0   knitr_1.49  
#> 
#> loaded via a namespace (and not attached):
#>  [1] Matrix_1.7-1        future.apply_1.11.3 jsonlite_1.8.9     
#>  [4] compiler_4.4.2      Rcpp_1.0.13-1       parallel_4.4.2     
#>  [7] jquerylib_0.1.4     globals_0.16.3      splines_4.4.2      
#> [10] yaml_2.3.10         fastmap_1.2.0       lattice_0.22-6     
#> [13] R6_2.5.1            future_1.34.0       nloptr_2.1.1       
#> [16] maketools_1.3.1     bslib_0.8.0         rlang_1.1.4        
#> [19] cachem_1.1.0        xfun_0.49           sass_0.4.9         
#> [22] sys_3.4.3           cli_3.6.3           digest_0.6.37      
#> [25] grid_4.4.2          mvtnorm_1.3-2       lifecycle_1.0.4    
#> [28] timereg_2.0.6       evaluate_1.0.1      pracma_2.4.4       
#> [31] data.table_1.16.2   numDeriv_2016.8-1.1 listenv_0.9.1      
#> [34] codetools_0.2-20    buildtools_1.0.0    survival_3.7-0     
#> [37] optimx_2023-10.21   parallelly_1.39.0   rmarkdown_2.29     
#> [40] tools_4.4.2         htmltools_0.5.8.1   mets_1.3.5