doPS | R Documentation |
doPS
calculates the unstabilized and stabilized inverse probability treatment weights (IPW) for average treatment effect using propensity score. The propensity score is calculated by twang
package using the boosted logistic regression.
doPS(data,Trt,Trt.name,VARS.,logistic = FALSE,w=NULL)
data |
The dataset, includes treatment assignment as well as covariates. |
Trt |
The name of the treatment variable in the dataset. |
Trt.name |
The treated group name of the treatment variable in the dataset. |
VARS. |
The vector of the name of potential confounding variables in the dataset. |
logistic |
A logical value indicating whether use logistic regression (TRUE) or non-parametric boosted tree (FALSE). |
w |
Optional sampling weights. |
The treatment variable should only contain 2 levels of treatment, and one should be viewed as treated group and another is control group.
For stabilized weights:
For the treated individuals, we assign the IPW: w = Pr(T=1)/Pr(T=1|X=x), for control individuals, the stabilized weight is: w = (1-Pr(T=1))/(1-Pr(T=1|X=x)).
doPS returns an object of class "PS". An object of class "PS" is a list containing the following components:
Data |
A new dataset which excludes all the missing value on the potential confounders from input data, add the propensity score and IPW into the new dataset.
|
ps |
an object of class |
ps
n <- 500 set.seed(1234) Cens = runif(n,0.7,0.9) set.seed(1234) OUT1 <- sim_cox_msm_semicmrsk(beta1 = 1,beta2 = 1,beta3 = 0.5, sigma_2 = 1, alpha0 = 0.5, alpha1 = 0.1, alpha2 = -0.1, alpha3 = -0.2, n=n, Cens = Cens) data_test <- OUT1$data0 ## Get the PS weights vars <- c("Z1","Z2","Z3") ps1 <- doPS(data = data_test, Trt = "A", Trt.name = 1, VARS. = vars, logistic = TRUE,w=NULL) w <- ps1$Data$ipw_ate_stab
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.