add intro to mcmc techniques for Bayesian inference#837
add intro to mcmc techniques for Bayesian inference#837github-actions[bot] wants to merge 24 commits into
Conversation
Adapts content from Dobson & Barnett 4e Chapter 13. Covers Monte Carlo integration, the Metropolis-Hastings algorithm, the Gibbs sampler, burn-in, convergence diagnostics (trace plots, ACF, Gelman-Rubin), and posterior inference from MCMC samples, with worked R examples using the Bernoulli model. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Claude finished @d-morrison's task in 3m 41s —— View job Code Review — PR #837: Intro to MCMC Techniques
SummaryThe new Critical1.
Every occurrence of Significant2.
The trace plot chunk should be restructured as: :::{#exm-trace-plot}
## Trace plot for MH chain
:::{#fig-trace-mh}
```{r}
#| code-fold: show
library(ggplot2)
burnin <- 500L
df_chain <- data.frame(iteration = seq_along(mh_chain), pi = mh_chain)
ggplot(df_chain, aes(x = iteration, y = pi)) +
geom_line(linewidth = 0.2, alpha = 0.7) +
geom_vline(xintercept = burnin, linetype = "dashed", colour = "red") +
labs(x = "Iteration", y = expression(pi)) +
theme_bw()MH chain trace plot; dashed line marks end of burn-in. ::: The length of the burn-in period is chosen by inspection of trace plots JAGS (Just Another Gibbs Sampler) automates this approach for a wide class of models; and removes the blank line that preceded the JAGS section. This integration is correct: the section heading is in the parent (not the subfile), satisfying the subfile convention. No issues here beyond the forward reference noted in item 4 above. VerdictThis PR should not be merged in its current state due to the undefined |
|
@claude address review comments |
|
👀 Picked up by workflow run #26543221524. R/Quarto/renv setup runs first (~3-5 min); Claude itself responds after that. |
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@claude review |
|
👀 Picked up by workflow run #26553161091. R/Quarto/renv setup runs first (~3-5 min); Claude itself responds after that. |
|
Claude finished @d-morrison's task in 2m 37s —— View job Code Review — PR #837 (re-review after fixes)
What Was FixedCommit
Remaining IssuesSignificant 1. Trace plot figure has no caption and no div wrapper The
The trace plot currently renders as an unlabeled, uncaptioned plot inside an example div — not suitable for a textbook. The chunk at :::{#fig-trace-mh}
```{r}
#| code-fold: show
burnin <- 500L
df_chain <- data.frame(iteration = seq_along(mh_chain), pi = mh_chain)
ggplot(df_chain, aes(x = iteration, y = pi)) +
geom_line(linewidth = 0.2, alpha = 0.7) +
geom_vline(xintercept = burnin, linetype = "dashed", colour = "red") +
labs(x = "Iteration", y = expression(pi)) +
theme_bw()MH chain trace plot; dashed line marks end of burn-in. |
|
@claude iterate |
|
👀 Picked up by workflow run #26641130635. R/Quarto/renv setup runs first (~3-5 min); Claude itself responds after that. |
|
Claude finished @d-morrison's task in 2m 11s —— View job Code Review — PR #837 (post-iterate, round 3)
What Was Fixed by the Iterate CommitsCommits
One Remaining Minor Nit
Structural Note (no action required)
VerdictAll critical and significant issues from prior reviews are resolved. The only remaining item is the low-priority |
|
@claude address review comments, even nits; also why doesn't https://d-morrison.github.io/rme/pr-preview/pr-837/chapters/intro-bayes.html#sec-mcmc:~:text=a%20Bernoulli%20model)-,We%20implement%20the,-MH%20algorithm%20for have an exercise number? also fix all broken crossrefs; note in ai instructions, cross-chapter crossrefs need to handled differently from within-chapter crossrefs |
|
👀 Picked up by workflow run #26988088244. R/Quarto/renv setup runs first (~3-5 min); Claude itself responds after that. |
|
@claude also adapt the rest of the content from dobson |
|
👀 Picked up by workflow run #27047682804. R/Quarto/renv setup runs first (~3-5 min); Claude itself responds after that. |
- Replace undefined \dev macro with D in DIC prose (mcmc-methods.qmd)
- Use \operatorname{DIC} instead of \mathrm{DIC} in equation
- Remove forward reference @exm-normal-credible-vs-confidence (intro-bayes.qmd)
- Remove forward reference @sec-bayes-conjugate from normal-normal section
- Use cross-chapter link for Beta-Bernoulli example (_sec-mcmc.qmd)
- Add citation for JAGS claim [@dobson4e, Chapter 13]
- Use \logit macro and \tp{\vxi} for transpose (bayesian-examples.qmd)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
71e38f1 to
683a5b6
Compare
|
Claude finished @d-morrison's task in 2m 51s —— View job Code Review — PR #837 (round 8)
What Was Fixed Since Round 7All seven round-7 findings were addressed:
One Remaining Nit
And once in
The codebase defines VerdictAll critical, significant, and moderate issues from all prior rounds are resolved. The only remaining item is the low-priority |
…0527-185948 Co-authored-by: d-morrison <2474437+d-morrison@users.noreply.github.com>
Replace the conceptual-only model-averaging section with a worked, base-R example: enumerate all subsets of three predictors (one irrelevant), weight models by the BIC approximation to the posterior model probability [@schwarz1978estimating], and report posterior inclusion probabilities and a model-averaged slope. Recovers high inclusion for the true predictors, low for the irrelevant one, and a model-averaged slope near the true value. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-authored-by: d-morrison <2474437+d-morrison@users.noreply.github.com>
…' into claude/issue-836-20260527-185948 Co-authored-by: d-morrison <2474437+d-morrison@users.noreply.github.com>
|
Claude finished @d-morrison's task in 2m 41s —— View job Code Review — PR #837 (round 9)
What's New Since Round 8Commit Carry-forward: Nit1. Still unresolved from round 8. Raw
And once in
No New issue from the BMA addition2.
New content — no issues
VerdictTwo items remain: the carry-forward |
- Bump latex-macros to pick up the new \hR macro (d-morrison/macros#63) and replace the four raw \hat{R} / \hat R occurrences with \hR (Gelman-Rubin statistic) in _sec-mcmc.qmd and bayesian-examples.qmd. - \mathrm{BIC} -> \operatorname{BIC} in the BMA example, matching the book convention for criterion names (as done for \operatorname{DIC}). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-authored-by: d-morrison <2474437+d-morrison@users.noreply.github.com>
|
Claude finished @d-morrison's task in 2m 34s —— View job Code Review — PR #837 (round 10)
What Was Fixed Since Round 9Commit
No Remaining IssuesA scan of all changed files for lingering raw-LaTeX operator names ( VerdictAll critical, significant, moderate, and minor issues from rounds 1–9 are resolved. The PR is ready to merge. |
|
Claude finished @d-morrison's task in 3m 59s —— View job Code Review — PR #837 (round 11)
What Was Fixed Since Round 10The merge commit
One Nit
VerdictAll critical, significant, and moderate issues from all prior rounds are resolved. The only remaining item is the low-priority redundant |
Built to branch |
|
Claude finished @d-morrison's task in 3m 39s —— View job Code Review — PR #837 (round 12)
What Was Fixed Since Round 11The merge commit
Carry-forward: Nit
Still not addressed from round 11. New Nit
of an estimator $\hat\theta$ —
that is, the distribution of $\hat\theta$ over hypothetical repetitions
VerdictAll critical and significant issues from all prior rounds are resolved. Two minor nits remain:
The PR is ready to merge once these two nits are addressed. |
Address round-12 review nits on PR #837: - Replace raw $\hat\theta$ with the \hth macro (lines 33-34) - Remove redundant library(ggplot2); ggplot2 is loaded globally via r-config.qmd Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019NHtAdoQEyFVdaPY4BbEJD
|
Claude finished @d-morrison's task in 2m 1s —— View job Code Review — PR #837 (round 13)
What Was Fixed Since Round 12Commit
No Remaining IssuesA final scan of all changed files (
VerdictAll critical, significant, moderate, and minor issues from rounds 1–12 are resolved. The PR is ready to merge. |
Draft PR opened by
@claudeto address #836.Triggered by workflow run.
Addresses #836.