library(qte)
library(ggplot2)
set.seed(42)
data(lalonde)
xf <- ~ age + I(age^2) + education + black + hispanic + married + nodegreeThe Average Treatment Effect (ATE) or Average Treatment Effect on the Treated (ATT) summarizes the causal effect of a treatment by a single number: the mean difference in outcomes between treated and untreated units. This is often a natural quantity, but it can miss important heterogeneity. If a job training program substantially raises earnings at the bottom of the distribution while having little effect at the top, the ATE obscures this. If a minimum wage increase compresses the wage distribution, an average effect conceals the compression.
The Quantile Treatment Effect at level τ is QTE(τ) = QY(1)(τ) − QY(0)(τ), where QY(d)(τ) is the τ-th quantile of the potential outcome distribution under treatment status d. Mapping QTE(τ) across τ ∈ (0, 1) traces how the treatment shifts the entire outcome distribution. The Quantile Treatment Effect on the Treated (QTT) conditions on the treated group.
This vignette demonstrates unc_qte(), the qte package’s estimator for cross-sectional settings (no panel data required). For DiD-based estimators and staggered treatment adoption, see vignette("panel-estimators") and vignette("staggered-adoption").
library(qte)
library(ggplot2)
set.seed(42)
data(lalonde)
xf <- ~ age + I(age^2) + education + black + hispanic + married + nodegreeUnder random assignment, no covariate adjustment is needed: the unconditional quantiles of the treated and control outcome distributions identify the QTE directly. unc_qte() implements the semiparametrically efficient estimator of Firpo (2007). We use the experimental Lalonde data (lalonde.exp), where treatment was randomly assigned.
res_exp <- unc_qte(
yname = "re78",
dname = "treat",
data = lalonde.exp,
target = "qte",
probs = seq(0.1, 0.9, 0.1),
biters = 100
)
summary(res_exp)#>
#> Overall ATE:
#> ATE Std. Error [ 95% Conf. Int.]
#> 1794.343 566.6378 683.7534 2904.933 *
#>
#>
#> QTE:
#> Tau QTE Std. Error [ 95% Simult. Conf. Band]
#> 0.1 0.000 0.0000 0.0000 0.0000
#> 0.2 0.000 141.1888 -438.1941 438.1941
#> 0.3 929.884 311.5726 -37.1140 1896.8819
#> 0.4 1176.944 937.1751 -1731.6769 4085.5641
#> 0.5 1091.468 841.2708 -1519.5036 3702.4394
#> 0.6 1466.690 717.0160 -758.6433 3692.0243
#> 0.7 1810.696 943.5590 -1117.7378 4739.1293
#> 0.8 2300.454 1011.9796 -840.3301 5441.2377
#> 0.9 2856.068 2239.1618 -4093.4035 9805.5402
#> ---
#> Signif. codes: `*' confidence band does not cover 0
#> Note: the outcome looks discrete (308 distinct values; 31% at 0); quantile effects may be unreliable.
Earnings are zero for 31% of this sample, so unc_qte() warns that the outcome looks discrete, and summary() repeats the note. Quantiles in the mass point are zero in both groups, so the QTE there is zero by construction; interpret the low quantiles with care.
autoplot(res_exp, ylab = "QTE (earnings, 1978)")The point estimates are zero at the lowest quantiles, inside the mass point, and then increase with τ, from about $900 at the 30th percentile to about $2,900 at the 90th. With 445 participants, though, the uniform band covers zero at every quantile, even though the ATE of about $1,800 is statistically significant: a band that holds simultaneously over nine quantiles is much wider than a single interval.
When treatment is not randomly assigned, the unconfoundedness assumption (conditional independence of potential outcomes given covariates) provides identification (Firpo 2007). We use the observational Lalonde data (lalonde.psid), which combines the treated group from the experiment with a comparison group from the PSID.
unc_qte() supports three estimation methods:
"ipw" — inverse probability weighting (propensity score re-weighting)"reg" — outcome regression (conditional quantile regression)"aipw" — augmented IPW (doubly robust; recommended)xf <- ~ age + I(age^2) + education + black + hispanic + married + nodegree
res_psid <- unc_qte(
yname = "re78",
dname = "treat",
data = lalonde.psid,
xformula = xf,
est_method = "aipw",
target = "qte",
probs = seq(0.1, 0.9, 0.1),
biters = 100
)
summary(res_psid)#>
#> Overall ATE:
#> ATE Std. Error [ 95% Conf. Int.]
#> -12537.37 1740.177 -15948.05 -9126.687 *
#>
#>
#> QTE:
#> Tau QTE Std. Error [ 95% Simult. Conf. Band]
#> 0.1 0.000 449.2543 -2737.819 2737.8192
#> 0.2 -6404.679 2113.9444 -19287.354 6477.9962
#> 0.3 -8523.773 2135.0722 -21535.204 4487.6582
#> 0.4 -11114.085 2405.7382 -25774.993 3546.8225
#> 0.5 -12684.516 3728.2369 -35404.917 10035.8858
#> 0.6 -13532.837 3330.9643 -33832.203 6766.5296
#> 0.7 -14181.889 1556.9702 -23670.285 -4693.4931 *
#> 0.8 -18285.313 806.9748 -23203.131 -13367.4950 *
#> 0.9 -22580.785 3752.0629 -45446.385 284.8154
#> ---
#> Signif. codes: `*' confidence band does not cover 0
#> Note: the outcome looks discrete (740 distinct values; 12% at 0); quantile effects may be unreliable.
autoplot(res_psid, ylab = "QTE (earnings, 1978)")These estimates are large and negative, far from the experimental benchmark above. The QTE is about the whole population, which here is mostly PSID households with much higher earnings than the program’s participants, and these covariates (which leave out earnings before the program) do not make the two groups comparable (LaLonde 1986; Dehejia and Wahba 1999).
Setting target = "qtt" estimates the Quantile Treatment Effect on the Treated — the distributional effect for the subpopulation that actually received treatment.
res_qtt <- unc_qte(
yname = "re78",
dname = "treat",
data = lalonde.psid,
xformula = xf,
est_method = "aipw",
target = "qtt",
probs = seq(0.1, 0.9, 0.1),
biters = 100
)
summary(res_qtt)#>
#> Overall ATT:
#> ATT Std. Error [ 95% Conf. Int.]
#> -4543.922 816.4717 -6144.177 -2943.667 *
#>
#>
#> QTT:
#> Tau QTT Std. Error [ 95% Simult. Conf. Band]
#> 0.1 0.0001 143.1839 -824.0687 824.0688
#> 0.2 -1002.7420 262.6508 -2514.3807 508.8967
#> 0.3 -3400.5673 2264.5917 -16434.0115 9632.8768
#> 0.4 -5009.2491 1082.4184 -11238.9106 1220.4125
#> 0.5 -4602.4652 643.5540 -8306.3228 -898.6077 *
#> 0.6 -5229.1454 1173.0966 -11980.6888 1522.3980
#> 0.7 -5507.4720 1243.2416 -12662.7219 1647.7779
#> 0.8 -6885.7529 1635.1317 -16296.4547 2524.9489
#> 0.9 -10517.0625 2494.8751 -24875.8609 3841.7358
#> ---
#> Signif. codes: `*' confidence band does not cover 0
#> Note: the outcome looks discrete (740 distinct values; 12% at 0); quantile effects may be unreliable.
autoplot(res_qtt, ylab = "QTT (earnings, 1978)")The QTT only needs a counterfactual for the participants, so it is much smaller in magnitude than the QTE, but it is still negative and grows with τ, and the band excludes zero at the median. It remains well below the experimental estimates, a reminder that unconfoundedness given these covariates is a strong assumption for this comparison group.
summary() prints the overall ATT, the QTE/QTT at each quantile, and standard errors with confidence intervals. autoplot() returns a ggplot object so you can add layers:
autoplot(res_qtt) +
ggplot2::labs(title = "QTT — Lalonde (observational)",
subtitle = "AIPW with pre-treatment covariates")By default autoplot() shows a uniform confidence band (cband = TRUE), which provides simultaneous coverage over all quantile levels — a stronger guarantee than pointwise intervals. Pass cband = FALSE for pointwise intervals instead.
Standard errors are computed via the empirical bootstrap. The biters argument controls the number of iterations (default 100). Parallel computation is available via the cl argument.