Skip to content

Release 0.6.0: repeated-measures toolkit, reproduction model, forest/PPC plots, lapse-regression fix - #8

Merged
Gilles86 merged 11 commits into
mainfrom
repeated-measures-helpers
Nov 10, 2026
Merged

Gilles86 merged 11 commits into
mainfrom
repeated-measures-helpers

Conversation

@Gilles86

@Gilles86 Gilles86 commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Tools for within-subject repeated-measures designs (e.g. baseline / placebo / doses over sessions): a Bayesian observer for reproduction tasks, tidy posterior and posterior-predictive summaries, house-style forest and PPC plots, and a fix for lapse rates in regression models.

Added

  • bauer.models.ReproductionModel / ReproductionRegressionModel: log-space Bayesian observer for reproduction tasks (e.g. interval timing). Measurement m ~ N(log x, ν²), Gaussian prior N(μ_p, σ_p²), response = posterior mean, uniform lapse. The response SD is the SD of the posterior mean across trials, w·ν (not the within-trial posterior SD √w·ν). Fits nu, prior_mu (default) and optionally prior_sd (fit_prior_sd=True, identified from slope + spread), bias (instead of prior_mu) and sigma_motor. Own ppc() returning simulated_response.
  • RegressionModel.conditionwise_draws(idata, conditions, parameters, group=True): natural-scale parameter draws per condition (group or every subject), long format.
  • bauer.utils summaries: summarize_posterior (posterior mean, 95% HDI, P(> 0)), contrast_draws (per-draw differences from a reference level), posterior_draws, ppc_summary / ppc_observed / ppc_coverage (two-step group or subject-level PPC summaries and coverage), convergence_report.
  • bauer.utils plots: set_house_style, plot_forest (group forest plot), plot_sorted_forest (subject-level sorted forest plot per condition), plot_ppc_panels, plot_ppc_overlay, plot_subject_ppc. Shared arguments by / order / palette / level_labels; dotted reference lines via ref / xref.
  • PsychophysicalRegressionModel accepts fixed_regressors / random_regressors.
  • Docs: new "Summarising and plotting posteriors" section and API entries; tutorial lessons 1, 2, 8 and 9 use the new helpers (forest / sorted forest plots, two-step PPCs with coverage, real 95% HDIs instead of percentiles labelled HDI).

Fixed

  • *LapseRegressionModel (Psychophysical, MagnitudeComparison, Risk): since the Beta lapse group prior became the default (8345d8a, 2026-06-09), the regression path built p_lapse as an untransformed Normal(0, 0.5) that could leave (0, 1). Regression models now use the logit-normal lapse prior with a wide between-subject SD. Re-fit lapse-regression fits made since 2026-06-09.

Changed

  • RegressionModel raises on rank-deficient designs (e.g. baseline always in session 1 with C(session)), and warns when random effects are not identified within any subject (e.g. a session trend with one condition per session).
  • convergence_report checks group-level variables only (not subject-level *_sd / *_mu), treats NaN r̂ as a failure, and takes max_divergences=.
  • The tutorial generator (make_notebooks.py) reproduces lessons 3 and 4 again.
  • All new helpers validate their input and raise a ValueError describing the problem instead of returning empty or silently averaged results.

🤖 Generated with Claude Code

Gilles86 and others added 11 commits November 10, 2026 15:36
…s, forest plots, lapse-regression fix

- ReproductionModel / ReproductionRegressionModel: log-space Bayesian observer
  for reproduction tasks (e.g. interval timing). Response SD is the SD of the
  posterior MEAN across trials (w*nu), not the within-trial posterior SD.
  Optional fit_prior_sd (identified from slope + spread), fit_motor_noise,
  lapse mixture, ppc().
- RegressionModel.conditionwise_draws: natural-scale draws per condition in
  long format (group or per subject).
- RegressionModel: refuse rank-deficient designs (e.g. baseline always in
  session 1 with C(session)).
- Fix: *LapseRegressionModel built p_lapse as an untransformed Normal(0, .5)
  since the Beta lapse prior became the default (8345d8a); regression models
  now use the logit-normal group prior with a wide between-subject SD.
- PsychophysicalRegressionModel accepts fixed_regressors/random_regressors.
- bauer.utils: summarize_posterior, contrast_draws, posterior_draws,
  ppc_summary, ppc_observed, ppc_coverage, convergence_report,
  set_house_style, plot_forest, plot_sorted_forest, plot_ppc_panels,
  plot_ppc_overlay, plot_subject_ppc.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ent bias; document constant CV and skew

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t wrong output

- contrast_draws: explicit keys, raises on unknown reference, varying extra
  columns, duplicate rows; preserves level order
- summarize_posterior: raises on NaN draws / NaN keys; warns on pooled rows
  and < 100 draws
- ppc_coverage: raises on unmatched or duplicated cells
- posterior_draws: refuses regression parameters (use conditionwise_draws)
- conditionwise_draws: checks parameter names and duplicate conditions
- convergence_report: includes *_sd, NaN r-hat fails, names the worst
  variable, handles missing *_mu / sample_stats, verdict in attrs['ok']
- RegressionModel warns when random effects are not identified within any
  subject (e.g. condition + session trend, one condition per session)
- plots: one vocabulary (by / order / palette / level_labels / xlabel[s]),
  input validation, lines sorted by x, plot_subject_ppc returns a Figure and
  labels panels by subject id correctly

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…0 on psychometric curves)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…into the default group-level check

Subject-level parameters can end in '_sd' or '_mu' themselves (n1_evidence_sd,
prior_sd, prior_mu), so the name-suffix filter pulled every subject's value
into the default check. On lesson 1's MagnitudeComparisonModel this reported
'worst: n2_evidence_sd[13]' and a min ESS of a subject-level parameter.
Now also require no 'subject' dimension; regression test added.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…olled code

- Lesson 1: conditionwise_draws + summarize_posterior for nu(n1); a
  convergence_report cell; nu1/nu2 via posterior_draws + summarize_posterior,
  group forest (plot_forest) and subject sorted forest (plot_sorted_forest)
  instead of get_subject_posterior_df + FacetGrid; scatter uses the same
  summary (95% HDI instead of equal-tailed 3-97%). PPC rewritten with
  ppc_summary / ppc_observed / ppc_coverage + plot_ppc_panels,
  plot_ppc_overlay and a new subject-level plot_subject_ppc; this also fixes
  the generator, whose PPC cell still used the removed ppc(var_names=...) API.
  Notes the 61% group coverage (misfit at small n1).
- Lesson 2: format effect via conditionwise_draws, contrast_draws and
  plot_forest instead of get_conditionwise_parameters + KDEs.
- Lesson 8: convergence_report for the diagnostics; ISI effect via
  conditionwise_draws / summarize_posterior / contrast_draws / plot_forest
  (was mean/median + equal-tailed percentiles labelled HDI, and KDEs).
- Lesson 9: convergence_report for the DDM and RDM diagnostics.

All four notebooks regenerated with make_notebooks.py and executed
(lessons 8/9 from the cached fits in ~/.bauer_tutorial_cache).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s, 0.6.0 history

- docs/usage.rst: the long-draws convention, convergence_report, group forest
  + contrasts, subject sorted forest, group/subject PPC + coverage, figure style
- docs/api_reference.rst: ReproductionModel / ReproductionRegressionModel,
  conditionwise_draws, summaries, diagnostics and the new plot functions
  (plus the existing summarize_ppc_group)
- docs/concepts.rst: typical workflow uses convergence_report and
  summarize_posterior, links to the new section
- HISTORY.rst: 0.6.0 (unreleased) entry

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ences=)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…HalfNormal group SD is the default

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Gilles86
Gilles86 merged commit 5be94e9 into main Nov 10, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant