Skip to content

Port worthwhile Bayes and MSE derivation work from rme#1194 and rme#1196 - #94

Open
d-morrison wants to merge 4 commits into
mainfrom
claude/port-rme-1194-1196
Open

d-morrison wants to merge 4 commits into
mainfrom
claude/port-rme-1194-1196

Conversation

@d-morrison

Copy link
Copy Markdown
Contributor

Requested by Ezra · project thread

Before: rme#1234 deletes rme's statistics appendices now that sds hosts them. Two open rme PRs, rme#1194 (Bayesian inference subfiles) and rme#1196 (estimation.qmd and proof-mse-bias-variance.qmd), edited those appendices. Their work would be lost along with the files.

After: The parts of those PRs that add something sds lacked are now in sds, rewritten to sds's style (one operation per line with a reason, exercise and solution for derivations, semantic macros, computed rather than hard-coded values). Everything else was checked against sds's current content and left out for the reasons listed under "Skipped".

How

Ported from rme#1194:

  • Uniform-prior coin posterior → new #exm-marginal-likelihood-uniform in bayesian-inference.qmd, after #exm-marginal-likelihood. It works out the marginal likelihood as an integral, then the posterior 2θ and its mean 2/3, one step per line. It doesn't name the Beta family, because the Beta family is introduced later on the page.
  • Step-by-step normal-normal derivation → #exm-normal-normal. The combined "expanding the square; Σxᵢ = n x̄" step and the combined "adding exponents" and "factoring; definition of m" steps are now split into single operations. The skeptical-prior derivation in sds already had the rme PR's level of detail, so it is unchanged.
  • AR(1) Markov chain → new #exm-ar1-chain (states the chain and shows the Markov property) and #exr-ar1-stationary/#sol-ar1-stationary in mcmc.qmd, after #exm-two-state-chain. The rme PR stated the stationary distribution N(0, σ²/(1−ρ²)) without proof. Here it is derived, and the solution shows that no N(0, v) is stationary when |ρ| ≥ 1. A simulation checks the result. The solution adds a \arcoef macro to _macros-sds.qmd.
  • Credible-interval interpretation → added to #exm-beta-bernoulli. The endpoints are computed inline: [0.501, 0.699].

Ported in the spirit of rme#1196 (full annotation of the MSE = bias² + variance derivation):

  • #sol-bias-sq-plus-var: the single "cancel" step is split into reorder, group, a − a = 0 and a + 0 = a.

Skipped:

  • rme#1196's MSE derivation. It adds and subtracts E[θ̂], which sds's derivation rules tell authors to avoid. sds's existing exercise route already has every step annotated.
  • rme#1196's annotated "bias = E − truth" proof. #sol-bias-exprs already has the same annotated steps.
  • rme#1194's DIC example. Its numbers are hypothetical, and #exm-dic-bernoulli already computes DIC from real posterior draws.
  • rme#1194's burn-in example. Its numbers are hypothetical, and #exm-burnin already shows burn-in with simulated chains.
  • Slidebreaks, wording churn and \eqdef changes. sds's parent pages already place the slidebreaks. The \eqdef in rme#1194's Markov-chain definition was wrong anyway (see below).

Errors found in the source PRs:

  • rme#1194 writes \eqdef in the Markov-chain definition. That equation is a condition, not a definition.
  • rme#1194 says Pr(0.50 ≤ π ≤ 0.70 | y) = 0.95 for Beta(56, 37). The equal-tailed interval is [0.501, 0.699]; the rounded interval [0.50, 0.70] has probability 0.953.
  • rme#1194's AR(1) example needs ε^(t+1) to be independent of the earlier states, and the PR doesn't say so. It also asserts convergence without a citation.
  • rme#1196's MSE derivation writes \eqdef on the step that substitutes Var(θ̂). That equality uses the definition of variance but is not itself a definition. Some of its lines also combine two operations.

Checks:

  • estimation.qmd and mcmc.qmd render with no unresolved cross-references.
  • bayesian-inference.qmd can't render in full locally because reticulate isn't installed (this predates this PR). I rendered a temporary copy without its Python chunks instead. It had no unresolved references, and I then deleted it.
  • lintr reports no lints on the changed files.
  • I added antiderivative and exponentials to inst/WORDLIST.
  • The [@CaseBerg01, Corollary 4.6.10] locator (linear combinations of independent normals are normal) comes from memory. It is not yet checked against the PDF.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GPxetNyfUNvZoA23DwYCUg


Generated by Claude Code

rme#1234 deletes rme's statistics appendices now that sds hosts them,
so the open rme PRs that edited those appendices (#1194 and #1196)
would lose their work.
This commit carries over the parts that add something sds lacks,
rewritten to sds's style:

- A continuous-prior posterior example (uniform prior, one head),
  computing the marginal likelihood as an integral (from rme#1194).
- The normal-normal likelihood and posterior derivations split into
  one operation per line (from rme#1194's step-by-step derivations).
- A continuous-state Markov chain example (first-order autoregressive),
  with its stationary distribution derived as an exercise and checked
  by simulation, rather than asserted (from rme#1194).
- A reading of the Beta(56, 37) credible interval as a probability
  statement about the parameter (from rme#1194), with the interval
  computed rather than hard-coded.
- The cancel step in the squared-bias-plus-variance solution split into
  its reorder, group, a - a = 0 and a + 0 = a steps, in the spirit of
  rme#1196's fully annotated MSE derivation.

Items sds already covers as well or better (the annotated bias proof,
the DIC and burn-in examples, which sds bases on real draws) and pure
wording churn were not ported.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GPxetNyfUNvZoA23DwYCUg
@d-morrison d-morrison self-assigned this Oct 9, 2026
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

- Record the AR(1) stationary distribution as a theorem whose proof cites
  the exercise, per the exercise -> solution -> theorem -> proof pattern.
- Show the 0.9^2 substitution instead of a hard-coded 0.81.
- Say the credible-interval probability is approximately 0.95, since the
  printed endpoints are rounded.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GPxetNyfUNvZoA23DwYCUg
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Copy link
Copy Markdown
Contributor Author

check-dois failed because publisher DOI endpoints didn't respond: davison1997bootstrap timed out at www.cambridge.org, and `efron1993introduction` returned 503. This PR doesn't touch references.bib, so the failure isn't from its changes, and there's no fix to port. I've re-run the failed job once.


Generated by Claude Code

ai-config's AGENTS.md asks for a label on every display equation, so
each new one gets a number and a stable URL.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GPxetNyfUNvZoA23DwYCUg
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GPxetNyfUNvZoA23DwYCUg
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

Claude finished review — View run


Commit 6629216 replaces the hardcoded 0.81 and 0.19 in _subfiles/bayesian-inference/_exr-ar1-stationary.qmd:87 with inline R expressions. This confirms the earlier rounds, which ended in Ready for merge. The latest of those is the review of 359a1d5, and it still stands. I did not render the site or run the spell check.

What I checked

  • Values: 0.9^2 prints as 0.81, and 1 - 0.9^2 prints as 0.19 with R's default 7 significant digits, which knitr's inline formatting uses. The sentence therefore renders as 1/(1 − 0.9²) = 1/(1 − 0.81) = 1/0.19 ≈ 5.26, the same text as before.
  • Syntax: the inline `r ...` spans sit inside $...$ math, as in the neighbouring inline expression. They are balanced and well-formed.
  • Scope: only that one line changed. No other file is touched.

Verdict

Ready for merge

Structured Review Data (JSON)
{
  "schema_version": "1.1",
  "reviewer": "claude",
  "commit_sha": "66292168a7c578216b9bd2248895bef42048f645",
  "verdict": "CLEAN",
  "findings": [],
  "detailed_assessment": "The changed line in _exr-ar1-stationary.qmd uses inline R for 0.9^2 and 1-0.9^2, which render as 0.81 and 0.19, matching the prior hardcoded text.",
  "holistic_assessment": "The commit is a one-line, scoped follow-up that leaves the earlier clean verdict intact, with no regression, integration or build-artifact concerns."
}

Reviewed commit: 6629216

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

💰 Cost: $0.1639 (review) — run

Copy link
Copy Markdown
Contributor Author

Cross-model adversarial review (OpenCode harness, GPT-6 Luna model) at head 6629216: ALL CLEAR, after fixes for the "approximately 0.95" credible-interval wording, a theorem and proof recording the AR(1) stationary distribution, labelled display equations, and inline-computed intermediate values. The reviewer's suggestion to move the Casella and Berger citation into a Source callout was declined, because it supports one factual step rather than crediting adapted content.

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


Generated by Claude Code

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1
🚀 Preview available at: https://Morrison-Lab.github.io/sds/pr-preview/pr-94/

Built to branch gh-pages at 2026-10-09 03:04 UTC.

This branch has not been deployed

No deployments
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