moderndid.didinter.variance.compute_clustered_variance#
- moderndid.didinter.variance.compute_clustered_variance(influence_func, cluster_ids, n_groups)[source]#
Compute clustered standard error from influence function.
Computes standard errors for \(\text{DID}_\ell\) estimators using the influence function approach with optional clustering. The variance is computed as
\[\widehat{\text{Var}}(\text{DID}_\ell) = \frac{1}{G^2} \sum_{c=1}^{C} \left(\sum_{g \in c} \psi_g\right)^2\]where \(\psi_g\) is the influence function for group \(g\), \(G\) is the total number of groups, and \(C\) is the number of clusters. When not clustering, each group is its own cluster.
- Parameters:
- influence_func
numpy.ndarray Influence function values \(\psi_g\) for each group.
- cluster_ids
numpy.ndarray Cluster identifiers for each group.
- n_groups
int Total number of groups \(G\).
- influence_func
- Returns:
floatClustered standard error.
References
[1]de Chaisemartin, C., & D’Haultfoeuille, X. (2024). Difference-in- Differences Estimators of Intertemporal Treatment Effects. Review of Economics and Statistics, 106(6), 1723-1736.