# Average treatment effect (ATE) for Competing risks and binary outcomes

#### Klaus Holst & Thomas Scheike

#### 2025-08-30

The binregATE function can fit a logistic link model with IPCW adjustment for a specific time-point, and can thus be used for describing survival or competing risks data. The function can be used for large data and is completely scalable, that is, linear in the data. A nice feature is that influcence functions are computed and are available.

In addition and to summarize

- the censoring weights can be strata dependent
- predictions can be computed with standard errors
- computation time is linear in data
  - including standard errors
- clusters can be given and then cluster corrected standard errors are computed

# Average treatment for Competing risks data

The binreg function does direct binomial regression for one time-point, \(t\), fitting the model \[\begin{align*} P(T \leq t, \epsilon=1 | X ) & = \mbox{expit}( X^T \beta), \end{align*}\] for possible right censored data. The estimation procedure is based on IPCW adjusted estimating equation (EE) \[\begin{align*} U(\beta) = & X \left( \Delta(t) I(T \leq t, \epsilon=1 )/G_c(T \wedge t) - \mbox{expit}( X^T beta) \right) = 0 \end{align*}\] where \(G_c(t)=P(C > t)\), the censoring survival distribution, and with \(\Delta(t) = I( C > T \wedge t)\) the indicator of being uncensored at time \(t\).

The function logitIPCW instead considers the EE the EE \[\begin{align*} U(\beta) = & X \frac{\Delta(t)}{G_c(T \wedge t)} \left( I(T \leq t, \epsilon=1 ) - \mbox{expit}( X^T beta) \right) = 0. \end{align*}\] The two score equations are quite similar, and exactly the same when the censoring model is fully-nonparametric given \(X\).

- It seems that the binreg estimating equations most often is preferable to use, and the estimating equation used is also augmented in the default implementation (see the binreg vignette).

Additional functions logitATE, and binregATE computes the average treatment effect. We demonstrate their use below.

The functions binregATE (recommended) and logitATE also works when there is no censoring and we thus have simple binary outcome.

Variance is based on sandwich formula with IPCW adjustment, and naive.var is variance under a known censoring model. The influence functions are stored in the output. Further, the standard errors can be cluster corrected by specifying the relevant cluster for the working outcome model.

- We estimate the average treatment effect of our binary response \(I(T \leq t, \epsilon=1)\)
  - Using a working logistic model for the resonse (possibly with a cluster specification)
  - Using a working logistic model for treatment given covariates
    - The binregATE can also handle a factor with more than two levels and then uses the mlogit multinomial regression function (of mets).
  - Using a working model for censoring given covariates, this must be a stratified Kaplan-Meier.

If there are no censoring then the censoring weights are simply set to 1.

The average treatment effect is \[\begin{align*} E(Y(1) - Y(0)) \end{align*}\] using counterfactual outcomes.

We compute the simple G-estimator \[\begin{align*} \sum m_a(X_i) \end{align*}\] to estimate the risk \(E(Y(a))\).

The DR-estimator instead uses the estimating equations that are double robust wrt

- A working logistic model for the resonse
- A working logistic model for treatment given covariates

This is estimated using the estimator \[\begin{align*} \sum \left[ \frac{A_i Y_i}{\pi_A(X_i)}-\frac{A_i - \pi_A(X_i)}{\pi_A(X_i)} m_1(X_i) \right] - \left[ \frac{(1-A_i) Y_i}{1-\pi_A(X_i)}+\frac{A_i - \pi_A(X_i)}{1-\pi_A(X_i)} m_0(X_i) \right] \end{align*}\] where

- \(A_i\) is treatment indicator
- \(\pi_A(X_i) = P(A_i=1|X_i)\) is treatment model
- \(Y_i\) outcome, that in case of censoring is censoring adjusted \(\tilde Y_i \Delta(t) /G_c(T_i- \wedge t)\)
- \(\tilde Y_i = I(T_i \leq t, \epsilon_i=1)\) oucome before censoring.
- \(m_j(X_i)=P(Y_i=1| A_i=j,X_i)\) is outcome model, using binomial regression.

The standard errors are then based on an iid decomposition using taylor-expansions for the parameters of the treatment-model and the outcome-model, and the censoring probability.

We need that the censoring model is correct, so it can be important to use a sufficiently large censorng model as we also illustrate below.

- The censoring model can be specified by strata (used for phreg

We also compute standard marginalization for average treatment effect (called differenceG) \[\begin{align*} \sum \left[ m_1(X_i) - m_0(X_i) \right] \end{align*}\] and again standard errors are based on the related influcence functions and are also returned.

For large data where there are more than 2 treatment groups the computations can be memory extensive when there are many covariates due to the multinomial-regression model used for the propensity scores. Otherwise the function (binregATE) will run for large data.

The ATE functions need that the treatment that is given as the first variable on the right hand side of the outcome model is a factor. The variable is also indentified from the left hand side of the treatment model (treat.model), that per default assumes that treatment does not depend on any covariates.

# Average treatment effect

First we simulate some data that mimics that of Kumar et al 2012. This is data from multiple myeloma patients treated with allogeneic stem cell transplantation from the Center for International Blood and Marrow Transplant Research (CIBMTR) Kumar et al (2012), “Trends in allogeneic stem cell transplantation for multiple myeloma: a CIBMTR analysis”. The data used in this paper consist of patients transplanted from 1995 to 2005, and we compared the outcomes between transplant periods: 2001-2005 (N=488) versus 1995-2000 (N=375). The two competing events were relapse (cause 2) and treatment-related mortality (TRM, cause 1) defined as death without relapse. considered the following risk covariates: transplant time period (gp (main interest of the study): 1 for transplanted in 2001-2005 versus 0 for transplanted in 1995-2000), donor type (dnr: 1 for Unrelated or other related donor (N=280) versus 0 for HLA-identical sibling (N=584)), prior autologous transplant (preauto: 1 for Auto+Allo transplant (N=399) versus 0 for allogeneic transplant alone (N=465)) and time to transplant (ttt24: 1 for more than 24 months (N=289) versus 0 for less than or equal to 24 months (N=575))).

We here generate similar data by assuming that the two cumlative incidence curves are logistic and we have censoring that depends on the covariates via a Cox model. All this is wrapped in the kumarsim function. The simulation does not deal with possible violations of the bound that \(F_1+F_2 < 1\). But as we increase the sample size we still see that we recover the parameters of cause 2.

    ###install.packages("mets")

    library(mets)
    set.seed(100)
    ###
    n <- 400
    kumar <- kumarsim(n,depcens=1)
    kumar$cause <- kumar$status
    kumar$ttt24 <- kumar[,6]
    dtable(kumar,~cause)
    #>
    #> cause
    #>   0   1   2
    #> 122 126 152
    dfactor(kumar) <- gp.f~gp
    kumar$id <- 1:400
    kumar$idc <- sample(100,400,TRUE)
    kumar$ids <- sample(400,400)
    kumar$id2 <- sample(400,400)
    kumar2 <- kumar[order(kumar$id2),]
    kumar$int <- interaction(kumar$gp,kumar$dnr)
    kumar2$int <- interaction(kumar2$gp,kumar2$dnr)
    clust <- 0

    b2 <- binregATE(Event(time,cause)~gp.f+dnr+preauto+ttt24,kumar2,cause=2,
        treat.model=gp.f~dnr+preauto+ttt24,time=40,cens.model=~strata(gp,dnr))
    summary(b2)
    #>    n events
    #>  400    144
    #>
    #>  400 clusters
    #> coeffients:
    #>              Estimate   Std.Err      2.5%     97.5% P-value
    #> (Intercept) -1.074326  0.214347 -1.494439 -0.654214  0.0000
    #> gp.f1        0.669400  0.259837  0.160129  1.178670  0.0100
    #> dnr          0.238437  0.263384 -0.277787  0.754661  0.3653
    #> preauto      0.587886  0.275985  0.046965  1.128806  0.0332
    #> ttt24        0.085280  0.275382 -0.454458  0.625018  0.7568
    #>
    #> exp(coeffients):
    #>             Estimate    2.5%  97.5%
    #> (Intercept)  0.34153 0.22437 0.5199
    #> gp.f1        1.95306 1.17366 3.2500
    #> dnr          1.26926 0.75746 2.1269
    #> preauto      1.80018 1.04809 3.0920
    #> ttt24        1.08902 0.63479 1.8683
    #>
    #> Average Treatment effects (G-formula) :
    #>            Estimate   Std.Err      2.5%     97.5% P-value
    #> treat0    -0.684331  0.183487 -1.043959 -0.324702  0.0002
    #> treat1    -0.014931  0.171518 -0.351101  0.321239  0.9306
    #> treat:1-0  0.669400  0.259837  0.160129  1.178670  0.0100
    #>
    #> Average Treatment effects (double robust) :
    #>           Estimate  Std.Err     2.5%    97.5% P-value
    #> treat0    0.317773 0.040256 0.238872 0.396673  0.0000
    #> treat1    0.496173 0.043239 0.411427 0.580920  0.0000
    #> treat:1-0 0.178401 0.058844 0.063068 0.293734  0.0024

    b5 <- binregATE(Event(time,cause)~int+preauto+ttt24,kumar,cause=2,
            treat.model=int~preauto+ttt24,cens.code=0,time=60)
    summary(b5)
    #>    n events
    #>  400    150
    #>
    #>  400 clusters
    #> coeffients:
    #>              Estimate   Std.Err      2.5%     97.5% P-value
    #> (Intercept) -1.067627  0.285570 -1.627333 -0.507921  0.0002
    #> int1.0       0.846566  0.320929  0.217557  1.475575  0.0083
    #> int0.1       0.619052  0.494731 -0.350604  1.588707  0.2108
    #> int1.1       0.896555  0.410239  0.092501  1.700609  0.0289
    #> preauto      0.373155  0.273876 -0.163631  0.909942  0.1730
    #> ttt24        0.468170  0.300260 -0.120328  1.056668  0.1189
    #>
    #> exp(coeffients):
    #>             Estimate    2.5%  97.5%
    #> (Intercept)  0.34382 0.19645 0.6017
    #> int1.0       2.33163 1.24304 4.3735
    #> int0.1       1.85717 0.70426 4.8974
    #> int1.1       2.45115 1.09691 5.4773
    #> preauto      1.45231 0.84906 2.4842
    #> ttt24        1.59707 0.88663 2.8768
    #>
    #> Average Treatment effects (G-formula) :
    #>                Estimate   Std.Err      2.5%     97.5% P-value
    #> treat0.0      -0.724432  0.269297 -1.252245 -0.196620  0.0071
    #> treat1.0       0.122134  0.173553 -0.218023  0.462290  0.4816
    #> treat0.1      -0.105381  0.420091 -0.928745  0.717983  0.8019
    #> treat1.1       0.172123  0.292009 -0.400204  0.744450  0.5556
    #> treat:1.0-0.0  0.846566  0.320929  0.217557  1.475575  0.0083
    #> treat:0.1-0.0  0.619052  0.494731 -0.350604  1.588707  0.2108
    #> treat:1.1-0.0  0.896555  0.410239  0.092501  1.700609  0.0289
    #> treat:0.1-1.0 -0.227514  0.462117 -1.133247  0.678219  0.6225
    #> treat:1.1-1.0  0.049989  0.342303 -0.620913  0.720891  0.8839
    #> treat:1.1-0.1  0.277504  0.515530 -0.732917  1.287924  0.5904
    #>
    #> Average Treatment effects (double robust) :
    #>                Estimate   Std.Err      2.5%     97.5% P-value
    #> treat0.0       0.354351  0.057164  0.242312  0.466391  0.0000
    #> treat1.0       0.464900  0.079669  0.308752  0.621048  0.0000
    #> treat0.1       0.597978  0.616708 -0.610748  1.806704  0.3322
    #> treat1.1       0.545436  0.637030 -0.703121  1.793992  0.3919
    #> treat:1.0-0.0  0.110549  0.097618 -0.080779  0.301876  0.2574
    #> treat:0.1-0.0  0.243627  0.624019 -0.979428  1.466681  0.6962
    #> treat:1.1-0.0  0.191084  0.642422 -1.068039  1.450207  0.7661
    #> treat:0.1-1.0  0.133078  0.629442 -1.100606  1.366762  0.8326
    #> treat:1.1-1.0  0.080536  0.625281 -1.144992  1.306064  0.8975
    #> treat:1.1-0.1 -0.052542  0.596654 -1.221962  1.116877  0.9298

We note that the estimates found using the large censoring model are very different from those using the simple Kaplan-Meier weights that are severely biased for these data. This is due to a stong censoring dependence.

The average treatment is around \(0.17 = E(Y(1) - Y(0))\) at time 60 for the transplant period, under the standard causal assumptions. The 1/0 treatment variable used for the causal computation is found as the right hand side (rhs) of the treat.model or as the first argument on the rhs of the response model.

# Average treatment effect for binary or continuous responses

In the binary case a binary outcome is specified instead of the survival outcome, and as a consequence no-censoring adjustment is done

- the binary/numeric outcome must be a variable in the data-frame

Running the code (can also use binregATE koding cause without censorings values, so setting cens.code=2, and time large)

    kumar$cause2 <- 1*(kumar$cause==2)

    b3 <- logitATE(cause2~gp.f+dnr+preauto+ttt24,kumar,treat.model=gp.f~dnr+preauto+ttt24)
    summary(b3)
    #>    n events
    #>  400    400
    #>
    #>  400 clusters
    #> coeffients:
    #>                Estimate     Std.Err        2.5%       97.5% P-value
    #> (Intercept) -1.07282963  0.19388190 -1.45283117 -0.69282808  0.0000
    #> gp.f1        0.26229718  0.23212023 -0.19265012  0.71724448  0.2585
    #> dnr          0.47162640  0.24030425  0.00063871  0.94261408  0.0497
    #> preauto      0.26934293  0.24156220 -0.20411028  0.74279614  0.2648
    #> ttt24        0.40066829  0.24437556 -0.07829902  0.87963559  0.1011
    #>
    #> exp(coeffients):
    #>             Estimate    2.5%  97.5%
    #> (Intercept)  0.34204 0.23391 0.5002
    #> gp.f1        1.29991 0.82477 2.0488
    #> dnr          1.60260 1.00064 2.5667
    #> preauto      1.30910 0.81537 2.1018
    #> ttt24        1.49282 0.92469 2.4100
    #>
    #> Average Treatment effects (G-formula) :
    #>           Estimate  Std.Err     2.5%    97.5% P-value
    #> treat0    -0.65978  0.17273 -0.99833 -0.32122  0.0001
    #> treat1    -0.39748  0.14485 -0.68139 -0.11357  0.0061
    #> treat:1-0  0.26230  0.23212 -0.19265  0.71724  0.2585
    #>
    #> Average Treatment effects (double robust) :
    #>            Estimate   Std.Err      2.5%     97.5% P-value
    #> treat0     0.340232  0.040085  0.261667  0.418798   0.000
    #> treat1     0.398325  0.034951  0.329823  0.466828   0.000
    #> treat:1-0  0.058093  0.052008 -0.043842  0.160027   0.264

    ###library(targeted)
    ###b3a <- ate(cause2~gp.f|dnr+preauto+ttt24| dnr+preauto+ttt24,kumar,family=binomial)
    ###summary(b3a)

    ## calculate also relative risk
    estimate(coef=b3$riskDR,vcov=b3$var.riskDR,f=function(p) p[1]/p[2])
    #>        Estimate Std.Err   2.5% 97.5%   P-value
    #> treat0   0.8542  0.1228 0.6135 1.095 3.506e-12

Or with continuous response using normal estimating equations

    b3 <- normalATE(time~gp.f+dnr+preauto+ttt24,kumar,treat.model=gp.f~dnr+preauto+ttt24)
    summary(b3)
    #>    n events
    #>  400    400
    #>
    #>  400 clusters
    #> coeffients:
    #>              Estimate   Std.Err      2.5%     97.5% P-value
    #> (Intercept)  27.80015   3.30304  21.32631  34.27399  0.0000
    #> gp.f1       -16.06100   3.25515 -22.44098  -9.68102  0.0000
    #> dnr          -6.51649   3.16550 -12.72075  -0.31223  0.0395
    #> preauto       1.66745   2.93033  -4.07590   7.41080  0.5693
    #> ttt24        -1.12151   3.27807  -7.54640   5.30338  0.7323
    #>
    #>
    #> Average Treatment effects (G-formula) :
    #>           Estimate  Std.Err     2.5%    97.5% P-value
    #> treat0     26.2456   2.9998  20.3660  32.1251       0
    #> treat1     10.1846   1.0464   8.1336  12.2355       0
    #> treat:1-0 -16.0610   3.2552 -22.4410  -9.6810       0
    #>
    #> Average Treatment effects (double robust) :
    #>           Estimate  Std.Err     2.5%    97.5% P-value
    #> treat0     28.0289   3.2124  21.7328  34.3251       0
    #> treat1     10.7094   1.0007   8.7481  12.6707       0
    #> treat:1-0 -17.3195   3.3652 -23.9153 -10.7238       0

# SessionInfo

    sessionInfo()
    #> R version 4.5.1 (2025-06-13)
    #> Platform: aarch64-apple-darwin24.5.0
    #> Running under: macOS Sequoia 15.6.1
    #>
    #> Matrix products: default
    #> BLAS:   /Users/kkzh/.asdf/installs/R/4.5.1/lib/R/lib/libRblas.dylib
    #> LAPACK: /Users/kkzh/.asdf/installs/R/4.5.1/lib/R/lib/libRlapack.dylib;  LAPACK version 3.12.1
    #>
    #> locale:
    #> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
    #>
    #> time zone: Europe/Copenhagen
    #> tzcode source: internal
    #>
    #> attached base packages:
    #> [1] stats     graphics  grDevices utils     datasets  methods   base
    #>
    #> other attached packages:
    #> [1] timereg_2.0.7  survival_3.8-3 mets_1.3.7
    #>
    #> loaded via a namespace (and not attached):
    #>  [1] cli_3.6.5           knitr_1.50          rlang_1.1.6
    #>  [4] xfun_0.53           jsonlite_2.0.0      future.apply_1.20.0
    #>  [7] listenv_0.9.1       lava_1.8.1          htmltools_0.5.8.1
    #> [10] sass_0.4.10         rmarkdown_2.29      grid_4.5.1
    #> [13] evaluate_1.0.5      jquerylib_0.1.4     fastmap_1.2.0
    #> [16] numDeriv_2016.8-1.1 yaml_2.3.10         mvtnorm_1.3-3
    #> [19] lifecycle_1.0.4     compiler_4.5.1      codetools_0.2-20
    #> [22] ucminf_1.2.2        Rcpp_1.1.0          future_1.67.0
    #> [25] lattice_0.22-7      digest_0.6.37       R6_2.6.1
    #> [28] parallelly_1.45.1   parallel_4.5.1      splines_4.5.1
    #> [31] Matrix_1.7-4        bslib_0.9.0         tools_4.5.1
    #> [34] globals_0.18.0      cachem_1.1.0