formalize the procedure for determining how to interpret regression beta coefficients#870
formalize the procedure for determining how to interpret regression beta coefficients#870github-actions[bot] wants to merge 24 commits into
Conversation
…869) Introduces `#def-coef-interp-procedure` in the linear regression chapter as a 4-step procedure (write linear predictor, differentiate or difference, set remaining covariates to 0, solve for beta_j). Adds cross-references from the coefficient interpretation sections of the logistic regression, Poisson/count regression, and proportional hazards chapters. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Claude finished @d-morrison's task in 2m 9s —— View job Code Review: PR #870 — Formal Procedure for Interpreting Regression Coefficients
SummaryThis PR introduces Issues1. Missing required concrete example — convention violation
The new 2. "differencing" vs. "differentiating" in The added sentence (line 265) reads:
The parenthetical says "differencing" but Cox covariates are typically continuous, for which the procedure calls for differentiating (step 2a), not differencing (step 2b). The procedure itself carefully distinguishes "differentiate or difference"; this application should match that precision. Suggested fix: "(differentiating or differencing with respect to $x_j$, depending on whether $x_j$ is continuous or discrete, with all other covariates held fixed)" — or simply drop the parenthetical since the procedure itself defines the distinction. 3. Step 4 phrasing is unclear Step 4 (
"Symmetry of equality" is not a standard phrasing for this operation (the more common phrasing is "since equality is symmetric" or simply "rearranging"). More importantly, by the time steps 2–3 are complete,
4. Non-standard notation for discrete difference (minor) In step 2b ( The subscript-arrow notation 5. Extra blank line in The diff shows: +Applying @def-coef-interp-procedure...
+
::: notesThis leaves two consecutive blank lines before the Minor positives
|
|
@claude address review comments |
|
👀 Picked up by workflow run #26870912489. R/Quarto/renv setup runs first (~3-5 min); Claude itself responds after that. |
|
@claude note that the intercept term, if present, is special; it requires no differentiating or differencing, just setting all covariates to their reference values |
|
👀 Picked up by workflow run #26870995112. R/Quarto/renv setup runs first (~3-5 min); Claude itself responds after that. |
|
All the review comments appear to have already been addressed by the previous session (workflow run #26870912489). Let me verify the complete current state of the procedure file. The file already contains:
The previous session (triggered by the "@claude address review comments" at 07:43:39Z) committed all five fixes and incorporated d-morrison's note about the intercept. The intercept special case in the current file reads:
This matches exactly what you specified. All review comments have been addressed — no further changes needed. You can request review when ready. — posted by @claude post-step from workflow run |
|
Claude finished @d-morrison's task in 3m 42s —— View job Code Review: PR #870 — Formal Procedure for Interpreting Regression Coefficients
SummaryThe PR introduces Issues1.
\eta(m,a)\big|_{m=1} - \eta(m,a)\big|_{m=0}
&= (\beta_0 + \beta_M + \beta_A a) - (\beta_0 + \beta_A a)
\\\\ ← four backslashes
&= \beta_M,The rest of the codebase uses 2.
The 3. Same file, same block — the example uses plain 4. Double blank line in The diff shows two consecutive blank lines between the new cross-reference sentence and Positives
|
|
@claude move sec-coef-interp-procedure after compare-coefficient-interpretations |
|
👀 Picked up by workflow run #26899143416. R/Quarto/renv setup runs first (~3-5 min); Claude itself responds after that. |
|
@claude address review comments |
|
Claude finished @d-morrison's task in 5m 35s —— View job Code Review: PR #870 — Formal Procedure for Interpreting Regression Coefficients
SummaryBoth issues flagged in the previous review (2026-06-05T00:49:51Z) have been addressed:
The procedure logic is correct, macro usage is consistent, and notation matches project conventions throughout. Two minor items remain below. Issues1. Step 3 note for
The note correctly explains that step 3 is skipped, but a reader following the procedure step-by-step will notice that
2. Heading case inconsistency (cosmetic) The
But the
Both headings refer to the same concept. One should match the other; sentence case is the more common convention for definition headers in this codebase. Positives
|
|
@claude explain how the solution to exr-interaction-coef follows the general procedure. Revise the wording of the procedure to fit what we did in that solution (starting at "Difference in slopes:") |
|
👀 Picked up by workflow run #27043881934. R/Quarto/renv setup runs first (~3-5 min); Claude itself responds after that. |
|
I'm on Here's my response: Explanation: how the The solution works through
The solution's three labeled sections map directly onto the two sub-applications of step 2:
Proposed revision to the procedure The current interaction-coefficient note says:
Proposed replacement (uses "slope of
I've written the updated file locally but couldn't commit it to the PR branch (session checked out — posted by @claude post-step from workflow run |
|
Claude finished @d-morrison's task in 2m 57s —— View job Code Review: PR #870 — Formal Procedure for Interpreting Regression Coefficients
How
|
| Procedure step | What the solution does |
|---|---|
|
Step 1 — write down |
|
|
Step 2a — differentiate w.r.t. |
"Slope among males": |
|
Step 2a — differentiate w.r.t. |
"Slope among females": |
|
Step 2b — difference those slopes w.r.t. |
"Difference in slopes": |
| Step 3 — set remaining covariates | Not needed: |
| Step 4 — state the result |
The solution's labeled sections map exactly:
- "Slope among males" / "Slope among females" = step 2a applied at each level of
$m$ - "Difference in slopes" = step 2b, differencing the two slopes w.r.t.
$m$
Proposed revision to the interaction-coefficient note
The current wording at _sec_linreg_coef_interp_procedure.qmd lines 22–26:
For an **interaction coefficient** $\b_{jk}$
(multiplying the product $x_j \cdot x_k$),
apply this step once for each variable in the product:
differentiate or difference with respect to $x_j$,
then differentiate or difference the result with respect to $x_k$.
Proposed replacement (uses "slope" / "difference in slopes" to match the solution's labeled sections):
For an **interaction coefficient** $\b_{jk}$
(multiplying the product $x_j \cdot x_k$),
apply this step twice in sequence:
first differentiate or difference $\eta$ with respect to $x_j$
to obtain the **slope of $x_j$** at each value of $x_k$;
then difference those slopes with respect to $x_k$
to obtain the **difference in slopes**, which equals $\b_{jk}$.
This change is the only edit needed to match d-morrison's requested revision.
Remaining issues from previous review rounds (not yet fixed)
1. Heading case inconsistency — _sec_linreg_understanding.qmd line 684:
### General Procedure for Interpreting Coefficients {#sec-coef-interp-procedure}
Uses title case; the #### heading inside the #def block uses sentence case. Flagged in the 2026-06-05T22:37:22Z review. Should be:
### General procedure for interpreting coefficients {#sec-coef-interp-procedure}
2. Step 3 note for \b_M still incomplete — _sec_linreg_coef_interp_procedure.qmd line 92:
(Step 3 not needed: $a$ cancels in the differencing.)
Flagged in the 2026-06-05T22:37:22Z review (issue #1). The fix adds why $a$ appearing in the result is not a problem:
(Step 3 not needed: $a$ cancels in the differencing, so the result holds for all values of $A$.)
Positives
- All earlier rounds of review comments correctly resolved:
\\not\\\\,\b_*macros,\E{...}notation,{{< slidebreak >}}, intercept special case, step 4 "Identify$\b_j$ " phrasing, differentiating/differencing Cox distinction. - Cross-references in logistic MLE callout, Poisson RRs, and Cox section are well-placed and accurately describe what the procedure delivers.
- The
_exm_wcgs_coef_interp.qmdhint correctly points students to apply the procedure to the log-odds linear predictor.
1. Revise the interaction-coefficient note to match the structure of
the exr-interaction-coef solution ("slope of \$x_j\$" → "difference
in slopes"), per d-morrison's request to "revise the wording of
the procedure to fit what we did in that solution".
2. Heading case fix in `_sec_linreg_understanding.qmd`: title case
→ sentence case to match the convention used for the embedded
`#def-coef-interp-procedure` header.
3. Step-3-not-needed note for \$\\b_M\$: add "so the result holds for
all values of \$A\$" so a reader doesn't wonder why \$a\$ still
appears in the result line.
|
Claude finished @d-morrison's task in 3m 47s —— View job Code Review: PR #870 — Formal Procedure for Interpreting Regression Coefficients
SummaryAll issues from every prior review round are resolved in the current branch (commit Issues1. Interaction note still says "difference" for the second step — but
The
Proposed fix for lines 25–28: first differentiate or difference $\eta$ with respect to $x_j$
to obtain the **slope of $x_j$** (which is a function of $x_k$);
then differentiate or difference that slope with respect to $x_k$
(the **derivative or difference of slopes**), which equals $\b_{jk}$.Or, if keeping the "difference in slopes" terminology that d-morrison requested, scope the note to the discrete case explicitly and add a parenthetical for continuous then difference those slopes with respect to $x_k$
(or differentiate if $x_k$ is continuous)
to obtain the **difference in slopes**, which equals $\b_{jk}$.2. Step 3 header reads as unconditional (minor)
The body (lines 31–35) begins "If covariates other than the one(s) used in step 2 still appear…", making it clear the step is conditional. But the bold heading reads as always-apply. A student who follows only the bold phrases will substitute reference levels even when no substitution is needed — the step 3 notes in the example ("Step 3 not needed: …") address this symptom but not the source. Suggested fix: "If remaining covariates still appear, set them to their reference levels." Positives
|
- Interaction note now covers continuous/continuous and continuous/discrete interactions, not just continuous/discrete: "differentiate or difference that slope" instead of just "difference". Also switches "difference in slopes" to "change in slopes" so the phrasing reads correctly when the outer step is differentiation. - Step-3 header reads "(if any remain)" to match the body's conditional language and avoid implying it always applies.
|
Claude finished @d-morrison's task in 3m 35s —— View job Code Review: PR #870 — Formal Procedure for Interpreting Regression Coefficients
SummaryThe PR is in very good shape. All issues from the previous four review rounds have been addressed. I found two remaining issues — one substantive and one macro-consistency — plus one minor wording note. Issues1. "at each value of
The 2026-06-06T01:57 review flagged this exact phrase: "'At each value of $x_k$' is not the right framing for a continuous covariate; the slope is a function of $x_k$, not computed at a finite set of levels." That review also suggested fixing "at each value of" → "as a function of". The subsequent session fixed Suggested replacement for line 26: 2.
The rest of this file uses Fix: 3. Step-3 header: conditional parenthetical at the end is slightly awkward (minor)
The "(if any remain)" appended after the period of the imperative reads awkwardly — the condition comes after the instruction rather than qualifying it. The prior review suggested "If remaining covariates still appear, set them to their reference levels." which puts the condition first. The current phrasing conveys the intent, but moving the conditional to the front makes the conditional logic clearer for students following the steps. Positives
|
- coef-interp procedure: 'slope of x_j at each value of x_k' ->
'as a function of x_k' (correct for continuous x_k, where the slope is
a function of x_k rather than evaluated at finite levels)
- step-3 header: move the conditional to the front
('If any covariates remain, set them to their reference levels')
- poisson RRs: use the \logf{...} macro instead of bare \log for the
log-rate linear predictor, matching the convention used elsewhere
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011CqGbHzLqKVGnbEpLEdadG
|
Addressed all three findings from the latest review (commit
Checks: @claude please re-review. Generated by Claude Code |
|
Claude finished @d-morrison's task in 3m 30s —— View job Code Review: PR #870 — Formal Procedure for Interpreting Regression Coefficients
SummaryAll three issues from the 2026-06-09 review have been correctly addressed in commit Verification of Fixes1. "as a function of
✅ Correctly fixed. "As a function of 2.
✅ Correctly fixed. Matches the 3. Conditional moved to front in step-3 header —
✅ Correctly fixed. The conditional now leads the imperative, preventing students from applying the step unconditionally. Positives
|
|
👀 Picked up by workflow run #27813262878. R/Quarto/renv setup runs first (~3-5 min); Claude itself responds after that. |
|
Working tree is clean — no code changes needed for this review. Here's my response to post back on the PR thread: All three fixes from commit
I reviewed all six changed files and found no remaining issues:
PR is ready to merge. — posted by @claude post-step from workflow run |
Built to branch |
Draft PR opened by
@claudeto address #869.Triggered by workflow run.
Addresses #869.