causal.multiple.treatments
The goal of causal.multiple.treatments is to
You can install the latest version directly from GitHub with devtools:
install.packages("devtools")
devtools::install_github("JiayiJi/causal.multiple.treatments")
We generated the data under scenario 1 in the paper.
library(causal.multiple.treatments)
set.seed(3242019)
idata = data_gen(n = 1200, ratio =1)
trt_ind <- as.numeric(idata$trtdat$trt_ind)
all_vars <- idata$trtdat[, -1] #exclude treatment indicator
y <- idata$Yobs
causal_multiple_treatment(y = y, x = idata$trtdat, trt = trt_ind, method ="Regression Adjustment", estimand = "ATE")
## $ATE12
## EST SE LOWER UPPER
## RD -0.026 0.023 -0.073 0.019
## RR 0.918 0.071 0.782 1.060
## OR 0.887 0.099 0.706 1.090
##
## $ATE13
## EST SE LOWER UPPER
## RD -0.054 0.037 -0.124 0.019
## RR 0.850 0.099 0.675 1.060
## OR 0.792 0.136 0.563 1.091
##
## $ATE23
## EST SE LOWER UPPER
## RD -0.027 0.025 -0.074 0.023
## RR 0.925 0.069 0.796 1.073
## OR 0.891 0.100 0.713 1.109
causal_multiple_treatment(y = y, x = idata$trtdat, trt = trt_ind, method ="Regression Adjustment", estimand = "ATT")
## $ATT12
## EST SE LOWER UPPER
## RD -0.027 0.035 -0.094 0.043
## RR 0.920 0.109 0.721 1.142
## OR 0.892 0.151 0.631 1.211
##
## $ATT13
## EST SE LOWER UPPER
## RD -0.054 0.047 -0.151 0.033
## RR 0.852 0.126 0.619 1.122
## OR 0.798 0.174 0.502 1.176
causal_multiple_treatment(y = y, x = idata$trtdat, trt = trt_ind, method = "VM Matching", estimand = "ATT")
## $ATT12
## EST
## RD -0.08496732
## RR 0.77966102
## OR 0.68493585
##
## $ATT13
## EST
## RD 0.0620915
## RR 1.2602740
## OR 1.3721675
causal_multiple_treatment(y = y, x = idata$trtdat, trt = trt_ind, method = "BART", estimand = "ATE", discard = TRUE)
## *****Into main of pbart
## *****Data:
## data:n,p,np: 1200, 11, 0
## y1,yn: 0, 1
## x1,x[n*p]: 2.000000, 0.000000
## *****Number of Trees: 100
## *****Number of Cut Points: 2 ... 2
## *****burn and ndpost: 1000, 1000
## *****Prior:mybeta,alpha,tau: 2.000000,0.950000,0.150000
## *****binaryOffset: -0.470030
## *****Dirichlet:sparse,theta,omega,a,b,rho,augment: 0,0,1,0.5,1,11,0
## *****nkeeptrain,nkeeptest,nkeeptreedraws: 1000,1000,1000
## *****printevery: 100
## *****skiptr,skipte,skiptreedraws: 1,1,1
##
## MCMC
## done 0 (out of 2000)
## done 100 (out of 2000)
## done 200 (out of 2000)
## done 300 (out of 2000)
## done 400 (out of 2000)
## done 500 (out of 2000)
## done 600 (out of 2000)
## done 700 (out of 2000)
## done 800 (out of 2000)
## done 900 (out of 2000)
## done 1000 (out of 2000)
## done 1100 (out of 2000)
## done 1200 (out of 2000)
## done 1300 (out of 2000)
## done 1400 (out of 2000)
## done 1500 (out of 2000)
## done 1600 (out of 2000)
## done 1700 (out of 2000)
## done 1800 (out of 2000)
## done 1900 (out of 2000)
## time: 8s
## check counts
## trcnt,tecnt: 1000,0
## *****In main of C++ for bart prediction
## tc (threadcount): 1
## number of bart draws: 1000
## number of trees in bart sum: 100
## number of x columns: 11
## from x,np,p: 11, 392
## ***using serial code
## *****In main of C++ for bart prediction
## tc (threadcount): 1
## number of bart draws: 1000
## number of trees in bart sum: 100
## number of x columns: 11
## from x,np,p: 11, 392
## ***using serial code
## *****In main of C++ for bart prediction
## tc (threadcount): 1
## number of bart draws: 1000
## number of trees in bart sum: 100
## number of x columns: 11
## from x,np,p: 11, 392
## ***using serial code
## *****In main of C++ for bart prediction
## tc (threadcount): 1
## number of bart draws: 1000
## number of trees in bart sum: 100
## number of x columns: 11
## from x,np,p: 11, 398
## ***using serial code
## *****In main of C++ for bart prediction
## tc (threadcount): 1
## number of bart draws: 1000
## number of trees in bart sum: 100
## number of x columns: 11
## from x,np,p: 11, 398
## ***using serial code
## *****In main of C++ for bart prediction
## tc (threadcount): 1
## number of bart draws: 1000
## number of trees in bart sum: 100
## number of x columns: 11
## from x,np,p: 11, 398
## ***using serial code
## *****In main of C++ for bart prediction
## tc (threadcount): 1
## number of bart draws: 1000
## number of trees in bart sum: 100
## number of x columns: 11
## from x,np,p: 11, 410
## ***using serial code
## *****In main of C++ for bart prediction
## tc (threadcount): 1
## number of bart draws: 1000
## number of trees in bart sum: 100
## number of x columns: 11
## from x,np,p: 11, 410
## ***using serial code
## *****In main of C++ for bart prediction
## tc (threadcount): 1
## number of bart draws: 1000
## number of trees in bart sum: 100
## number of x columns: 11
## from x,np,p: 11, 410
## ***using serial code
## $ATE12
## EST SE LOWER UPPER
## RD 0.002 0.034 -0.064 0.072
## RR 1.008 0.084 0.855 1.191
## OR 1.018 0.145 0.766 1.342
##
## $ATE13
## EST SE LOWER UPPER
## RD -0.061 0.037 -0.137 0.008
## RR 0.875 0.071 0.736 1.020
## OR 0.790 0.117 0.575 1.035
##
## $ATE23
## EST SE LOWER UPPER
## RD -0.063 0.040 -0.144 0.008
## RR 0.872 0.077 0.724 1.018
## OR 0.785 0.125 0.554 1.031
causal_multiple_treatment(y = y, x = idata$trtdat, trt = trt_ind, method = "BART", estimand = "ATE", discard = FALSE)
## *****Into main of pbart
## *****Data:
## data:n,p,np: 1200, 11, 0
## y1,yn: 0, 1
## x1,x[n*p]: 2.000000, 0.000000
## *****Number of Trees: 100
## *****Number of Cut Points: 2 ... 2
## *****burn and ndpost: 1000, 1000
## *****Prior:mybeta,alpha,tau: 2.000000,0.950000,0.150000
## *****binaryOffset: -0.470030
## *****Dirichlet:sparse,theta,omega,a,b,rho,augment: 0,0,1,0.5,1,11,0
## *****nkeeptrain,nkeeptest,nkeeptreedraws: 1000,1000,1000
## *****printevery: 100
## *****skiptr,skipte,skiptreedraws: 1,1,1
##
## MCMC
## done 0 (out of 2000)
## done 100 (out of 2000)
## done 200 (out of 2000)
## done 300 (out of 2000)
## done 400 (out of 2000)
## done 500 (out of 2000)
## done 600 (out of 2000)
## done 700 (out of 2000)
## done 800 (out of 2000)
## done 900 (out of 2000)
## done 1000 (out of 2000)
## done 1100 (out of 2000)
## done 1200 (out of 2000)
## done 1300 (out of 2000)
## done 1400 (out of 2000)
## done 1500 (out of 2000)
## done 1600 (out of 2000)
## done 1700 (out of 2000)
## done 1800 (out of 2000)
## done 1900 (out of 2000)
## time: 8s
## check counts
## trcnt,tecnt: 1000,0
## *****In main of C++ for bart prediction
## tc (threadcount): 1
## number of bart draws: 1000
## number of trees in bart sum: 100
## number of x columns: 11
## from x,np,p: 11, 392
## ***using serial code
## *****In main of C++ for bart prediction
## tc (threadcount): 1
## number of bart draws: 1000
## number of trees in bart sum: 100
## number of x columns: 11
## from x,np,p: 11, 392
## ***using serial code
## *****In main of C++ for bart prediction
## tc (threadcount): 1
## number of bart draws: 1000
## number of trees in bart sum: 100
## number of x columns: 11
## from x,np,p: 11, 392
## ***using serial code
## *****In main of C++ for bart prediction
## tc (threadcount): 1
## number of bart draws: 1000
## number of trees in bart sum: 100
## number of x columns: 11
## from x,np,p: 11, 398
## ***using serial code
## *****In main of C++ for bart prediction
## tc (threadcount): 1
## number of bart draws: 1000
## number of trees in bart sum: 100
## number of x columns: 11
## from x,np,p: 11, 398
## ***using serial code
## *****In main of C++ for bart prediction
## tc (threadcount): 1
## number of bart draws: 1000
## number of trees in bart sum: 100
## number of x columns: 11
## from x,np,p: 11, 398
## ***using serial code
## *****In main of C++ for bart prediction
## tc (threadcount): 1
## number of bart draws: 1000
## number of trees in bart sum: 100
## number of x columns: 11
## from x,np,p: 11, 410
## ***using serial code
## *****In main of C++ for bart prediction
## tc (threadcount): 1
## number of bart draws: 1000
## number of trees in bart sum: 100
## number of x columns: 11
## from x,np,p: 11, 410
## ***using serial code
## *****In main of C++ for bart prediction
## tc (threadcount): 1
## number of bart draws: 1000
## number of trees in bart sum: 100
## number of x columns: 11
## from x,np,p: 11, 410
## ***using serial code
## $ATE12
## EST SE LOWER UPPER
## RD -0.002 0.034 -0.070 0.066
## RR 1.000 0.083 0.844 1.177
## OR 1.004 0.143 0.749 1.314
##
## $ATE13
## EST SE LOWER UPPER
## RD -0.055 0.036 -0.124 0.009
## RR 0.885 0.071 0.754 1.021
## OR 0.807 0.116 0.603 1.038
##
## $ATE23
## EST SE LOWER UPPER
## RD -0.054 0.040 -0.129 0.022
## RR 0.889 0.081 0.742 1.051
## OR 0.814 0.134 0.589 1.095
causal_multiple_treatment(y = y, x = idata$trtdat, trt = trt_ind, method = "BART", estimand = "ATT", discard = TRUE)
## *****Into main of pbart
## *****Data:
## data:n,p,np: 1200, 11, 0
## y1,yn: 0, 1
## x1,x[n*p]: 2.000000, 0.000000
## *****Number of Trees: 100
## *****Number of Cut Points: 2 ... 2
## *****burn and ndpost: 1000, 1000
## *****Prior:mybeta,alpha,tau: 2.000000,0.950000,0.150000
## *****binaryOffset: -0.470030
## *****Dirichlet:sparse,theta,omega,a,b,rho,augment: 0,0,1,0.5,1,11,0
## *****nkeeptrain,nkeeptest,nkeeptreedraws: 1000,1000,1000
## *****printevery: 100
## *****skiptr,skipte,skiptreedraws: 1,1,1
##
## MCMC
## done 0 (out of 2000)
## done 100 (out of 2000)
## done 200 (out of 2000)
## done 300 (out of 2000)
## done 400 (out of 2000)
## done 500 (out of 2000)
## done 600 (out of 2000)
## done 700 (out of 2000)
## done 800 (out of 2000)
## done 900 (out of 2000)
## done 1000 (out of 2000)
## done 1100 (out of 2000)
## done 1200 (out of 2000)
## done 1300 (out of 2000)
## done 1400 (out of 2000)
## done 1500 (out of 2000)
## done 1600 (out of 2000)
## done 1700 (out of 2000)
## done 1800 (out of 2000)
## done 1900 (out of 2000)
## time: 9s
## check counts
## trcnt,tecnt: 1000,0
## *****In main of C++ for bart prediction
## tc (threadcount): 1
## number of bart draws: 1000
## number of trees in bart sum: 100
## number of x columns: 11
## from x,np,p: 11, 392
## ***using serial code
## *****In main of C++ for bart prediction
## tc (threadcount): 1
## number of bart draws: 1000
## number of trees in bart sum: 100
## number of x columns: 11
## from x,np,p: 11, 392
## ***using serial code
## *****In main of C++ for bart prediction
## tc (threadcount): 1
## number of bart draws: 1000
## number of trees in bart sum: 100
## number of x columns: 11
## from x,np,p: 11, 392
## ***using serial code
## $ATT12
## EST SE LOWER UPPER
## RD 0.003 0.032 -0.061 0.061
## RR 1.014 0.102 0.824 1.212
## OR 1.024 0.151 0.753 1.323
##
## $ATT13
## EST SE LOWER UPPER
## RD -0.133 0.033 -0.199 -0.071
## RR 0.706 0.063 0.589 0.833
## OR 0.571 0.081 0.428 0.741
causal_multiple_treatment(y = y, x = idata$trtdat, trt = trt_ind, method = "BART", estimand = "ATT", discard = FALSE)
## *****Into main of pbart
## *****Data:
## data:n,p,np: 1200, 11, 0
## y1,yn: 0, 1
## x1,x[n*p]: 2.000000, 0.000000
## *****Number of Trees: 100
## *****Number of Cut Points: 2 ... 2
## *****burn and ndpost: 1000, 1000
## *****Prior:mybeta,alpha,tau: 2.000000,0.950000,0.150000
## *****binaryOffset: -0.470030
## *****Dirichlet:sparse,theta,omega,a,b,rho,augment: 0,0,1,0.5,1,11,0
## *****nkeeptrain,nkeeptest,nkeeptreedraws: 1000,1000,1000
## *****printevery: 100
## *****skiptr,skipte,skiptreedraws: 1,1,1
##
## MCMC
## done 0 (out of 2000)
## done 100 (out of 2000)
## done 200 (out of 2000)
## done 300 (out of 2000)
## done 400 (out of 2000)
## done 500 (out of 2000)
## done 600 (out of 2000)
## done 700 (out of 2000)
## done 800 (out of 2000)
## done 900 (out of 2000)
## done 1000 (out of 2000)
## done 1100 (out of 2000)
## done 1200 (out of 2000)
## done 1300 (out of 2000)
## done 1400 (out of 2000)
## done 1500 (out of 2000)
## done 1600 (out of 2000)
## done 1700 (out of 2000)
## done 1800 (out of 2000)
## done 1900 (out of 2000)
## time: 8s
## check counts
## trcnt,tecnt: 1000,0
## *****In main of C++ for bart prediction
## tc (threadcount): 1
## number of bart draws: 1000
## number of trees in bart sum: 100
## number of x columns: 11
## from x,np,p: 11, 392
## ***using serial code
## *****In main of C++ for bart prediction
## tc (threadcount): 1
## number of bart draws: 1000
## number of trees in bart sum: 100
## number of x columns: 11
## from x,np,p: 11, 392
## ***using serial code
## *****In main of C++ for bart prediction
## tc (threadcount): 1
## number of bart draws: 1000
## number of trees in bart sum: 100
## number of x columns: 11
## from x,np,p: 11, 392
## ***using serial code
## $ATT12
## EST SE LOWER UPPER
## RD -0.027 0.033 -0.092 0.038
## RR 0.926 0.093 0.757 1.117
## OR 0.895 0.133 0.658 1.185
##
## $ATT13
## EST SE LOWER UPPER
## RD -0.115 0.033 -0.184 -0.054
## RR 0.734 0.067 0.602 0.865
## OR 0.615 0.088 0.449 0.793
causal_multiple_treatment(y = y, x = idata$trtdat, trt = trt_ind, method = "IPTW-Logistics", estimand = "ATE")
## $ATE12
## EST
## RD 0.1157188
## RR 1.5143438
## OR 1.7801388
##
## $ATE13
## EST
## RD -0.0601762
## RR 0.8498891
## OR 0.7723171
##
## $ATE23
## EST
## RD -0.1758950
## RR 0.5612260
## OR 0.4338522
causal_multiple_treatment(y = y, x = idata$trtdat, trt = trt_ind, method = "IPTW-Logistics-Trim", estimand = "ATE")
## $ATE12
## EST
## RD 0.09896265
## RR 1.44063097
## OR 1.65139284
##
## $ATE13
## EST
## RD -0.07752048
## RR 0.80671882
## OR 0.71426888
##
## $ATE23
## EST
## RD -0.1764831
## RR 0.5599760
## OR 0.4325251
causal_multiple_treatment(y = y, x = idata$trtdat, trt = trt_ind, method = "IPTW-GBM", estimand = "ATE")
## $ATE12
## EST
## RD 0.06451888
## RR 1.26600925
## OR 1.38388642
##
## $ATE13
## EST
## RD -0.1142297
## RR 0.7288588
## OR 0.6087075
##
## $ATE23
## EST
## RD -0.1787486
## RR 0.5757137
## OR 0.4398537
causal_multiple_treatment(y = y, x = idata$trtdat, trt = trt_ind, method = "IPTW-GBM-Trim", estimand = "ATE")
## $ATE12
## EST
## RD 0.06695134
## RR 1.27088358
## OR 1.39493759
##
## $ATE13
## EST
## RD -0.1087382
## RR 0.7428436
## OR 0.6250761
##
## $ATE23
## EST
## RD -0.1756896
## RR 0.5845096
## OR 0.4481033
causal_multiple_treatment(y = y, x = idata$trtdat, trt = trt_ind, method = "IPTW-Logistics", estimand = "ATT")
## $ATT12
## EST
## RD 0.03958638
## RR 1.14995689
## OR 1.21532271
##
## $ATT13
## EST
## RD -0.1299691
## RR 0.7002146
## OR 0.5695390
causal_multiple_treatment(y = y, x = idata$trtdat, trt = trt_ind, method = "IPTW-Logistics-Trim", estimand = "ATT")
## $ATT12
## EST
## RD 0.04048331
## RR 1.15387738
## OR 1.22095214
##
## $ATT13
## EST
## RD -0.1302954
## RR 0.6996881
## OR 0.5687829
causal_multiple_treatment(y = y, x = idata$trtdat, trt = trt_ind, method = "IPTW-GBM", estimand = "ATT")
## $ATT12
## EST
## RD 0.002632855
## RR 1.008748811
## OR 1.012562395
##
## $ATT13
## EST
## RD -0.1247128
## RR 0.7088083
## OR 0.5818786
causal_multiple_treatment(y = y, x = idata$trtdat, trt = trt_ind, method = "IPTW-GBM-Trim", estimand = "ATT")
## $ATT12
## EST
## RD 0.01950579
## RR 1.06866651
## OR 1.09859806
##
## $ATT13
## EST
## RD -0.1215373
## RR 0.7141030
## OR 0.5894812
If you find small bugs, larger issues, or have suggestions, please file them using the issue tracker or email the maintainer at Jiayi.Ji@mountsinai.org. Contributions (via pull requests or otherwise) are welcome.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.