# `causalis.scenarios.did.refutation.post_inference`

## Module Contents

### Functions

`did_post_inference_cell_table` | Return fitted cell-level inference diagnostics for a Callaway & Sant’Anna estimate.
`did_influence_table` | Return unit-level influence shares for the simple overall ATT.
`did_cluster_influence_table` | Return cluster-level influence shares for clustered Callaway & Sant’Anna estimates.
`run_did_post_inference_diagnostics` | Run post-fit Callaway & Sant’Anna inference diagnostics and return a reliability report.
`run_did_inference_diagnostics` | Alias for :func:`run_did_post_inference_diagnostics`.

### Data

`__all__` |

### API

causalis.scenarios.did.refutation.post_inference.did_post_inference_cell_table(estimate: causalis.data_contracts.panel_did_estimate.CallawaySantAnnaDIDEstimate) → pandas.DataFrame

  Return fitted cell-level inference diagnostics for a Callaway & Sant’Anna estimate.

  This function merges the point estimates and standard errors with auxiliary cell-level diagnostics produced during the estimation process (e.g., propensity clipping, covariate balance, and effective sample sizes).

  Parameters

  estimate : CallawaySantAnnaDIDEstimate The fitted estimate object from a `CallawaySantAnnaDID` model.

  Returns

  pd.DataFrame A table where each row corresponds to an ATT(g,t) cell, containing: - `group`: The treatment group (first treated period). - `time`: The calendar time period. - `att`: The point estimate for this cell. - `se`: The standard error. - `t_stat`: The t-statistic (att / se). - `is_post_treatment`: Whether the cell is in the post-treatment period. - Additional columns from the model’s cell diagnostics (e.g., `control_ess`, `max_propensity_clip`).

  Examples

  > > > from causalis.scenarios.did import CallawaySantAnnaDID, generate_did_gamma_26 from causalis.scenarios.did.refutation import did_post_inference_cell_table data = generate_did_gamma_26(n_units=200, n_periods=5, seed=42) model = CallawaySantAnnaDID().fit(data) est = model.estimate(diagnostic_data=True) cells = did_post_inference_cell_table(est) cells[[“group”, “time”, “att”, “t_stat”]].head()

causalis.scenarios.did.refutation.post_inference.did_influence_table(data_or_estimate: causalis.data_contracts.PanelDataDID | causalis.data_contracts.panel_did_estimate.CallawaySantAnnaDIDEstimate, estimate: Optional[causalis.data_contracts.panel_did_estimate.CallawaySantAnnaDIDEstimate] = None, *, top_n: Optional[int] = None) → pandas.DataFrame

  Return unit-level influence shares for the simple overall ATT.

  Influence scores represent the first-order contribution of each unit to the final estimate. This function aggregates influence scores across all ATT(g,t) cells used in the simple average ATT and calculates their relative shares.

  Parameters

  data_or_estimate : PanelDataDID or CallawaySantAnnaDIDEstimate If a `PanelDataDID` object is provided, the second argument `estimate` must be supplied. If a `CallawaySantAnnaDIDEstimate` is provided, the data will be resolved from the estimate if possible. estimate : CallawaySantAnnaDIDEstimate, optional The fitted estimate object. Required if the first argument is data. top_n : int, optional If provided, only return the top N units by absolute influence share.

  Returns

  pd.DataFrame A table of unit-level influence metrics: - `unit_id`: The unit identifier. - `rank`: Ranking by absolute influence. - `influence_score`: The raw aggregated influence score. - `abs_influence_score`: The absolute value of the score. - `abs_influence_share`: The share of total absolute influence.

  Notes

  The influence share for unit :math:`i` is defined as:

  .. math:: S_i = \frac{|\psi_i|}{\sum_{j=1}^n |\psi_j|}

  where :math:`\psi_i` is the influence score of unit :math:`i` on the target parameter (e.g., the simple aggregate ATT). High influence shares indicate units that have a disproportionate impact on the final result.

  Examples

  > > > from causalis.scenarios.did import CallawaySantAnnaDID, generate_did_gamma_26 from causalis.scenarios.did.refutation import did_influence_table data = generate_did_gamma_26(n_units=200, n_periods=5, seed=42) model = CallawaySantAnnaDID().fit(data) est = model.estimate(diagnostic_data=True) influence = did_influence_table(data, est, top_n=5) influence[[“unit_id”, “abs_influence_share”]]

causalis.scenarios.did.refutation.post_inference.did_cluster_influence_table(data: causalis.data_contracts.PanelDataDID, estimate: causalis.data_contracts.panel_did_estimate.CallawaySantAnnaDIDEstimate) → pandas.DataFrame

  Return cluster-level influence shares for clustered Callaway & Sant’Anna estimates.

  Aggregates unit-level influence scores up to the cluster level. This is essential for diagnostics when the model was fitted using clustered standard errors, as the independence assumption holds at the cluster level.

  Parameters

  data : PanelDataDID The original panel data used for estimation. estimate : CallawaySantAnnaDIDEstimate The fitted estimate object, which must have `cluster_col` defined.

  Returns

  pd.DataFrame A table of cluster-level influence metrics: - `cluster_id`: The cluster identifier. - `rank`: Ranking by absolute influence. - `influence_score`: Sum of unit influence scores within the cluster. - `abs_influence_share`: Share of total absolute influence.

  Examples

  > > > from causalis.scenarios.did import CallawaySantAnnaDID, generate_did_gamma_26 from causalis.scenarios.did.refutation import did_cluster_influence_table

  > > > Assuming data has a ‘cluster’ column

  > > > model = CallawaySantAnnaDID(cluster_col=’cluster’).fit(data)

  > > > est = model.estimate(diagnostic_data=True)

  > > > clusters = did_cluster_influence_table(data, est)

causalis.scenarios.did.refutation.post_inference.run_did_post_inference_diagnostics(data_or_estimate: causalis.data_contracts.PanelDataDID | causalis.data_contracts.panel_did_estimate.CallawaySantAnnaDIDEstimate, estimate: Optional[causalis.data_contracts.panel_did_estimate.CallawaySantAnnaDIDEstimate] = None, *, max_skipped_post_cell_share: float = 0.2, min_control_ess: float = 20.0, max_propensity_clip_share: float = 0.05, max_abs_weighted_smd: float = 0.25, max_top_unit_influence_share: float = 0.2, max_top_cluster_influence_share: float = 0.5, min_influence_ess: float = 10.0, max_abs_pretrend_t_stat: float = 2.0, max_simple_cell_weight_share: float = 0.5, min_clusters: int = 2, require_multiplier_bootstrap: bool = False) → pandas.DataFrame

  Run post-fit Callaway & Sant’Anna inference diagnostics and return a reliability report.

  This function performs a comprehensive suite of checks on the fitted model to detect potential issues with identification, estimation stability, and excessive influence of individual observations.

  Parameters

  data_or_estimate : PanelDataDID or CallawaySantAnnaDIDEstimate The first argument can be either the data or the estimate. If data is passed, the `estimate` argument must also be provided. estimate : CallawaySantAnnaDIDEstimate, optional The fitted estimate object. Required if the first argument is data. max_skipped_post_cell_share : float, default 0.20 Maximum allowable share of requested post-treatment cells that were skipped (e.g., due to lack of treated/control units). min_control_ess : float, default 20.0 Minimum effective sample size for the control group in each ATT(g,t) cell. max_propensity_clip_share : float, default 0.05 Maximum share of units in a cell that can have their propensity scores clipped to the boundaries. max_abs_weighted_smd : float, default 0.25 Maximum allowable absolute weighted Standardized Mean Difference (SMD) for covariates after IPW reweighting. max_top_unit_influence_share : float, default 0.20 Maximum absolute influence share of the single most influential unit. max_top_cluster_influence_share : float, default 0.50 Maximum absolute influence share of the single most influential cluster. min_influence_ess : float, default 10.0 Minimum Effective Sample Size (ESS) based on influence scores, calculated as :math:`1 / \sum w_i^2`. max_abs_pretrend_t_stat : float, default 2.0 Maximum absolute t-statistic allowed for pre-treatment testing cells. max_simple_cell_weight_share : float, default 0.50 Maximum weight share of any single ATT(g,t) cell in the simple aggregate ATT. min_clusters : int, default 2 Minimum number of clusters required for valid clustered inference. require_multiplier_bootstrap : bool, default False If True, flags a warning if the multiplier bootstrap was not used for simultaneous inference.

  Returns

  pd.DataFrame A diagnostic report with columns: - `test`: Name of the diagnostic check. - `flag`: Status (GREEN, YELLOW, RED). - `value`: Observed value of the metric. - `threshold`: The threshold used for the check. - `message`: Descriptive result message.

  Notes

  The influence-based ESS is a measure of how concentrated the estimate’s dependence is on a small subset of units. It is defined as:

  .. math:: ESS_{\psi} = \frac{(\sum |\psi_i|)^2}{\sum \psi_i^2}

  Low values suggest the result may be driven by outliers.

  Examples

  > > > from causalis.scenarios.did import CallawaySantAnnaDID, generate_did_gamma_26 from causalis.scenarios.did.refutation import run_did_post_inference_diagnostics data = generate_did_gamma_26(n_units=300, n_periods=5, seed=42) model = CallawaySantAnnaDID().fit(data) est = model.estimate(diagnostic_data=True) report = run_did_post_inference_diagnostics(data, est) report[[“test”, “flag”, “value”]]

causalis.scenarios.did.refutation.post_inference.run_did_inference_diagnostics(*args, **kwargs) → pandas.DataFrame

  Alias for :func:`run_did_post_inference_diagnostics`.

causalis.scenarios.did.refutation.post_inference.__all__

  [‘did_post_inference_cell_table’, ‘did_influence_table’, ‘did_cluster_influence_table’, ‘run_did_pos…