moderndid.compute_conditional_cs_sdrm#
- moderndid.compute_conditional_cs_sdrm(betahat, sigma, num_pre_periods, num_post_periods, l_vec=None, m_bar=0, alpha=0.05, hybrid_flag='LF', hybrid_kappa=None, post_period_moments_only=True, grid_points=1000, grid_lb=None, grid_ub=None, seed=None)[source]#
Compute conditional confidence set for \(\Delta^{SDRM}(\bar{M})\).
Computes a confidence set for \(l'\tau_{post}\) under the restriction that delta lies in \(\Delta^{SDRM}(\bar{M})\), which bounds the second differences in post-treatment periods based on the maximum absolute second difference in pre-treatment periods.
The combined smoothness and relative magnitudes restriction, \(\Delta^{SDRM}(\bar{M})\), is defined in [1] as
\[\Delta^{SDRM}(\bar{M}) = \left\{\delta: \forall t \geqslant 0, \left|\left(\delta_{t+1}-\delta_{t}\right)-\left(\delta_{t}-\delta_{t-1}\right)\right| \leqslant \bar{M} \cdot \max_{s<0} \left|\left(\delta_{s+1}-\delta_{s}\right)- \left(\delta_{s}-\delta_{s-1}\right)\right|\right\}.\]This restriction is useful when researchers believe the differential trend evolves relatively smoothly but are uncertain about the appropriate smoothness bound \(M\).
- Parameters:
- betahat
numpy.ndarray Estimated event study coefficients.
- sigma
numpy.ndarray Covariance matrix of \(\hat{\beta}\).
- 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.
- m_bar
float, default=0 Relative magnitude parameter \(\bar{M}\). Second differences in post-treatment periods can be at most \(\bar{M}\) times the maximum absolute second difference in pre-treatment periods.
- alpha
float, default=0.05 Significance level.
- hybrid_flag{‘LF’, ‘ARP’, ‘FLCI’}, default=’LF’
Type of hybrid test.
- hybrid_kappa
float, optional First-stage size for hybrid test. If None, defaults to \(\alpha/10\).
- 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.
- grid_ub
float, optional Upper bound for grid search.
- seed
int, optional Random seed for reproducibility.
- betahat
- Returns:
dictReturns dict with ‘grid’ and ‘accept’ arrays.
- Raises:
ValueErrorIf num_pre_periods == 1 (not enough pre-periods for second differences). If hybrid_flag is not in {‘LF’, ‘ARP’, ‘FLCI’}.
Notes
The confidence set is constructed using the moment inequality approach from Section 3. Since \(\Delta^{SDRM}(\bar{M})\) is a finite union of polyhedra, we can apply Lemma 2.2 to construct a valid confidence set by taking the union of the confidence sets for each of its components.
Unlike \(\Delta^{SD}(M)\), this restriction is not convex, so Fixed Length Confidence Intervals (FLCIs) may have poor performance. The conditional/hybrid approach is recommended.
References
[1]Rambachan, A., & Roth, J. (2023). A more credible approach to parallel trends. Review of Economic Studies, 90(5), 2555-2591.