This page demonstrates the estimators that py-qte offers for unconfounded data. All four estimators provide effects for the overall population (QTE) and for the treated group (QTT), but they differ in how they adjust for covariates:
The unadjusted estimator compares the treated and control outcome distributions directly,
inverse probability weighting (IPW) reweights the observed outcomes by the propensity score,
outcome regression predicts the counterfactual outcome distributions from quantile regressions, and
augmented inverse probability weighting (AIPW) combines the propensity score and the outcome regression.
For the covariate-adjusted estimators, the target argument selects the estimand: CausalTarget.QTE for the overall population or CausalTarget.QTT for the treated. For the unadjusted estimator, the two estimands coincide when treatment is randomly assigned.
The covariate-adjusted estimators rely on unconfoundedness and overlap: conditional on covariates \(X\), treatment is independent of the potential outcomes, and both treatment states occur with positive probability. The unadjusted estimator requires that the treatment is as good as randomly assigned. All estimators compute point estimates on the original sample and bootstrap standard errors by resampling rows.
The implementations are inspired by the R qte package.
Listing 1 displays the quantiles used throughout and the bootstrap configuration.
The LaLonde (1986) data are a standard example for covariate adjustment. We use the version that compares the treated men from the experimental sample with the observational PSID comparison group. The outcome is 1978 earnings (re78), the treatment is treat, and the covariates are age, education, race, marital status and degree status. The PSID comparison group is not randomly assigned, which is why the covariate-adjusted estimators below use it.
Listing 2
from qte.datasets import load_lalondeCOVARIATES ="age + I(age**2) + education + black + hispanic + married + nodegree"DATA = load_lalonde(controls_source="psid").with_columns(pl.col("treat").cast(pl.Int8))print(f"{DATA.height:,} observations, {DATA['treat'].sum():,} treated")
2,675 observations, 185 treated
Table 1 reports the mean of each variable by treatment status.
VARIABLES = {"re74": "Earnings 1974","re75": "Earnings 1975","re78": "Earnings 1978","age": "Age","education": "Education","black": "Black","hispanic": "Hispanic","married": "Married","nodegree": "No degree",}balance = pl.DataFrame( {"Variable": list(VARIABLES.values()),"Treated": [DATA.filter(pl.col("treat") ==1)[v].mean() for v in VARIABLES],"Control": [DATA.filter(pl.col("treat") ==0)[v].mean() for v in VARIABLES], }).with_columns((pl.col("Treated") - pl.col("Control")).alias("Difference"))( GT(balance) .fmt_number(["Treated", "Control", "Difference"], decimals=1, use_seps=True) .tab_header(title="LaLonde Data, Means by Treatment Status") .tab_source_note("The comparison group is the observational PSID sample."))
Table 1
LaLonde Data, Means by Treatment Status
Variable
Treated
Control
Difference
Earnings 1974
2,095.6
19,428.7
−17,333.2
Earnings 1975
1,532.1
19,063.3
−17,531.3
Earnings 1978
6,349.1
21,553.9
−15,204.8
Age
25.8
34.9
−9.0
Education
10.3
12.1
−1.8
Black
0.8
0.3
0.6
Hispanic
0.1
0.0
0.0
Married
0.2
0.9
−0.7
No degree
0.7
0.3
0.4
The comparison group is the observational PSID sample.
Unadjusted Estimator
The unadjusted estimator takes the difference between the treated and control quantiles at each requested probability,
\[
\hat{\Delta}_{\tau}
= \hat{Q}_{\tau}(Y \mid D = 1) - \hat{Q}_{\tau}(Y \mid D = 0),
\]
and reports the difference in means as the average effect. No propensity score or outcome model is involved.
Table 2 and Figure 1 show the results in tabular and graphical form.
unadjusted.tabulate(quantiles=QS)
Table 2
Quantile & Average Treatment Effects
Outcome : re78
Confidence Lvl : 0.95
Quantile
Effect Estimate
Std. Error
Lower CI
Upper CI
Quantile Treatment Effects
0.10
0.00
0.00
0.00
0.00
0.25
−11,041.04
675.56
−12,365.11
−9,716.96
0.50
−16,455.86
759.24
−17,943.95
−14,967.77
0.75
−19,911.53
680.25
−21,244.80
−18,578.26
0.90
−23,867.79
1,872.81
−27,538.43
−20,197.15
Average Treatment Effects
-
−15,204.78
645.61
−16,470.15
−13,939.40
show_chart(unadjusted.plot())
Figure 1: Unadjusted quantile treatment effects on the LaLonde data.
Inverse Probability Weighting
IPW estimates the counterfactual outcome distributions by weighting each observation with the inverse of its probability of receiving the treatment it actually received. With \(\hat{p}(X) = P(D = 1 \mid X)\), the distribution under treatment \(d\) is
propensity_score_formula specifies the logit model for \(\hat{p}(X)\). The target argument selects CausalTarget.QTE for the population or CausalTarget.QTT for the treated.
Table 3 and Figure 2 show the results in tabular and graphical form.
ipw.tabulate(quantiles=QS)
Table 3
Quantile & Average Treatment Effects
Outcome : re78
Confidence Lvl : 0.95
Quantile
Effect Estimate
Std. Error
Lower CI
Upper CI
Quantile Treatment Effects
0.10
0.00
424.19
−831.41
831.41
0.25
−8,754.13
2,302.73
−13,267.40
−4,240.86
0.50
−13,667.88
3,667.86
−20,856.75
−6,479.01
0.75
−16,545.34
2,069.89
−20,602.24
−12,488.44
0.90
−25,253.39
1,536.24
−28,264.36
−22,242.42
Average Treatment Effects
-
−13,194.78
1,692.76
−16,512.53
−9,877.04
show_chart(ipw.plot())
Figure 2: IPW quantile treatment effects on the LaLonde data.
Outcome Regression
Outcome regression fits a quantile regression of the outcome on the covariates separately for the treated and the control group. For a grid of quantiles \(\tau_g\), the fitted conditional quantiles \(\hat{Q}_{Y(d)}(\tau_g \mid X_i)\) generate a prediction for every unit. Pooling these predictions gives the counterfactual distribution
The outcome_regression_config argument takes either a formula or an OutcomeRegressionConfig, which also controls the quantile grid and the quantile-regression algorithm.
Table 4 and Figure 3 show the results in tabular and graphical form.
outcome_regression.tabulate(quantiles=QS)
Table 4
Quantile & Average Treatment Effects
Outcome : re78
Confidence Lvl : 0.95
Quantile
Effect Estimate
Std. Error
Lower CI
Upper CI
Quantile Treatment Effects
0.10
−629.48
646.70
−1,896.98
638.01
0.25
−7,389.09
1,351.31
−10,037.61
−4,740.58
0.50
−12,317.56
1,890.54
−16,022.95
−8,612.18
0.75
−15,976.41
2,414.71
−20,709.16
−11,243.65
0.90
−19,354.27
3,765.67
−26,734.85
−11,973.70
Average Treatment Effects
-
−11,667.72
1,668.18
−14,937.30
−8,398.14
show_chart(outcome_regression.plot())
Figure 3: Outcome-regression quantile treatment effects on the LaLonde data.
Augmented Inverse Probability Weighting
AIPW combines the two models. The propensity score reweights the observed outcomes, while the outcome regression predicts the outcomes that are not observed. For treatment state \(d\), the estimated counterfactual distribution is, up to normalization,
The estimator is doubly robust in the sense that it remains consistent if either the propensity score or the outcome regression is correctly specified. It takes both formulas, and the same target argument as IPW.
Table 5 and Figure 4 show the results in tabular and graphical form.
aipw.tabulate(quantiles=QS)
Table 5
Quantile & Average Treatment Effects
Outcome : re78
Confidence Lvl : 0.95
Quantile
Effect Estimate
Std. Error
Lower CI
Upper CI
Quantile Treatment Effects
0.10
0.00
545.97
−1,070.09
1,070.09
0.25
−7,647.31
2,405.66
−12,362.32
−2,932.30
0.50
−12,682.67
3,060.58
−18,681.29
−6,684.05
0.75
−16,522.64
1,784.54
−20,020.27
−13,025.01
0.90
−22,580.78
3,322.70
−29,093.15
−16,068.42
Average Treatment Effects
-
−12,535.52
1,832.64
−16,127.43
−8,943.61
show_chart(aipw.plot())
Figure 4: AIPW quantile treatment effects on the LaLonde data.
Summary
Table 6 compares the four estimators on the same quantiles.
estimates = {"Unadjusted": unadjusted,"IPW": ipw,"Outcome regression": outcome_regression,"AIPW": aipw,}summary = pl.DataFrame({"Quantile": QS})for name, result in estimates.items(): summary = summary.with_columns( pl.Series(name, result.qtt.sort("q")["effect"].to_list()) )( GT(summary) .fmt_number([c for c in summary.columns if c !="Quantile"], decimals=1, use_seps=True) .tab_header(title="Quantile Treatment Effects, All Four Estimators"))
Table 6
Quantile Treatment Effects, All Four Estimators
Quantile
Unadjusted
IPW
Outcome regression
AIPW
0.1
0.0
0.0
−629.5
0.0
0.25
−11,041.0
−8,754.1
−7,389.1
−7,647.3
0.5
−16,455.9
−13,667.9
−12,317.6
−12,682.7
0.75
−19,911.5
−16,545.3
−15,976.4
−16,522.6
0.9
−23,867.8
−25,253.4
−19,354.3
−22,580.8
Benchmarks against the R qte package, including simulated data, are reported separately on the benchmarks page.
References
LaLonde, R. J. (1986). Evaluating the econometric evaluations of training programs with experimental data. The American Economic Review, 76(4), 604–620.