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:
betahatnumpy.ndarray

Estimated event study coefficients.

sigmanumpy.ndarray

Covariance matrix of \(\hat{\beta}\).

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 \(\theta = l'\tau_{post}\). If None, defaults to first post-period.

m_barfloat, 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.

alphafloat, default=0.05

Significance level.

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

Type of hybrid test.

hybrid_kappafloat, 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_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

Returns dict with ‘grid’ and ‘accept’ arrays.

Raises:
ValueError

If 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.