perform_instrument_validity_test
iv.perform_instrument_validity_test(
ds: pl.DataFrame,
outcome: ColumnName,
treatment: ColumnName,
instrument: ColumnName,
*,
weights: ColumnName | None = None,
weighting: ValidityWeighting = ValidityWeighting.VARIANCE,
se_floor: float = 0.15,
outcome_grid_size: int = 50,
alpha: float = 0.05,
bootstrap_config: BootstrapConfig | int = 1000,
)Test instrument validity with the Kitagawa (2015) test.
The treatment and the instrument need to be binary, and D = 1 needs to be the state that the instrument encourages (as of now you have to recode the variables if it is not).
The test relies on the fact that, under the assumptions that identify a treatment effect on the compliers, we must have
\[ P(B, 1) - Q(B, 1) >= 0 and Q(B, 0) - P(B, 0) >= 0. \]
That is, the distribution of \((Y,D)\) when the instrument is switched on (off), \(P\) (\(Q\)), assigns at least as much probability as the other one to every set \(B\) whenever the treatment is on (off).
The test builds a test statistic on this basis and then uses the pooled bootstrap to derive the distribution of the test statistic under the assumption that \(Q\) and \(P\) are in fact equal.
Notice that the test can only reject instrument validity, not confirm it. Further, the test is conservative in the sense that it tends to underreject. This is because the bootstrap distribution is computed at \(P = Q\), the least favourable member of the null, so the critical values are conservative whenever the inequalities are slack.
This implementation is relatively close to the original Kitagawa (2015) paper as opposed to the implementation in the ivcheck R package which uses the wild bootstrap.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| ds | polars.DataFrame |
Input data. | required |
| outcome | ColumnName |
Name of the outcome column. | required |
| treatment | ColumnName |
Name of the binary treatment column (1 treated, 0 not). |
required |
| instrument | ColumnName |
Name of the binary instrument column, coded 1 for the encouraged (“on”) arm and 0 for the unencouraged (“off”) arm. The levels are taken as given; a negative first_stage means the coding is the wrong way round for the monotonicity direction D(on) >= D(off). |
required |
| weights | ColumnName |
Name of a column with sampling weights; when omitted every observation gets unit weight. The weights define the empirical measure of the observed CDFs; the bootstrap resamples rows, as everywhere else in the package, and the drawn rows keep their weights. | None |
| weighting | ValidityWeighting |
Variance-weighted or unweighted Kolmogorov–Smirnov statistic. | ValidityWeighting.VARIANCE |
| se_floor | float |
Lower bound for the plug-in standard error in the variance-weighted statistic (xi in the paper, which recommends 0.05 to 0.1). The larger default is more stable in small or unbalanced instrument arms. |
0.15 |
| outcome_grid_size | int |
Maximum number of outcome grid points used for the interval search. | 50 |
| alpha | float |
Significance level used for the verdict. | 0.05 |
| bootstrap_config | BootstrapConfig or int |
Bootstrap settings, or the number of replications. | 1000 |
Returns
| Name | Type | Description |
|---|---|---|
InstrumentValidityResult |
Test statistic, bootstrap p value and the binding interval. |
See Also
References
Kitagawa, T. (2015). A Test for Instrument Validity. Econometrica, 83(5), 2043–2063.
Examples
Test the college-proximity instrument on the Card data:
>>> from qte.datasets import load_card
>>> from qte.iv import perform_instrument_validity_test
>>> res = perform_instrument_validity_test(
... load_card(treatment_cutoff=16),
... "lwage",
... "college",
... "nearc4",
... bootstrap_config=50,
... )
>>> res.verdict
'Reject IV validity'