ehrapy.plot.propensity_overlap

ehrapy.plot.propensity_overlap#

ehrapy.plot.propensity_overlap(positivity, *, bins=40, title=None, width=520, height=320)[source]#

Plot overlapping propensity score histograms for treated and untreated groups.

Use the dict returned by positivity_check(). A lack of overlap between the two arms is the visual signature of a positivity violation.

Parameters:
  • positivity (dict) – Output of positivity_check().

  • bins (int, default: 40) – Number of histogram bins per arm.

  • title (str | None, default: None) – Plot title. If None, defaults to a string describing the support fraction.

  • width (int, default: 520) – Plot width in pixels.

  • height (int, default: 320) – Plot height in pixels.

Return type:

Overlay

Returns:

A holoviews.Overlay containing one histogram per arm and the support-boundary guide lines.

Examples

>>> import ehrapy as ep
>>> import ehrdata as ed
>>> edata = ed.dt.mimic_2_preprocessed()
>>> info = ep.tl.positivity_check(
...     edata,
...     "aline_flg",
...     covariates=["age", "sofa_first", "sapsi_first"],
... )
>>> ep.pl.propensity_overlap(info)
Preview:
../../_images/propensity_overlap.png