diff_diff.SensitivityResults

class diff_diff.SensitivityResults[source]

Bases: object

Results from sensitivity analysis over a grid of M values.

Contains bounds and confidence intervals for each M value, plus the breakdown value.

M_values

Grid of M parameter values.

Type:

np.ndarray

bounds

List of (lb, ub) identified set bounds for each M.

Type:

List[Tuple[float, float]]

robust_cis

List of (ci_lb, ci_ub) robust CIs for each M.

Type:

List[Tuple[float, float]]

breakdown_M

Smallest M where robust CI includes zero.

Type:

float

method

Type of restriction used.

Type:

str

original_estimate

Original point estimate.

Type:

float

original_se

Original standard error.

Type:

float

alpha

Significance level.

Type:

float

__init__(M_values, bounds, robust_cis, breakdown_M, method, original_estimate, original_se, alpha=0.05)
Parameters:
Return type:

None

Methods

__init__(M_values, bounds, robust_cis, ...)

plot([ax, show_bounds, show_ci, breakdown_line])

Plot sensitivity analysis results.

print_summary()

Print summary to stdout.

summary()

Generate formatted summary.

to_dataframe()

Convert to DataFrame with one row per M value.

Attributes

alpha

has_breakdown

Check if there is a finite breakdown value.

M_values

bounds

robust_cis

breakdown_M

method

original_estimate

original_se

M_values: ndarray
bounds: List[Tuple[float, float]]
robust_cis: List[Tuple[float, float]]
breakdown_M: float | None
method: str
original_estimate: float
original_se: float
alpha: float = 0.05
property has_breakdown: bool

Check if there is a finite breakdown value.

summary()[source]

Generate formatted summary.

Return type:

str

print_summary()[source]

Print summary to stdout.

Return type:

None

to_dataframe()[source]

Convert to DataFrame with one row per M value.

Return type:

DataFrame

plot(ax=None, show_bounds=True, show_ci=True, breakdown_line=True, **kwargs)[source]

Plot sensitivity analysis results.

Parameters:
  • ax (matplotlib.axes.Axes, optional) – Axes to plot on. If None, creates new figure.

  • show_bounds (bool) – Whether to show identified set bounds.

  • show_ci (bool) – Whether to show confidence intervals.

  • breakdown_line (bool) – Whether to show vertical line at breakdown value.

  • **kwargs – Additional arguments passed to plotting functions.

Returns:

ax – The axes with the plot.

Return type:

matplotlib.axes.Axes

__init__(M_values, bounds, robust_cis, breakdown_M, method, original_estimate, original_se, alpha=0.05)
Parameters:
Return type:

None