What is the exact formula how the CBPS package calculated the weights? I am currently working with the CBPS package to estimate propensity scores. However, I am wondering about the weights, the package creates. The balance plot with incorporated weights looks great, but I want to compare it to weighted propensity scores from other packages and therefore need to understand the whole formula. In the help section it is given as
$$\dfrac{n}{n_t} \dfrac{(T_i - \pi_i)}{(1 - \pi_i)}$$
for binary treatment ATT estimation. The last part of the formula is similar to the ATT IPW formula, but I don't know what the first part $\left(\dfrac{n}{n_t}\right)$ is. I tried to calculate the weights myself by multiplying the inversed fitted values from the model with the sampling weights, but it does not result in the same values as the package weights.
Has anyone ideas what this term could stand for or experiences with the package?
 A: Typically, for the ATT, the weights $\omega$ are 1 for treated units and $\frac{\pi_i}{1-\pi_i}$ for control units. The weights $\omega^*$ resulting from CBPS() with standardize = FALSE are $\frac{N}{N_1}$ for treated units and $\frac{N}{N_1}\frac{\pi_i}{1-\pi_i}$ for control units; that is, $\omega^* \equiv \frac{N}{N1}\omega$, where $N$ is the total sample size and $N_1$ is the number of treated units (i.e., with $T_i=1$). These weights differ from the weights $w_\beta(T_i, X_i)$ described in Imai and Ratkovic (2014) (IR14), which are used in the CBPS algorithm to specify the balance constraints in the generalized method of moments (GMM) estimator. The documentation for CBPS() is wrong because it gives the formula for $w_\beta(T_i, X_i)$ in the description of the output of CBPS(), when in reality what is produced is $\omega^*$ (which, to be fair, is almost the same as $w_\beta(T_i, X_i)$ except that the sign is reversed for control units).
The reason IR14 use $w_\beta(T_i, X_i)$ is because one can write the moments constraints in the GMM estimator as
$$\frac{1}{N} \sum\limits_{i=1}^N w_\beta(T_i, X_i)X = 0$$
Typically, we think of the balance constraints instead as the weighted difference in covariate means between the treatment groups, which we would instead write as
$$\frac{\sum\limits_{i=1}^N A_i\omega_i X_i}{\sum\limits_{i=1}^N A_i\omega_i} - \frac{\sum\limits_{i=1}^N (1-A_i)\omega_i X_i}{\sum\limits_{i=1}^N (1-A_i)\omega_i} = 0$$
We know that for ATT weights, $\omega=1$ for treated units. It's also the case that the sum of the control unit ATT weights is (approximately) equal to the number of treated units. That is, $\sum A\omega = \sum (1-A)\omega = N_1$, so we can rewrite the balance constraint as
$$\frac{1}{N_1}\sum\limits_{i=1}^N A_i\omega_i X_i - \frac{1}{N_1} \sum\limits_{i=1}^N(1-A_i)\omega_i X_i = 0$$
which we can further simplify as
$$\frac{1}{N_1}\sum\limits_{i=1}^N (A_i-(1-A_i))\omega_i X_i = 0$$
If we multiply the $\frac{1}{N_1}$ by $\frac{N_1}{N}$ and the summand by $\frac{N}{N_1}$ (which is equivalent to multiplying the whole thing by $1$), we can rewrite this as
$$\frac{1}{N}\sum\limits_{i=1}^N (A_i-(1-A_i))\frac{N}{N_1}\omega_i X_i = 0$$
Substituing in $\omega_i^* = \frac{N}{N_1}\omega_i$, we get
$$\frac{1}{N}\sum\limits_{i=1}^N (A_i-(1-A_i))\omega_i^* X_i = 0$$
and substituting $w_\beta(T_i, X_i)$ for $(A_i-(1-A_i))\omega_i^*$ (since $w_\beta(T_i, X_i)$ is just $\omega_i^*$ with the sign flipped for the control units, which is what multiplying it by $(A_i-(1-A_i))$ does), we finally arrive at the GMM moments constraint
$$\frac{1}{N} \sum\limits_{i=1}^N w_\beta(T_i, X_i)X = 0$$
So, to recap, the traditional ATT weights $\omega$ can be multiplied by the scaling factor $\frac{N}{N_1}$ to get $\omega^*$. The sign of $\omega^*$ can be flipped for the control units to get $w_\beta(T_i, X_i)$. The CBPS() documentation claims the weights produced by CBPS() are $w_\beta(T_i, X_i)$, when in actuality they are $\omega^*$, which makes it easier to estimate treatment effects using the weights in the normal way (i.e., because $\omega^*$ behave more like the ATT weights $\omega$). $\omega^*$ bridge the ATT weights with the GMM moments constraints. Balance statistics and the estimated treatment effect do not depend on whether $\omega$ or $\omega^*$ are used; in most cases they are invariant to scaling factors applied to the weights.
Producing $\omega^*$ instead of $\omega$ is a strange convention and leads to reasonable confusion like yours. I recommend computing the ATT weights by hand using the estimated propensity scores and the standard ATT formula. This will make it easier to compare with other weighting methods that estimate propensity scores. This is the approach used in the WeightIt package, which was designed to facilitate comparisons between several weighting methods, including CBPS.
