R/causal_multiple_treatment.R

Defines functions causal_multiple_treatment

Documented in causal_multiple_treatment

#' Estimation of Causal Effects of Multiple Treatments with a Binary Outcome
#'
#' @param y y is a numeric vector for the binary outcome
#' @param x x is a dataframe including the treatment indicator and the covariates
#' @param trt trt is a numeric vector for the treatment indicator
#' @param method method is the potential methods for causal inference with multiple treatments. In the package, we incorporate regression adjustment, vector matching, inverse probability of treatment weighting and Bayesian Additive Regression Trees.
#' @param discard Whether to use discarding rules for BART
#' @param estimand Whether the focus is on ATT effect or ATE effect
#'
#' @return list with the 2 elements for ATT or 3 elements for ATE. Nested within each list, it contains the results for ATE/ATT with the rows indicating Risk Difference/Risk Ratio/Odds Ratio and columns showing estimation.
#'
#' @export causal_multiple_treatment
#'
#' @examples
causal_multiple_treatment <- function(y = y, x = idata$trtdat, trt = trt_ind, method, discard, estimand){
  if (method == "Regression Adjustment" && estimand == "ATE") {
    result <- regadj_multiTrt(
      y = y,
      x = idata$trtdat,
      trt = trt_ind,
      estimand = "ATE"
    )
  } else if (method == "Regression Adjustment" && estimand == "ATT"){
    result <- regadj_multiTrt(
      y = y,
      x = idata$trtdat,
      trt = trt_ind,
      estimand = "ATT"
    )
  } else if (method == "VM Matching" && estimand == "ATT") {
    result <- vm_multiTrt_att(y = y, x = idata$trtdat, trt = trt_ind)
  } else if (method == "BART" && estimand == "ATE" && discard == FALSE){
    result <- bart_multiTrt(
      y = y,
      x = idata$trtdat,
      trt = trt_ind,
      estimand = "ATE",
      discard = FALSE
    )
  } else if (method == "BART" && estimand == "ATE" && discard == TRUE){
    result <- bart_multiTrt(
      y = y,
      x = idata$trtdat,
      trt = trt_ind,
      estimand = "ATE",
      discard = TRUE
    )
  } else if (method == "BART" && estimand == "ATT" && discard == FALSE){
    result <- bart_multiTrt(
      y = y,
      x = idata$trtdat,
      trt = trt_ind,
      estimand = "ATT",
      discard = FALSE
    )
  } else if (method == "BART" && estimand == "ATT" && discard == TRUE){
    result <- bart_multiTrt(
      y = y,
      x = idata$trtdat,
      trt = trt_ind,
      estimand = "ATT",
      discard = TRUE
    )
  } else if (method == "IPTW-Logistics" && estimand == "ATT" ){
    result <- iptw_multiTrt(
      y = y,
      trt_ind = trt_ind,
      psdat = idata$trtdat,
      estimand = "ATT",
      method
    )
  } else if (method == "IPTW-Logistics-Trim" && estimand == "ATT" ){
    result <- iptw_multiTrt(
      y = y,
      trt_ind = trt_ind,
      psdat = idata$trtdat,
      estimand = "ATT",
      method
    )
  } else if (method == "IPTW-GBM" && estimand == "ATT" ){
    result <- iptw_multiTrt(
      y = y,
      trt_ind = trt_ind,
      psdat = idata$trtdat,
      estimand = "ATT",
      method
    )
  } else if (method == "IPTW-GBM-Trim" && estimand == "ATT" ){
    result <- iptw_multiTrt(
      y = y,
      trt_ind = trt_ind,
      psdat = idata$trtdat,
      estimand = "ATT",
      method
    )
  } else if (method == "IPTW-Logistics" && estimand == "ATE" ){
    result <- iptw_multiTrt(
      y = y,
      trt_ind = trt_ind,
      psdat = idata$trtdat,
      estimand = "ATE",
      method
    )
  } else if (method == "IPTW-Logistics-Trim" && estimand == "ATE" ){
    result <- iptw_multiTrt(
      y = y,
      trt_ind = trt_ind,
      psdat = idata$trtdat,
      estimand = "ATE",
      method
    )
  } else if (method == "IPTW-GBM" && estimand == "ATE" ){
    result <- iptw_multiTrt(
      y = y,
      trt_ind = trt_ind,
      psdat = idata$trtdat,
      estimand = "ATE",
      method
    )
  } else if (method == "IPTW-GBM-Trim" && estimand == "ATE" ){
    result <- iptw_multiTrt(
      y = y,
      trt_ind = trt_ind,
      psdat = idata$trtdat,
      estimand = "ATE",
      method
    )
  }
  return(result)
}
JiayiJi/causal.multiple.treatments documentation built on Nov. 14, 2019, 7:46 p.m.