moderndid.compute_conditional_cs_rmm#

moderndid.compute_conditional_cs_rmm(betahat, sigma, num_pre_periods, num_post_periods, l_vec=None, m_bar=0, alpha=0.05, hybrid_flag='LF', hybrid_kappa=None, return_length=False, monotonicity_direction='increasing', post_period_moments_only=True, grid_points=1000, grid_lb=None, grid_ub=None, seed=None)[source]#

Compute conditional confidence set for \(\Delta^{RMI}(\bar{M})\).

Computes a confidence set for \(l'\tau_{post}\) under the restriction that \(\delta\) lies in \(\Delta^{RMI}(\bar{M})\), which combines the relative magnitudes restriction with a monotonicity constraint.

The combined restriction is defined in Section 2.4.4 of [2] as

\[\Delta^{RMI}(\bar{M}) = \Delta^{RM}(\bar{M}) \cap \Delta^{I},\]

where \(\Delta^{I} = \{\delta: \delta_t \ge \delta_{t-1} \, \forall t\}\) for increasing monotonicity. This is useful when there is prior knowledge that the trend is monotonic.

Since \(\Delta^{RMI}(\bar{M})\) is a finite union of polyhedra, a valid confidence set is constructed by taking the union of confidence sets for each component polyhedron, following Lemma 2.2 of [2].

Parameters:
betahatnumpy.ndarray

Estimated event study coefficients.

sigmanumpy.ndarray

Covariance matrix of betahat.

num_pre_periodsint

Number of pre-treatment periods.

num_post_periodsint

Number of post-treatment periods.

l_vecnumpy.ndarray, optional

Vector defining parameter of interest. If None, defaults to first post-period.

m_barfloat, default=0

Relative magnitude parameter \(\bar{M}\).

alphafloat, default=0.05

Significance level.

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

Type of hybrid test.

hybrid_kappafloat, optional

First-stage size for hybrid test. If None, defaults to alpha/10.

return_lengthbool, default=False

If True, return only the length of the confidence interval.

monotonicity_direction{‘increasing’, ‘decreasing’}, default=’increasing’

Direction of monotonicity restriction.

post_period_moments_onlybool, default=True

If True, use only post-period moments for ARP test.

grid_pointsint, default=1000

Number of grid points for confidence interval search.

grid_lbfloat, optional

Lower bound for grid search.

grid_ubfloat, optional

Upper bound for grid search.

seedint, optional

Random seed for reproducibility.

Returns:
dict or float

If return_length is False, returns dict with ‘grid’ and ‘accept’ arrays. If return_length is True, returns the length of the confidence interval.

Notes

The confidence set is constructed using the moment inequality approach from [1], as described in Section 3 of [2]. The intersection of \(\Delta^{RM}(\bar{M})\) and \(\Delta^{I}\) forms a finite union of polyhedra (Section 2.4.5 of [2]), allowing the application of Lemma 2.2 for constructing a valid confidence set. The monotonicity restriction can sharpen the identified set.

References

[1]

Andrews, I., Roth, J., & Pakes, A. (2021). Inference for linear conditional moment inequalities. Review of Economic Studies.

[2] (1,2,3,4)

Rambachan, A., & Roth, J. (2023). A more credible approach to parallel trends. Review of Economic Studies, 90(5), 2555-2591.