moderndid.compute_conditional_cs_rm#
- moderndid.compute_conditional_cs_rm(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, post_period_moments_only=True, grid_points=1000, grid_lb=None, grid_ub=None, seed=None)[source]#
Compute conditional confidence set for \(\Delta^{RM}(\bar{M})\).
Computes the confidence set by taking the union over all choices of reference period \(s\) and sign restrictions (+)/(-).
The relative magnitudes restriction \(\Delta^{RM}(\bar{M})\) is defined in Section 2.4.1 of [2] as
\[\Delta^{RM}(\bar{M}) = \{\delta: \forall t \ge 0, |\delta_{t+1} - \delta_t| \le \bar{M} \cdot \max_{s<0} |\delta_{s+1} - \delta_s|\}.\]This restriction formalizes that post-treatment violations of parallel trends are not excessively larger than pre-treatment violations. As shown in footnote 9 of [2], \(\Delta^{RM}(\bar{M})\) can be written as a finite union of polyhedra, which allows for tractable computation.
The confidence set is constructed based on Lemma 2.2 in [2], which states that a valid confidence set for a union of sets is the union of the confidence sets for each component. Thus, we compute
\[\mathcal{C}_n(\Delta^{RM}(\bar{M})) = \bigcup_{s<0, \text{sign} \in \{+,-\}} \mathcal{C}_n(\Delta^{RM}_{s, \text{sign}}(\bar{M})),\]where \(\Delta^{RM}_{s, \text{sign}}(\bar{M})\) corresponds to the polyhedron where the maximum pre-treatment violation occurs at period \(s\) with a given sign.
- Parameters:
- betahat
numpy.ndarray Estimated event study coefficients.
- sigma
numpy.ndarray Covariance matrix of betahat.
- num_pre_periods
int Number of pre-treatment periods.
- num_post_periods
int Number of post-treatment periods.
- l_vec
numpy.ndarray, optional Vector defining parameter of interest \(\theta = l'\tau_{post}\). If None, defaults to first post-period, \(\tau_{post,1}\).
- m_bar
float, default=0 Relative magnitude parameter \(\bar{M}\). Controls how much larger post-treatment violations can be relative to pre-treatment violations.
- alpha
float, default=0.05 Significance level.
- hybrid_flag{‘LF’, ‘ARP’}, default=’LF’
Type of hybrid test.
- hybrid_kappa
float, 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.
- post_period_moments_onlybool, default=True
If True, use only post-period moments for ARP test.
- grid_points
int, default=1000 Number of grid points for confidence interval search.
- grid_lb
float, optional Lower bound for grid search. If None, calculated as gridoff - gridhalf, where gridoff = betahat_post @ l_vec and gridhalf = (m_bar * sum(1:T_post * \(\ell_{vec}\)) * maxpre) + (20 * sd_theta).
- grid_ub
float, optional Upper bound for grid search. If None, calculated as gridoff + gridhalf, using the same formula as grid_lb.
- seed
int, optional Random seed for reproducibility.
- betahat
- Returns:
Notes
The confidence set is constructed using the moment inequality approach from Section 3 of [2]. Testing \(H_0: \theta = \bar{\theta}\) for \(\delta \in \Delta\) is equivalent to testing a system of moment inequalities with linear nuisance parameters, as shown in (12) and (13) of [2]. The conditional and hybrid tests from [1] are used to handle the computational challenge of high-dimensional nuisance parameters by exploiting the linear structure.
As detailed in footnote 9 of [2], \(\Delta^{RM}(\bar{M})\) is decomposed into a finite union of polyhedra
\[\Delta^{RM}(\bar{M}) = \bigcup_{s<0} (\Delta_{s,+}^{RM}(\bar{M}) \cup \Delta_{s,-}^{RM}(\bar{M})),\]where
\[\Delta_{s,+}^{RM}(\bar{M}) = \{\delta: \forall t \ge 0, |\delta_{t+1} - \delta_t| \le \bar{M}(\delta_{s+1} - \delta_s)\},\]and
\[\Delta_{s,-}^{RM}(\bar{M}) = \{\delta: \forall t \ge 0, |\delta_{t+1} - \delta_t| \le -\bar{M}(\delta_{s+1} - \delta_s)\}.\]References