weight.calculate.ps | R Documentation |
This function calculates the IPW for ATE as Tr/ps + (1-Tr)/(1-ps), where Tr is the treatment indicator and ps is the propensity score.
weight.calculate.ps(Z, ps, standardize = TRUE)
Z |
The binary treatment indicator. A vector with 2 unique numeric values in 0 = untreated and 1 = treated. |
ps |
The propensity score used to calculate the IPW weight. A vector with numeric values greater than 0 and less than 1. The length of "ps" should equal to the length of "Z". |
standardize |
If standardize the calculated IPW or not. When standardize = FALSE, the weights are calculated by the IPW definition shown in the description. standardize = TRUE by default, which makes the the sum of weights be 1 in the untreated/treated group. |
A list containing the following components:
"weight": The IPW weights calculated by the input propensity score
"ps": The input propensity score
KS = Kang_Schafer_Simulation(n = 1000, seeds = 5050) tr = KS$Data[,2] true.ps = KS$Data[,11] true.w = weight.calculate.ps(Z = tr, ps = true.ps, standardize = TRUE) summary(true.w$weight) c(sum(true.w$weight[which(tr==0)]), sum(true.w$weight[which(tr==1)]))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.