yasa.SleepStatsAgreement.plot_blandaltman#

SleepStatsAgreement.plot_blandaltman(sleep_stats=None, bias_method='auto', loa_method='auto', ci_method='auto', scatter_kwargs=None, **kwargs)[source]#

Plot Bland-Altman agreement plots for one or more sleep statistics.

Each panel shows observed-minus-reference differences (y-axis) against reference values (x-axis) for one sleep statistic. Bias and limits of agreement are drawn as lines, with optional confidence-interval bands. Methods (parametric, regression, or bootstrap) are chosen automatically per statistic based on the assumption tests stored in assumptions, or can be set explicitly.

See also

report, summary

Parameters:
sleep_statslist or None

List of sleep statistics to plot. Default (None) is to plot all sleep statistics.

bias_methodstr

If 'param', bias is always the mean difference (horizontal line with an optional CI band). If 'regr', bias is always a regression line (no CI band). If 'auto' (default), the method is chosen per statistic based on the proportional-bias assumption test.

loa_methodstr

Method used to draw limits of agreement. Options:

  • 'param' — constant LoA: horizontal lines at bias ± 1.96 SD. Always uses this form regardless of assumptions or log_transform. When the bias is a regression line, the LoA run parallel to it at ± 1.96 SD of its residuals (Menghini et al. 2021, eq. 2).

  • 'regr' — regression LoA: lines following bias ± 2.46 (c0 + c1 × ref), where c0 + c1 × ref models the absolute residuals of the bias. Always uses this form regardless of assumptions or log_transform.

  • 'log' — Euser LoA: lines following bias ± slope × ref. Requires log_transform=True and no zero values; raises ValueError otherwise.

  • 'auto' (default) — uses 'log' for the log-transformed statistics (see log_transform). Otherwise, uses 'param' when the homoscedasticity assumption passes and 'regr' when it fails.

ci_methodstr or None

If 'param', parametric CIs are drawn. If 'boot', bootstrap CIs are drawn. If 'auto' (default), chosen per statistic based on the normality assumption test. If None, no confidence intervals are drawn.

scatter_kwargsdict or None

Keyword arguments passed to matplotlib.pyplot.scatter.

**kwargsdict

Other keyword arguments are passed through to seaborn.FacetGrid.

Returns:
gseaborn.FacetGrid

Seaborn FacetGrid

Examples

>>> import yasa
>>> n = 20
>>> ref_hyps = [yasa.simulate_hypnogram(scorer="PSG", seed=i) for i in range(n)]
>>> obs_hyps = [ref_hyps[i].simulate_similar(scorer="Device", seed=i) for i in range(n)]
>>> eea = yasa.EpochByEpochAgreement(ref_hyps, obs_hyps)
>>> sstats = eea.get_sleep_stats()
>>> ssa = yasa.SleepStatsAgreement(sstats)
>>> stats = ["TST", "WASO", "N1", "REM"]
>>> g = ssa.plot_blandaltman(sleep_stats=stats, ci_method="param")
../_images/yasa-SleepStatsAgreement-plot_blandaltman-1.png