[WIP] Add section to logistic regression on computing marginal risk differences#706
[WIP] Add section to logistic regression on computing marginal risk differences#706Claude wants to merge 6 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR (WIP) expands the logistic regression materials by adding an explicit section on computing marginal risk differences (and risk ratios) from logistic models via predictive margins / g-computation, including bootstrap-based uncertainty estimation and a worked WCGS example.
Changes:
- Adds conceptual explanation of conditional vs marginal RD/RR from a logistic model, with notation and formulas.
- Adds a worked WCGS example that computes a marginal RD, a bootstrap SE/CI, and visualizes the bootstrap distribution.
- Adds alternative implementations using
boot::boot()and extends the approach to marginal risk ratios.
|
@copilot apply changes based on the comments in this thread |
Implemented in Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
@copilot apply changes based on the comments in this thread and #706 (review) check the section heading levels to make sure there are no jumps (ignore div title headings) |
Implemented in Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
d-morrison
left a comment
There was a problem hiding this comment.
clearly distinguish between
|
Claude finished @d-morrison's task in 5m 3s —— View job Code Review
SummaryThe PR is in good shape overall — the math, notation, and code structure are solid. Three issues need attention before this comes out of WIP. Bug: entire "Notes and caveats" content is hidden in HTMLFile: The entire file is wrapped in
These are all pedagogically important for students reading the textbook. The The same issue applies to the citation block at the top of Bug: duplicate chunk + div labels (previously flagged, not yet fixed)File: Both files have matching Structural question: heading isolated between two slidebreaksFile: The heading appears alone on one slide; the actual content is pushed to the next slide. If this is intentional (section-title slide style), it's fine — just confirming it's deliberate and not a leftover from the earlier slidebreak-ordering fixes. Positive: math is correct
Positive: cross-chapter references verifiedAll div IDs referenced across chapters exist in their targets:
Positive: code quality
Blocking before WIP removal: items 1 ( |
Code Review — PR #706
|
|
Claude finished @d-morrison's task in 5m 15s —— View job Code Review — PR #706
Bugs (blocking)1.
|
|
I'll analyze this and get back to you. |
|
I'll analyze this and get back to you. |
|
I'll analyze this and get back to you. |
|
I'll analyze this and get back to you. |
|
I'll analyze this and get back to you. |
|
I'll analyze this and get back to you. |
|
I'll analyze this and get back to you. |
|
I'll analyze this and get back to you. |
|
I'll analyze this and get back to you. |
Initial WIP draft of a section on computing marginal risk differences from logistic regression models, with bootstrap standard errors and a numerical example. Squashed from the original 87-commit history because the action's recursive submodule fetch was failing on commits that referenced a now-deleted latex-macros SHA. See the PR description for context.
|
Claude finished @d-morrison's task in 3m 36s —— View job Code Review — PR #706
Three bugs flagged in earlier reviews remain unaddressed. Everything else looks solid. Bugs (blocking — same issues as the 2026-05-25 and 2026-05-26 reviews; still unresolved)1.
|
…egression-marginal-risk
- _sec-logistic-marginal-considerations.qmd:1,61: remove ::: notes
wrapper around the entire considerations list. This content is
primary teaching material (target population, collapsibility,
bootstrap sample size, alternative methods, case-control caveat),
not asides — hiding it inside ::: notes excludes it from the
rendered HTML body.
- _sec-bootstrap-inference.qmd:1-7: same — the citation block is a
source attribution, not a margin note.
- _sec-wcgs-rd-bootstrap.qmd:62, _sec-wcgs-rd-viz.qmd:7: remove the
duplicate `#| label:` line from each chunk. The label is already
supplied by the enclosing `:::{#tbl-...}` / `:::{#fig-...}` div;
the duplicate triggers a Quarto warning ("label clashes with div").
|
Claude finished @d-morrison's task in 6m 19s —— View job Code Review — PR #706
|
|
Claude finished @d-morrison's task in 7m 24s —— View job Code Review — PR #706
Confirmed resolved (previously blocking)All three issues flagged in the 2026-05-25 / 2026-05-26 / 2026-06-09 reviews are fixed in commit
Issues still needing attention1.
|
…egression-marginal-risk
- replace \blue with \teal in the marginal-risk theorems for dark-mode readability (as requested in review) - fix the collapsibility wording: risk ratios are NOT collapsible in general (consistent with thm-collapsibility), with odds ratios non-collapsible in an even stronger sense -- removing the incorrect 'risk ratios are also called collapsible' claim - drop the slidebreak between the 'Notes and caveats' heading and its content so the heading no longer renders as a title-only slide Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011CqGbHzLqKVGnbEpLEdadG
|
Addressed the latest review (commit
Checks: @claude please re-review. Generated by Claude Code |
|
👀 Picked up by workflow run #27813945839. R/Quarto/renv setup runs first (~3-5 min); Claude itself responds after that. |
|
Claude finished @d-morrison's task in 5m 2s —— View job Code Review — PR #706
All three blocking items are confirmed fixed1. Both theorem files now use
2. Collapsibility wording in The incorrect "Risk ratios are also called collapsible" claim is gone. The text now correctly states:
All three statements are consistent with 3. Slidebreak structure at The structure is now: The Positive verification of all other aspectsMath — all correct:
Slidebreak policy (per updated CLAUDE.md lines):
Heading levels — no jumps:
Subfile structure:
R code quality:
Cross-references verified:
One deferred item (not blocking)
Status: all previously-blocking issues are resolved. This PR is ready for WIP label removal and merge. |
|
Working tree is clean — no code changes to make (this is a review). Now I'll post my findings. Code Review — PR #706All three must-fix items from the 2026-06-18 review are resolved: 1. Both 2. Collapsibility wording ✅ confirmed
This is consistent with 3. One Broader checks — all passMath: All estimands, theorems, and proofs verified:
Notation: Heading levels: Slidebreaks: Slidebreak before every R code:
Cross-references: WORDLIST: "Collapsibility"/"collapsibility" correctly added ✅ One remaining administrative actionTwo Verdict: no new bugs found. The optional file-length item ( — posted by @claude post-step from workflow run |
Built to branch |

Thanks for asking me to work on this. I will get started on it and keep this PR's description up to date as I form a plan and make progress.