Skip to content

Add a discrete-prior Bayes example to the Bayesian inference chapter - #109

Merged
dem-extra1 merged 3 commits into
mainfrom
claude/project-thread-w3lqh2-discrete-prior-bayes
Oct 11, 2026
Merged

dem-extra1 merged 3 commits into
mainfrom
claude/project-thread-w3lqh2-discrete-prior-bayes

Conversation

@dem-extra1

Copy link
Copy Markdown
Contributor

Before. bayesian-inference.qmd had beta-Bernoulli, logistic, survival and random-effects examples but no worked example where the prior lives on a discrete grid. The only copy was posterior_interval_example.Rmd, an unreferenced file in rme (prior on 0, 0.1, ..., 1; 8 successes in 10 trials; posterior and interval).

After. A new example, exm-discrete-prior, sits right after the credible-interval definition and its examples, before the conjugate-prior section. It builds the posterior column by column (prior, likelihood, product, posterior) with a table and a bar-chart figure with alt text. It then computes the one-sided 95% credible interval, (0.4, 1], with every number coming from the executed R chunks. Fixes to the source: the source's references to "2.5.x" are gone, dbinom replaces the hand-written binomial, the conflicted/slice_tail step is replaced by a plain max(), and the text now says that a discrete posterior cannot hit 0.95 exactly. It reads the chapter's def-credible-interval as "at least 1 - alpha" on a grid, so the interval is conservative (actual probability 0.9866).

How. New subfile _subfiles/bayesian-inference/_exm-discrete-prior.qmd, plus one include and slide break in bayesian-inference.qmd. No epi204 material used. The rme file is the maintainer's own, so no Source callout.

Verified: the example rendered to HTML in isolation (R chunks ran; table, figure and inline values checked against the prose); typos is clean apart from the existing @thm- cross-reference pattern. Not verified: a full-page render of bayesian-inference.qmd failed in this container because the installed reticulate lacks py_require, so the cross-references (thm-bayes-posterior, def-credible-interval, def-marginal-likelihood) were checked by id only. The repo's .lintr.R would not load here (lintr version), so lint ran with default settings (only line-length notes on chunk-option comments, as in existing subfiles).

🤖 Generated with Claude Code

https://claude.ai/code/session_013vVJoNUjq7DoadV7U1d6XY


Generated by Claude Code

Restores the grid-prior, 8 successes in 10 trials example (rme's
posterior_interval_example.Rmd) as an executed worked example after the
credible-interval definition.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013vVJoNUjq7DoadV7U1d6XY
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013vVJoNUjq7DoadV7U1d6XY

Copy link
Copy Markdown
Contributor Author

The link-checker failure is not from this PR's diff. Its only errors are a 503 Service Unavailable from https://github.com/Morrison-Lab/ai-config/blob/main/AGENTS.md, linked from the untouched AGENTS.md and CLAUDE.md (a transient GitHub error). The other lines in the log are redirects, not failures. I re-ran the failed job once.

Posted by Claude Code (AI agent) --- not written by a human.


Generated by Claude Code

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013vVJoNUjq7DoadV7U1d6XY
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown

Claude finished review — View run


Prior review: Ready for merge on 4e8d1f6. That verdict still stands, and the one commit since then doesn't change it.

The new commit is 026cda4, "Wrap long chunk-option lines to satisfy lint-project". It touches only _subfiles/bayesian-inference/_exm-discrete-prior.qmd, in the fig-discrete-prior chunk options:

  • fig-cap: the caption is now a quoted YAML string wrapped over two #| lines, with the continuation indented. YAML folds that into one line with a single space, so the rendered caption is the same.
  • fig-alt: one paste0() string is split in two. The pieces concatenate as "...grid values 0 to 1 " plus "on the horizontal axis ", which gives the same text with no missing or doubled space. The !expr form and its parentheses are still balanced.

Nothing else in the file changed, and no R or prose semantics changed. I re-read the whole example and found no new issues:

  • The cross-references and macros the earlier round checked are unchanged.
  • The chunk options and code-fold settings are unchanged.
  • No build artifacts are touched.

Verdict

Ready for merge

Structured Review Data (JSON)
{
  "schema_version": "1.1",
  "reviewer": "claude",
  "commit_sha": "026cda47ea8ae6e38c9bf45c753943bd0fd8b99d",
  "verdict": "CLEAN",
  "findings": [],
  "detailed_assessment": "Commit 026cda4 only wraps the fig-cap and fig-alt chunk options in _exm-discrete-prior.qmd; the YAML continuation and paste0 string pieces concatenate to identical text.",
  "holistic_assessment": "The change is a formatting-only lint fix within the original scope, so the prior Ready-for-merge verdict on 4e8d1f6 still holds with no regression or build-artifact concerns."
}

Reviewed commit: 026cda4

@github-actions

Copy link
Copy Markdown

💰 Cost: $0.1505 (review) — run

@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.

2026-10-11 07:38 UTC

@dem-extra1
dem-extra1 merged commit 07ecd4b into main Oct 11, 2026
17 of 18 checks passed
@dem-extra1
dem-extra1 deleted the claude/project-thread-w3lqh2-discrete-prior-bayes branch October 11, 2026 07:37
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.

2 participants