Plotting

All plotting functions return plotnine.ggplot objects and can be extended with standard plotnine layers (themes, scales, titles, etc.).

plot_resid

plot_resid(resid_df, type='resid_vs_fitted')[source]

Residual plot from the output of hlm_resid().

Parameters:
  • resid_df – DataFrame with .resid and .fitted columns.

  • type"resid_vs_fitted" or "qq".

Return type:

ggplot

Returns:

plotnine.ggplot – A plotnine plot object that can be displayed or saved.

Parameters:
  • resid_df (Any)

  • type (str)

Examples

>>> resid_df = interlace.hlm_resid(result, type="conditional")
>>> interlace.plot_resid(resid_df)

plot_influence

plot_influence(influence_df, diag='cooksd')[source]

Index plot of an influence diagnostic from hlm_influence().

Parameters:
  • influence_df – DataFrame with at least one influence column.

  • diag – Column to plot on the y-axis (default "cooksd").

Return type:

ggplot

Returns:

plotnine.ggplot – A plotnine plot object that can be displayed or saved.

Parameters:
  • influence_df (Any)

  • diag (str)

Examples

>>> infl = interlace.hlm_influence(result)
>>> interlace.plot_influence(infl, diag="cooksd")

dotplot_diag

dotplot_diag(influence_df, diag='cooksd', cutoff='internal', name=None)[source]

Ranked dotplot of an influence diagnostic with outlier labels.

Parameters:
  • influence_df – DataFrame from hlm_influence().

  • diag – Metric to plot.

  • cutoff"internal" uses 3×IQR above Q3; a float labels values above that threshold.

  • name – Column to use for outlier labels. Defaults to the first non-metric column in influence_df.

Return type:

ggplot

Returns:

plotnine.ggplot – A plotnine plot object that can be displayed or saved.

Parameters:
  • influence_df (Any)

  • diag (str)

  • cutoff (str | float)

  • name (str | None)

Examples

>>> infl = interlace.hlm_influence(result)
>>> interlace.dotplot_diag(infl, diag="cooksd", cutoff=0.5)