estimate_ivqr_effects
iv.estimate_ivqr_effects(
ds: pl.DataFrame,
outcome: ColumnName,
treatment: IvqrTreatment,
instruments: ColumnName | Sequence[ColumnName],
qs: ArrayLike = MEDIAN,
*,
covariates: FormulaRhs = '1',
n_workers: int = 1,
)Estimate an instrumental-variable quantile regression.
We estimate the structural quantile function
\[ q(\tau, d, x) = d' \alpha(\tau) + x' \beta(\tau). \]
For a unit with covariates \(x\) and treatment \(d\), this describes the \(\tau\)-quantile of the potential outcome \(Y(d)\). It is assumed that \(d\) is endogenous, which is why it needs to be instrumented.
The estimation procedure requires an IvqrTreatment, which supplies the treatment column and the grid for \(\alpha\) at which the objective function is evaluated. Notice that we only allow for a single treatment as multiple \(d\) would make the procedure prohibitively slow.
Standard errors are computed analytically. The procedure is still computationally demanding: for each \(\tau\), a quantile regression must be run for every value in the treatment grid. Again, for this reason we do not allow multiple treatments.
The mean effect reported in att is the average of the estimated quantile treatment effects. For this to be interpretable as a full-distribution average, the \(\tau\) grid should be dense. A standard two-stage least squares estimate is also reported in tsls. There is no reason for the mean of the quantiles and the two-stage least squares estimate to coincide, since they refer to different causal targets.
Finally, the estimator targets the quantile treatment effect. This is a population-level structural effect, not a local complier effect.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| ds | polars.DataFrame |
Input data. | required |
| outcome | ColumnName |
Name of the outcome column. | required |
| treatment | IvqrTreatment |
Endogenous treatment variable with the grid for its structural coefficient. | required |
| instruments | ColumnName or sequence of str | Name(s) of the instrument(s). One or more instruments may be used. | required |
| qs | array_like |
Quantiles in (0, 1) at which to estimate the coefficients. |
0.5 |
| covariates | FormulaRhs |
Right-hand side of the covariates. An intercept is always included. | "1" |
| n_workers | int |
Number of worker threads used to evaluate the alpha grid within each quantile. Results are identical for any value because the grid order is preserved. | 1 |
Returns
| Name | Type | Description |
|---|---|---|
IvqrResult |
Treatment and covariate coefficient estimates with their standard errors, one row per coefficient and quantile. |
See Also
IvqrTreatment qte.iv.estimate_unconditional_local_effects qte.iv.estimate_conditional_local_effects
Examples
Estimate the median effect of 401(k) participation on net financial assets, instrumenting participation by eligibility, as in Chernozhukov and Hansen (2004):
>>> import numpy as np
>>> from qte.datasets import load_pension
>>> from qte.iv import IvqrTreatment, estimate_ivqr_effects
>>> res = estimate_ivqr_effects(
... load_pension(),
... "net_tfa",
... treatment=IvqrTreatment("p401", np.arange(0, 25_001, 100)),
... instruments="e401",
... qs=0.5,
... covariates=(
... "C(icat) + C(ecat) + a1 + a2 + a3 + a4 + marr + fsize "
... "+ twoearn + db + pira + hown"
... ),
... )