Closed VT-iancrandell closed 3 years ago
My apologies for the ambiguous notation. n_t means the number of treated units (t for treated, as opposed to c for control). In the paper, it is written as n_1.
Ah I understand now, thank you. Now we have that the weights for the untreated are (n / n_t)*(- pi/ (1 - pi)), which agrees with the output excepting the minus sign. Thank you very much!
Good afternoon,
I was going over the CBPS function and trying to recreate the output by hand, and I came across what appears to be a discrepancy. I wanted to make sure that I'm understanding things properly.
See the weights section in the documentation for CBPS:
weights: Let π_i = f(T_i | X_i). For binary ATT, these are given by n/n_t * (T_i - π_i)/(1 - π_i).
I'm assuming π_i is the ith entry in the $fitted.value and n_t is the sample size for the t^th group. In the code below I produce wAsInDoc, which is my interpretation of the weight formula following the documentation but which does not equal the weights output from cbps. wMatchingOutput is a modified version of that which matches the weights returned by CBPS. n, t0, and t1 are the sample sizes overall and by treatment group for the lalonde data. The difference is coming from the minus sign in the numerator as well as a difference in scaling factor of n/t0 vs n/t1.
Am I misinterpreting the documentation, or is there something else going on? Thank you for your time.
` library(CBPS) cbpsLm = CBPS(treat ~ age + educ + race + married, data = lalonde, method = "over", ATT = 1, standardize = FALSE) n = 429 + 185; t0 = 429; t1 = 185
pi = cbpsLm$fitted.values
wAsInDoc = ifelse(lalonde$treat == 0, (n / t0)(- pi/ (1 - pi)), n / t1) wMatchingOutput = ifelse(lalonde$treat == 0, (n / t1)(pi / (1 - pi)), n / t1)
tdat = data.frame(treat = lalonde$treat, pi = cbpsLm$fitted.values, w = cbpsLm$weights, wAsInDoc, wMatchingOutput)
head(tdat) tail(tdat) `