$$ 
\begin{aligned}
\mathbb{E}\left[\frac{1_{\hat{\pi}>0}}{\hat{\pi}} 1_{|\hat{\pi}-\pi|<\varepsilon}\right] &\le \frac{1}{\pi-\varepsilon}\mathbb{E}\left[1_{\hat{\pi}>0} 1_{|\hat{\pi}-\pi|<\varepsilon}\right] \\
&\le \frac{1}{\pi-\varepsilon},
\end{aligned}
$$

and for the second term,

$$ 
\begin{aligned}
\mathbb{E}\left[\frac{1_{\hat{\pi}>0}}{\hat{\pi}} 1_{|\hat{\pi}-\pi|\ge\varepsilon}\right] &\le n\mathbb{E}\left[1_{\hat{\pi}>0} 1_{|\hat{\pi}-\pi|\ge\varepsilon}\right] \\
&\le n\mathbb{P}\left(|\hat{\pi}-\pi| \ge \varepsilon\right) \\
&\le 2ne^{-2\varepsilon^2 n}.
\end{aligned}
$$

The last row is obtained through Chernoff's inequality in a similar manner as in the proof for the semi-oracle (see (36)). As a consequence, and gathering the two previous inequalities,

$$ 
\begin{aligned}
\mathbb{E}\left[\frac{1_{\hat{\pi}>0}}{\hat{\pi}}\right] &\le \frac{1}{\pi-\varepsilon} + 2ne^{-2\varepsilon^2 n} \\
&= \frac{1}{\pi}\frac{1}{1-\frac{\varepsilon}{\pi}} + 2ne^{-2\varepsilon^2 n}.
\end{aligned}
$$

One can show using function analysis, that, for all $0 \le x < \frac{1}{2}$, we have

$$ \frac{1}{1-x} \le 1 + \frac{x}{1-2x}. $$

Then, as soon as $\varepsilon$ is small enough, then $\frac{\varepsilon}{\pi} < \frac{1}{2}$, so that,

$$ 
\begin{aligned}
\mathbb{E}\left[\frac{1_{\hat{\pi}>0}}{\hat{\pi}}\right] &\le \frac{1}{\pi}\frac{1}{1-\frac{\varepsilon}{\pi}} + 2ne^{-2\varepsilon^2 n} \\
&\le \frac{1}{\pi}\left(1 + \frac{\frac{\varepsilon}{\pi}}{1-2\frac{\varepsilon}{\pi}}\right) + 2ne^{-2\varepsilon^2 n}.
\end{aligned}
$$

Letting $\varepsilon = \frac{\pi}{4}n^{-\alpha}$ with $\alpha \in (0, \frac{1}{2})$, we have

$$ \mathbb{E}\left[\frac{1_{\hat{\pi}>0}}{\hat{\pi}}\right] \le \frac{1}{\pi} + \frac{1}{4\pi}\frac{n^{-\alpha}}{1-\frac{n^{-\alpha}}{2}} + 2ne^{-\frac{\pi^2}{8}n^{1-2\alpha}} $$

Now, using the fact that

$$ \forall x \ge 1, \forall \alpha \in (0, \frac{1}{2}), \quad x^2 e^{-\frac{\pi^2}{8}x^{1-2\alpha}} \le \underbrace{\left(\frac{16}{\pi^2(1-2\alpha)}\right)^{\frac{2}{1-2\alpha}}}_{C_{\alpha,\pi}}, $$

allows to have

$$ 
\begin{aligned}
\mathbb{E}\left[\frac{1_{\hat{\pi}>0}}{\hat{\pi}}\right] &\le \frac{1}{\pi} + \frac{1}{4\pi}\frac{n^{-\alpha}}{1-\frac{n^{-\alpha}}{2}} + 2\frac{C_{\alpha,\pi}}{n} \\
&\le \frac{1}{\pi} + \frac{n^{-\alpha}}{\pi} + 2\frac{C_{\alpha,\pi}}{\pi n^{\alpha}} \\
&= \frac{1 + n^{-\alpha}(1+2C_{\alpha,\pi})}{\pi}.
\end{aligned}
$$

□

**Lemma 4 (Variance inequality).** Considering the Horvitz-Thomson estimator (Definition 1) and the difference-in-means estimator (Definition 2), with an internally valid randomized controlled trial of size n (Assumption 2), then asymptotic variance of the difference-in-means is always smaller or equal than the Horvitz-Thomson, such as

$$ V_{DM,\infty} = V_{HT} - \left( \sqrt{\frac{1-\pi}{\pi}} \mathbb{E}_R[Y^{(1)}] + \sqrt{\frac{\pi}{1-\pi}} \mathbb{E}_R[Y^{(0)}] \right)^2 \le V_{HT}. $$

In addition, and using the previous inequality, Lemma 2 and Lemma 3, one can bound the finite sample difference-in-means's variance:
$$
\begin{aligned}
\mathrm{Var}[\hat{\tau}_{\mathrm{DM},n}] &\le \frac{1}{n} \left( \frac{\mathrm{Var}[Y^{(1)}]}{\pi} + \frac{\mathrm{Var}[Y^{(0)}]}{1-\pi} \right) + \mathcal{O}(n^{-3/2}) \\
&\le V_{\mathrm{HT}} + \mathcal{O}(n^{-3/2}).
\end{aligned}
$$

Proof. Asymptotic inequality

Recall that,

$$
V_{HT} = \mathbb{E} \left[ \frac{(Y^{(1)})^2}{\pi} \right] + \mathbb{E} \left[ \frac{(Y^{(0)})^2}{1-\pi} \right] - \tau^2.
$$

Noting that,

$$
\tau^2 = (\mathbb{E}[Y^{(1)} - Y^{(0)}])^2 = \mathbb{E}[Y^{(1)}]^2 + \mathbb{E}[Y^{(0)}]^2 - 2\mathbb{E}[Y^{(1)}]\mathbb{E}[Y^{(0)}],
$$

and that for any $a \in \{0, 1\}$,

$$
\mathrm{Var}[Y^{(a)}] = \mathbb{E}\left[\left(Y^{(a)}\right)^2\right] - \mathbb{E}\left[Y^{(a)}\right]^2,
$$

allows to obtain,

$$
\begin{align*}
V_{HT} &= \frac{\mathrm{Var}[Y^{(1)}]}{\pi} + \frac{\mathrm{Var}[Y^{(0)}]}{1-\pi} - \left(1-\frac{1}{\pi}\right)\mathrm{E}[Y^{(1)}]^2 - \left(1-\frac{1}{1-\pi}\right)\mathrm{E}[Y^{(0)}]^2 + 2\mathrm{E}[Y^{(1)}]\mathrm{E}[Y^{(0)}] \\
&= V_{\mathrm{DM},\infty} + \left(\sqrt{\frac{1-\pi}{\pi}}\mathrm{E}_R[Y^{(1)}] + \sqrt{\frac{\pi}{1-\pi}}\mathrm{E}_R[Y^{(0)}]\right)^2.
\end{align*}
$$

Finite sample inequality

Recall the finite sample variance of the difference-in-means from Lemma 2, and using the inequality from Lemma 3,

$$
\begin{align*}
\mathrm{Var}[\hat{\tau}_{\mathrm{DM},n}] &= \mathbb{E}[Y_i^{(1)}]^2 (1-\pi)^n + \mathbb{E}[Y_i^{(0)}]^2 \pi^n - \left(\mathbb{E}[Y_i^{(1)}] (1-\pi)^n + \mathbb{E}[Y_i^{(0)}] \pi^n\right)^2 \\
&\quad + \frac{1}{n} \left(\mathbb{E}\left[\frac{1}{\hat{\pi}}\right] \mathrm{Var}[Y_i^{(1)}] + \mathbb{E}\left[\frac{1}{1-\hat{\pi}}\right] \mathrm{Var}[Y_i^{(0)}]\right) \\
&\le \mathbb{E}[Y_i^{(1)}]^2 (1-\pi)^n + \mathbb{E}[Y_i^{(0)}]^2 \pi^n - \left(\mathbb{E}[Y_i^{(1)}] (1-\pi)^n + \mathbb{E}[Y_i^{(0)}] \pi^n\right)^2 \\
&\quad + \frac{1}{n} \left(\frac{1+C_{1/4,\pi}n^{-\frac{1}{4}}}{\pi} \mathrm{Var}[Y_i^{(1)}] + \frac{1+C_{1/4,1-\pi}n^{-\frac{1}{4}}}{1-\pi} \mathrm{Var}[Y_i^{(0)}]\right),
\end{align*}
$$

where Lemma 3 is applied with $\alpha = 1/4$ and we recall that $C_{1/4,\pi} = 1 + 2 (\frac{32}{\pi^2})^4$. Note that, at this stage, it is
possible to write that,

$$
\mathrm{Var}[\hat{\tau}_{\mathrm{DM},n}] = \frac{1}{n} \left( \frac{\mathrm{Var}[Y^{(1)}]}{\pi} + \frac{\mathrm{Var}[Y^{(0)}]}{1-\pi} \right) + \mathcal{O}(n^{-3/2}). \quad (61)
$$

But the overall goal here is to compare $\mathrm{Var}[\hat{\tau}_{\mathrm{DM},n}]$ with $\mathrm{Var}[\hat{\tau}_{\mathrm{HT},n}]$.

$$
\begin{align*}
\mathrm{Var}[\hat{\tau}_{\mathrm{DM},n}] \le \mathrm{Var}[\hat{\tau}_{\mathrm{HT},n}] & - \frac{1}{n} \left( \sqrt{\frac{1-\pi}{\pi}} \mathbb{E}_R[Y^{(1)}] + \sqrt{\frac{\pi}{1-\pi}} \mathbb{E}_R[Y^{(0)}] \right) \\
& + \frac{1}{n} \left( \frac{C_{1/4,\pi} n^{-\frac{1}{4}}}{\pi} \mathrm{Var}[Y_i^{(1)}] + \frac{C_{1/4,1-\pi} n^{-\frac{1}{4}}}{1-\pi} \mathrm{Var}[Y_i^{(0)}] \right) & \ge 0 \\
& + \mathbb{E}[Y_i^{(1)}]^2 (1-\pi)^n + \mathbb{E}[Y_i^{(0)}]^2 \pi^n - \left( \mathbb{E}[Y_i^{(1)}] (1-\pi)^n + \mathbb{E}[Y_i^{(0)}] \pi^n \right)^2
\end{align*}
$$

□
## D.5 Post-stratification estimator

The post-stratified estimator (see Definition 8) is an estimator of the average treatment effect from a RCT sample. The principle is to divide the RCT sample into strata, to compute the difference-in-means per strata, and then to average the estimand on each strata, weighting by the strata size. Indeed, the post-stratification estimator introduced in Definition 8 can be re-written as follows.

$$ \hat{\tau}_{\text{PS},n} = \sum_{x \in \mathcal{X}} \frac{n_{x,1} + n_{x,0}}{n} \left( \frac{1}{n_{x,1}} \sum_{A_i=1, X_i=x} Y_i - \frac{1}{n_{x,0}} \sum_{A_i=0, X_i=x} Y_i \right), \quad \text{where } n_{x,a} = \sum_{i=1}^{n} 1_{X_i=x} 1_{A_i=a}. $$

Therefore, the post-stratification estimator can be understood as a weighted estimate of each strata level difference-in-means estimates,

$$ \hat{\tau}_{\text{PS},n} = \sum_{x \in \mathcal{X}} \frac{n_x}{n} \hat{\tau}_{\text{DM},n_x}, \quad \text{where } n_x = \sum_{i=1}^{n} 1_{X_i=x}. $$

*Proof.* Recalling the definition of $\hat{\pi}_n(x)$ (Definition 7) and denoting $n_{x,a} = \sum_{i=1}^{n} 1_{X_i=x} 1_{A_i=a}$

$$ \begin{align*} \hat{\tau}_{\text{PS},n} &= \frac{1}{n} \sum_{i=1}^{n} \frac{A_i Y_i}{\hat{\pi}_n(x)} - \frac{(1-A_i)Y_i}{1-\hat{\pi}_n(x)} \\ &= \frac{1}{n} \sum_{i=1}^{n} \frac{A_i Y_i}{n_{x,1}/n_x} - \frac{(1-A_i)Y_i}{n_{x,0}/n_x} \tag*{Definition 7} \\ &= \sum_{x \in \mathcal{X}} \frac{1}{n} \sum_{i=1}^{n} 1_{X_i=x} \frac{A_i Y_i}{n_{x,1}/n_x} - \frac{(1-A_i)Y_i}{n_{x,0}/n_x} \tag*{Categorical covariates} \\ &= \sum_{x \in \mathcal{X}} \frac{n_x}{n} \sum_{i=1}^{n} 1_{X_i=x} \frac{A_i Y_i}{n_{x,1}} - \frac{(1-A_i)Y_i}{n_{x,0}} \tag*{Re-arranging $n_x$} \\ &= \sum_{x \in \mathcal{X}} \frac{n_x}{n} \hat{\tau}_{\text{DM},n_x}. \end{align*} $$

□

The post-stratified estimator is extensively detailed in Miratrix et al. (2013), but largely focused on inference on a finite population (except in their Section 5). In particular the variance of the post-stratified estimator under a Bernoulli or a completely randomized design is given in Miratrix et al. (2013) (see their Equation (16)). Imai et al. (2008) also present derivation to compare the variance of a difference-in-means with a post-stratified estimator, quantifying the gain in precision (see Appendix A).

## E (Non-exhaustive) Review of the different IPSW versions in the literature

Within the generalization literature, the IPSW can be found under slightly different forms, such as with estimated $\pi$ or not, or with or without normalization. Here, and to help the reader navigates, we reference some of the different formulas found in the literature and in implementations.

<table><caption>Table 1: Non-exhaustive review of the different IPSW versions, illustrating that different approaches exist.</caption><thead><tr><th>Reference</th><th>IPSW formula</th><th>Comments</th></tr></thead><tbody><tr><td>Huang (2022)</td><td><sup>1</sup>/<sub>n</sub> &sum;<sub>i&isin;Trial</sub> ˆw<sub>n,m</sub>(X<sub>i</sub>) (<sup>Y<sub>i</sub>A<sub>i</sub></sup>/<sub>&pi;&#x0302;<sub>n</sub></sub> - <sup>Y<sub>i</sub>(1-A<sub>i</sub>)</sup>/<sub>1-&pi;&#x0302;<sub>n</sub></sub>)</td><td>&pi; estimated once ˆ&pi;<sub>n</sub> = &sum;<sub>i=1</sub><sup>n</sup> A<sub>i</sub>/n</td></tr><tr><td>Josey et al. (2021)</td><td><sup>1</sup>/<sub>n</sub> &sum;<sub>i&isin;Trial</sub> ˆw<sub>n,m</sub>(X<sub>i</sub>) (<sup>Y<sub>i</sub>A<sub>i</sub></sup>/<sub>&pi;&#x0302;<sub>n</sub></sub> - <sup>Y<sub>i</sub>(1-A<sub>i</sub>)</sup>/<sub>1-&pi;&#x0302;<sub>n</sub></sub>)</td><td>&pi; estimated by any consistent estimator</td></tr><tr><td>Nie et al. (2021)</td><td><sup>1</sup>/<sub>n</sub> &sum;<sub>i&isin;Trial</sub> ˆw<sub>n,m</sub>(X<sub>i</sub>) (<sup>Y<sub>i</sub>A<sub>i</sub></sup>/<sub>&pi;</sub> - <sup>Y<sub>i</sub>(1-A<sub>i</sub>)</sup>/<sub>1-&pi;</sub>)</td><td>Oracle &pi;</td></tr><tr><td>Dahabreh et al. (2020)</td><td><sup>1</sup>/<sub>n</sub> &sum;<sub>i&isin;Trial</sub> ˆw<sub>n,m</sub>(X<sub>i</sub>) (<sup>Y<sub>i</sub>A<sub>i</sub></sup>/<sub>&pi;&#x0302;<sub>n</sub>(X&#x0304;)</sub> - <sup>Y<sub>i</sub>(1-A<sub>i</sub>)</sup>/<sub>1-&pi;&#x0302;<sub>n</sub>(X&#x0304;)</sub>)</td><td>ˆ&pi;<sub>n</sub>(X) estimated with logistic regression</td></tr><tr><td>Buchanan et al. (2018)</td><td><sup>1</sup>/<sub>n</sub> &sum;<sub>i&isin;Trial</sub> ˆw<sub>n,m</sub>(X<sub>i</sub>) (<sup>Y<sub>i</sub>A<sub>i</sub></sup>/<sub>&pi;&#x0302;<sub>n</sub></sub> - <sup>Y<sub>i</sub>(1-A<sub>i</sub>)</sup>/<sub>1-&pi;&#x0302;<sub>n</sub></sub>)</td><td>&pi; estimated once ˆ&pi;<sub>n</sub> = &sum;<sub>i=1</sub><sup>n</sup> A<sub>i</sub>/n</td></tr></tbody></table>