moderndid.maximize_bias#

moderndid.maximize_bias(h, sigma, n_pre_periods, n_post_periods, post_period_weights, smoothness_bound=1.0)[source]#

Find worst-case bias subject to standard deviation constraint \(h\).

Computes the affine estimator’s worst-case bias, which for \(\Delta^{SD}(M)\) is found by solving the following Second-Order Cone Program (SOCP)

\[\begin{split}\min_{w, t} \quad & C_{bias} + \sum_{s=-\underline{T}+1}^{0} t_s \\ \text{s.t.} \quad & -t_s \leq \sum_{j=-\underline{T}+1}^{s} w_j \leq t_s, \quad \forall s \\ & \sum_{s=-\underline{T}+1}^{0} w_s = \sum_{s=1}^{\bar{T}} s \cdot \ell_{post,s} \\ & \text{Var}(\ell'_{pre}\hat{\beta}_{pre} + \ell'_{post}\hat{\beta}_{post}) \leq h^2.\end{split}\]

Here, the optimization is over first-difference weights \(w\) and slack variables \(t\). The vector \(\ell_{pre}\) contains the cumulative sums of \(w\). The quadratic variance constraint is reformulated as a second-order cone, and the problem is solved using an interior-point method from [2].

Parameters:
hfloat

Standard deviation constraint for the affine estimator.

sigmanumpy.ndarray

Covariance matrix \(\Sigma\) of event study coefficients.

n_pre_periodsint

Number of pre-treatment periods.

n_post_periodsint

Number of post-treatment periods.

post_period_weightsnumpy.ndarray

Post-treatment weight vector \(\ell_{post}\).

smoothness_boundfloat

Smoothness parameter \(M\) (not directly used in optimization, applied as scaling factor to result).

Returns:
dict

Dictionary with optimization results:

  • status: ‘optimal’ if successful, ‘failed’ or error message otherwise

  • value: Maximum bias value (scaled by smoothness_bound)

  • optimal_l: Optimal pre-period weights \(\ell_{pre}\)

  • optimal_w: Optimal weights in \(w\) parameterization

  • optimal_x: Full solution vector from optimization

Notes

This implementation is specific to \(\Delta^{SD}(M)\). For other restriction sets, the worst-case bias computation differs significantly. For \(\Delta^{SDPB}(M)\) and \(\Delta^{SDI}(M)\), the worst-case bias of any affine estimator equals its worst-case bias over \(\Delta^{SD}(M)\), meaning sign and monotonicity restrictions provide no benefit for FLCIs. For \(\Delta^{RM}(\bar{M})\), the worst-case bias is infinite whenever \(\bar{M} > 0\), as pre-treatment violations can be arbitrarily scaled up.

References

[1]

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

[2]

Goulart, P. J., & Chen, Y. (2024). Clarabel: An interior-point solver for conic programs with quadratic objectives. arXiv preprint arXiv:2405.13033.