moderndid.compute_arp_ci#

moderndid.compute_arp_ci(beta_hat, sigma, A, d, n_pre_periods, n_post_periods, post_period_index=1, alpha=0.05, grid_lb=None, grid_ub=None, grid_points=1000, return_length=False, hybrid_flag='ARP', hybrid_kappa=None, flci_halflength=None, flci_l=None, lf_cv=None)[source]#

Compute Andrews-Roth-Pakes (ARP) confidence interval with no nuisance parameters.

Constructs confidence intervals for the parameter of interest \(\theta = l' \tau_{\text{post}}\) in the special case where \(\bar{T} = 1\) (single post-treatment period), which means there are no nuisance parameters \(\tilde{\tau}\) to profile over. This allows for more efficient computation compared to the general case.

For each value \(\bar{\theta}\) on a grid, the method tests the null hypothesis \(H_0: \theta = \bar{\theta}, \delta \in \Delta\) where \(\Delta = \{\delta: A \delta \leq d\}\). Following the results from [1], this is equivalent to testing whether there exists \(\tau_{\text{post}} \in \mathbb{R}^{\bar{T}}\) such that \(l' \tau_{\text{post}} = \bar{\theta}\) and

\[\mathbb{E}_{\hat{\beta}_n \sim \mathcal{N}(\delta+\tau, \Sigma_n)} [Y_n - A L_{\text{post}} \tau_{\text{post}}] \leq 0\]

where \(Y_n = A \hat{\beta}_n - d\) and \(L_{\text{post}} = [0, I]'\).

In the no-nuisance case (\(\bar{T} = 1\)), the profiled test statistic from equation (14) in [2] simplifies to \(\hat{\eta} = \max_i (A \hat{\beta}_n - d)_i / \tilde{\sigma}_{n,i}\) where \(\tilde{\sigma}_{n,i} = \sqrt{(A \Sigma_n A')_{ii}}\). The test conditions on the event that constraint \(j = \arg\max_i (A \hat{\beta}_n - d)_i / \tilde{\sigma}_{n,i}\) is binding, leading to a truncated normal distribution for \(\hat{\eta}\).

Parameters:
beta_hatnumpy.ndarray

Vector of estimated event study coefficients \(\hat{\beta}\). First n_pre_periods elements are pre-treatment, remainder are post-treatment.

sigmanumpy.ndarray

Covariance matrix \(\Sigma\) of estimated coefficients.

Anumpy.ndarray

Matrix \(A\) defining the constraint set \(\Delta\).

dnumpy.ndarray

Vector \(d\) such that \(\Delta = \{\delta : A\delta \leq d\}\).

n_pre_periodsint

Number of pre-treatment periods \(T_{pre}\).

n_post_periodsint

Number of post-treatment periods \(T_{post}\).

post_period_indexint, default=1

Which post-treatment period \(s\) to compute CI for (1-indexed).

alphafloat, default=0.05

Significance level \(\alpha\) for confidence interval.

grid_lbfloat, optional

Lower bound for grid search. If None, uses \(\hat{\theta} - 10 \cdot SE(\hat{\theta})\).

grid_ubfloat, optional

Upper bound for grid search. If None, uses \(\hat{\theta} + 10 \cdot SE(\hat{\theta})\).

grid_pointsint, default=1000

Number of points in the grid search.

return_lengthbool, default=False

If True, only return the CI length (useful for power calculations).

hybrid_flag{‘ARP’, ‘FLCI’, ‘LF’}, default=’ARP’

Type of test to use. ‘ARP’ is the standard conditional test, ‘FLCI’ adds fixed-length CI constraints for improved power, ‘LF’ uses a least favorable first stage.

hybrid_kappafloat, optional

First-stage size \(\kappa\) for hybrid tests. Required if hybrid_flag != ‘ARP’.

flci_halflengthfloat, optional

Half-length of FLCI constraint. Required if hybrid_flag == ‘FLCI’.

flci_lnumpy.ndarray, optional

Weight vector \(\ell\) for FLCI. Required if hybrid_flag == ‘FLCI’.

lf_cvfloat, optional

Critical value for LF test. Required if hybrid_flag == ‘LF’.

Returns:
APRCIResult

NamedTuple containing CI bounds, grid of tested values, acceptance indicators, and optimization status.

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.