moderndid.lp_conditional_test#
- moderndid.lp_conditional_test(y_t, x_t=None, sigma=None, alpha=0.05, hybrid_flag='ARP', hybrid_list=None, rows_for_arp=None)[source]#
Perform Andrews-Roth-Pakes (ARP) test of moment inequality with nuisance parameters.
Tests the null hypothesis \(H_0: \exists \tilde{\tau} \in \mathbb{R}^{\bar{T}-1} \text{ s.t. } \mathbb{E}[\tilde{Y}_n(\bar{\theta}) - \tilde{X}\tilde{\tau}] \leq 0\), where \(\tilde{Y}_n(\bar{\theta}) = Y_n - \tilde{A}_{(\cdot,1)}\bar{\theta}\) has been adjusted for the hypothesized value of \(\theta\). This is the core testing problem in the ARP framework.
The test statistic from equation (14) in [2] is
\[\hat{\eta} = \min_{\eta, \tilde{\tau}} \eta \text{ s.t. } \tilde{Y}_n(\bar{\theta}) - \tilde{X}\tilde{\tau} \leq \tilde{\sigma}_n \cdot \eta,\]where \(\tilde{\sigma}_n = \sqrt{\text{diag}(\tilde{\Sigma}_n)}\) and \(\tilde{\Sigma}_n = A\Sigma_n A'\). The test conditions on the binding moments at the optimum, leading to a truncated normal critical value.
The conditional distribution of \(\hat{\eta}\) given \(\gamma_* \in \hat{V}_n\) and \(S_n = s\) is
\[\hat{\eta} | \{\gamma_* \in \hat{V}_n, S_n = s\} \sim \xi | \xi \in [v^{lo}, v^{up}],\]where
\[\xi \sim \mathcal{N}(\gamma_*'\tilde{\mu}(\bar{\theta}), \gamma_*'\tilde{\Sigma}_n\gamma_*),\]\[S_n = \left(I - \frac{\tilde{\Sigma}_n\gamma_*\gamma_*'} {\gamma_*'\tilde{\Sigma}_n\gamma_*}\right)\tilde{Y}_n(\bar{\theta}),\]and \([v^{lo}, v^{up}]\) are truncation bounds. The conditional test uses critical value \(\max\{0, c_{C,\alpha}\}\) where \(c_{C,\alpha}\) is the \((1-\alpha)\) quantile of the truncated normal under \(\gamma_*'\tilde{\mu}(\bar{\theta}) = 0\).
When the optimization problem is degenerate or the binding moments don’t have full rank, the method switches to a dual approach that works directly with the Lagrange multipliers. This ensures numerical stability and correct inference even in challenging cases.
- Parameters:
- y_t
numpy.ndarray Outcome vector \(Y_T = A\hat{\beta} - d\) (already adjusted by \(\theta\)).
- x_t
numpy.ndarrayorNone Covariate matrix \(X_T\) for nuisance parameters. If None, no nuisance parameters are present.
- sigma
numpy.ndarray Covariance matrix \(\Sigma_Y = A\Sigma A'\) of y_t.
- alpha
float Significance level \(\alpha\) for the test.
- hybrid_flag{‘ARP’, ‘LF’, ‘FLCI’}
Type of test to perform. ‘ARP’ is standard conditional test, ‘LF’ adds least favorable first stage, ‘FLCI’ adds fixed-length CI constraints.
- hybrid_list
dict, optional Additional parameters for hybrid tests including hybrid_kappa, lf_cv, flci_halflength, vbar, and dbar.
- rows_for_arp
numpy.ndarray, optional Subset of rows to use for ARP test, allowing focus on informative moments.
- y_t
- Returns:
dictDictionary containing:
reject: bool, whether test rejects the null
eta: float, test statistic value \(\eta^*\)
delta: ndarray, optimal nuisance parameters \(\xi^*\)
lambda: ndarray, Lagrange multipliers \(\lambda^*\) at optimum
Notes
The test constructs the least favorable distribution by finding the value of \(\tilde{\tau}\) that minimizes the test statistic. Under the null hypothesis, \(\gamma_*'\tilde{\mu}(\bar{\theta}) \leq 0\) since \(\gamma_* \geq 0\), \(\gamma_*'\tilde{X} = 0\), and there exists \(\tilde{\tau}\) such that \(\tilde{\mu}(\bar{\theta}) - \tilde{X}\tilde{\tau} \leq 0\).
For the hybrid test, if the first-stage LF test with size \(\kappa\) rejects (i.e., \(\hat{\eta} > c_{LF,\kappa}\)), the test rejects. Otherwise, it applies a modified conditional test with size \((\alpha-\kappa)/(1-\kappa)\) that conditions on \(\hat{\eta} \leq c_{LF,\kappa}\), using \(v_H^{up} = \min\{v^{up}, c_{LF,\kappa}\}\).
Under LICQ, the LF-hybrid test’s local asymptotic power is at least as good as the power of the optimal size-\((\alpha-\kappa)/(1-\kappa)\) test (Corollary 3.1).
References
[1]Andrews, I., Roth, J., & Pakes, A. (2023). Inference for Linear Conditional Moment Inequalities. Review of Economic Studies.
[2]Rambachan, A., & Roth, J. (2023). A more credible approach to parallel trends. Review of Economic Studies, 90(5), 2555-2591.