Skip to content

formalize the procedure for determining how to interpret regression beta coefficients#870

Open
github-actions[bot] wants to merge 24 commits into
mainfrom
claude/issue-869-20260603-010210
Open

formalize the procedure for determining how to interpret regression beta coefficients#870
github-actions[bot] wants to merge 24 commits into
mainfrom
claude/issue-869-20260603-010210

Conversation

@github-actions

@github-actions github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Draft PR opened by @claude to address #869.

Triggered by workflow run.

Addresses #869.

…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>
@github-actions github-actions Bot requested a review from d-morrison June 3, 2026 01:18
@d-morrison d-morrison marked this pull request as ready for review June 3, 2026 01:21
@d-morrison d-morrison closed this Jun 3, 2026
@d-morrison d-morrison reopened this Jun 3, 2026
@github-actions github-actions Bot requested review from d-morrison and removed request for d-morrison June 3, 2026 01:21
@claude

claude Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Claude finished @d-morrison's task in 2m 9s —— View job


Code Review: PR #870 — Formal Procedure for Interpreting Regression Coefficients

  • Gather context and changed files
  • Read all changed files
  • Review new content for correctness, conventions, and style
  • Post review findings

Summary

This PR introduces @def-coef-interp-procedure, a formal step-by-step procedure for deriving regression coefficient interpretations, and cross-references it in the logistic regression, Poisson, and Cox PH model chapters. The approach is pedagogically sound — placing a general reusable definition in the linear models chapter and pointing to it downstream is a good design. Overall the content is correct; I found a few issues below.


Issues

1. Missing required concrete example — convention violation

CLAUDE.md says: "After every definition or concept, include a concrete example — preferably numerical — to illustrate the abstract idea; use a {#exm-...} div."

The new :::{#def-coef-interp-procedure} block is not followed by an {#exm-...} example. The parallel-lines birthweight model (@eq-lm-parallel) is available in the same chapter and would serve naturally here: walk through the procedure step by step for $\beta_M$ and $\beta_A$ as a concrete illustration.

Fix this →


2. "differencing" vs. "differentiating" in _sec-understand-coxph.qmd

The added sentence (line 265) reads:

Applying @def-coef-interp-procedure to the log-hazard linear predictor … (differencing with respect to $x_j$ with all other covariates held fixed) …

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.

Fix this →


3. Step 4 phrasing is unclear

Step 4 (_sec_linreg_coef_interp_procedure.qmd, line 35–36):

Solve for $\b_j$ by symmetry of equality: reverse the equation to read $\b_j = \cdots$

"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, $\b_j$ is already isolated — so the "equation" being reversed is the result of the differentiation/differencing, not an intermediate expression. Suggested rewrite:

Identify $\b_j$: the simplified expression equals $\b_j$; write $\b_j = \text{[that expression]}$ to state the interpretation.

Fix this →


4. Non-standard notation for discrete difference (minor)

In step 2b (_sec_linreg_coef_interp_procedure.qmd, line 20):

$\eta(\vx)\big|_{x_j \,\to\, x_j+1} - \eta(\vx)\big|_{x_j}$

The subscript-arrow notation $x_j \to x_j+1$ is non-standard. Consider the more conventional evaluation notation $\eta(\vx)\big|{x_j = a+1} - \eta(\vx)\big|{x_j = a}$, which is already used in the solutions elsewhere in the chapter (e.g., the parallel-lines model solutions).


5. Extra blank line in _sec_poisson_RRs.qmd (cosmetic)

The diff shows:

+Applying @def-coef-interp-procedure...
+
 
 ::: notes

This leaves two consecutive blank lines before the ::: notes block. Pandoc treats consecutive blank lines as a single paragraph break so it renders fine, but the extra blank line is untidy.


Minor positives

  • The notes section correctly explains the linear predictor scale vs. outcome scale distinction, and the clarification about reference level coding (line 53–57) is a useful addition.
  • Placement of the general procedure before the specific coefficient interpretation section in _sec_linreg_understanding.qmd is the right pedagogical order.
  • The cross-reference hint added to _exm_wcgs_coef_interp.qmd is a nice touch that connects the exercise to the general framework.
  • The cross-references in _sec_derivs_MLE.qmd appropriately distinguish the "interpret $\beta_j$" differentiation from the "find $\hat\beta$" MLE differentiation.

Comment thread _subfiles/Linear-models-overview/_sec_linreg_coef_interp_procedure.qmd Outdated
@github-actions github-actions Bot requested a review from d-morrison June 3, 2026 01:24
@d-morrison

Copy link
Copy Markdown
Owner

@claude address review comments

@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

👀 Picked up by workflow run #26870912489. R/Quarto/renv setup runs first (~3-5 min); Claude itself responds after that.

@d-morrison

Copy link
Copy Markdown
Owner

@claude note that the intercept term, if present, is special; it requires no differentiating or differencing, just setting all covariates to their reference values

@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

👀 Picked up by workflow run #26870995112. R/Quarto/renv setup runs first (~3-5 min); Claude itself responds after that.

@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

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:

  1. Concrete example ({#exm-coef-interp-procedure}) walking through the birthweight model
  2. Fixed "differencing" → "differentiating or differencing" in the Cox section
  3. Step 4 rephrased to "Identify $\b_j$"
  4. Conventional notation for discrete difference: $\eta(\vx)\big|_{x_j = a+1} - \eta(\vx)\big|_{x_j = a}$
  5. Extra blank line removed from Poisson RRs file
  6. d-morrison's inline suggestion: Step 3 now reads "Set any remaining covariates to their reference levels"
  7. Intercept special case added per d-morrison's comment

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:

Special case --- intercept ($\b_0$): If the coefficient of interest is the intercept $\b_0$, skip step 2. Apply step 3 directly by setting all covariates to their reference levels: $\b_0 = \eta(\text{reference pattern})$.

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

@github-actions github-actions Bot removed the request for review from d-morrison June 3, 2026 16:35
@claude

claude Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Claude finished @d-morrison's task in 3m 42s —— View job


Code Review: PR #870 — Formal Procedure for Interpreting Regression Coefficients

  • Read all changed files
  • Review content for correctness, conventions, and style
  • Post review findings

Summary

The PR introduces @def-coef-interp-procedure, a formal step-by-step procedure for deriving regression coefficient interpretations, backed by a concrete birthweight example, and cross-references it in the logistic, Poisson, and Cox chapters. The procedure logic is correct and the intercept special case (added per d-morrison's comment) is well-handled. Three issues found below.


Issues

1. \\\\ in aligned equation — likely rendering bug

_subfiles/Linear-models-overview/_sec_linreg_coef_interp_procedure.qmd, line 85:

\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 \\ for line breaks in \ba...\ea aligned environments (see _sec-understand-coxph.qmd lines 44–55, _sec_linreg_understanding.qmd lines 395–404). The \\\\ here passes four backslashes to MathJax/LaTeX, which renders as a double line break — leaving extra vertical whitespace between the two rows. Should be \\.

Fix this →


2. \beta vs \b macro inconsistency within the file

CLAUDE.md says: "Use custom macros from latex-macros/macros.qmd instead of raw LaTeX. Key macros: \b"

The #def-coef-interp-procedure block correctly uses \b_j, \b_0, \b_M, \b_A throughout. But the #exm-coef-interp-procedure block switches to raw \beta_0, \beta_M, \beta_A (lines 71–95). The example should use \b_0, \b_M, \b_A to be consistent with both the definition above it and the project convention.

Fix this →


3. E[...] vs \E{...} macro inconsistency in example

Same file, same block — the example uses plain E[Y|M=m, A=a] (lines 71, 77, 90, 95) instead of \E{Y|M=m, A=a} (the custom macro used in the definition block at line 49: $\eta(\vx) = \E{Y|\vx}$). Per project conventions, \E{...} should be used.

Fix this →


4. Double blank line in _sec_derivs_MLE.qmd (cosmetic)

The diff shows two consecutive blank lines between the new cross-reference sentence and **In order to interpret $\beta_j$**:. Should be one blank line.


Positives

  • Procedure logic is correct across all model types (linear, logistic, Poisson, Cox).
  • Intercept special case is cleanly placed inside #def-coef-interp-procedure and demonstrated in the example.
  • Cox parenthetical correctly says "differentiating or differencing … depending on whether $x_j$ is continuous or discrete" (properly precise, not just "differencing").
  • Step 4 uses clear "Identify $\b_j$" phrasing; Step 3 uses d-morrison's suggested wording "Set any remaining covariates to their reference levels."
  • Evaluation notation for discrete difference uses standard form: $\eta(\vx)\big|_{x_j = a+1} - \eta(\vx)\big|_{x_j = a}$.
  • The _sec_derivs_MLE.qmd callout clearly distinguishes interpretation differentiation (linear predictor) from MLE differentiation (log-likelihood).
  • Notes correctly explain the linear predictor scale vs. outcome scale distinction, including the non-arbitrariness of the reference level substitution.

@github-actions github-actions Bot requested a review from d-morrison June 3, 2026 16:40
@d-morrison

Copy link
Copy Markdown
Owner

@claude move sec-coef-interp-procedure after compare-coefficient-interpretations

@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

👀 Picked up by workflow run #26899143416. R/Quarto/renv setup runs first (~3-5 min); Claude itself responds after that.

@d-morrison

Copy link
Copy Markdown
Owner

@claude address review comments

@github-actions github-actions Bot removed the request for review from d-morrison June 5, 2026 22:37
@claude

claude Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Claude finished @d-morrison's task in 5m 35s —— View job


Code Review: PR #870 — Formal Procedure for Interpreting Regression Coefficients

  • Gather context and read changed files
  • Review content for correctness, conventions, and style
  • Post review findings

Summary

Both issues flagged in the previous review (2026-06-05T00:49:51Z) have been addressed:

  • (Step 3 not needed: …) notes added to the example ✓
  • {{< slidebreak >}} used instead of --- in _sec_linreg_understanding.qmd

The procedure logic is correct, macro usage is consistent, and notation matches project conventions throughout. Two minor items remain below.


Issues

1. Step 3 note for \b_M may confuse readers (minor)

_subfiles/Linear-models-overview/_sec_linreg_coef_interp_procedure.qmd, lines 91–92:

so $\b_M = \E{Y|M=1, A=a} - \E{Y|M=0, A=a}$.
(Step 3 not needed: $a$ cancels in the differencing.)

The note correctly explains that step 3 is skipped, but a reader following the procedure step-by-step will notice that a still appears on line 91 and may wonder: "if $a$ cancels, why is it still here?" The note would be clearer with an addendum explaining that the result holds for any value of A. Suggested replacement:

(Step 3 not needed: $a$ cancels in the differencing, so the result holds for all values of $A$.)

Fix this →


2. Heading case inconsistency (cosmetic)

The ### section heading added to _subfiles/Linear-models-overview/_sec_linreg_understanding.qmd (line 684) uses title case:

### General Procedure for Interpreting Coefficients

But the #### heading inside #def-coef-interp-procedure uses sentence case:

#### General procedure for interpreting a regression coefficient

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.

Fix this →


Positives

  • All previous findings fully addressed (step-3 notes, {{< slidebreak >}}, \b_*/\E{...} macros, \\ not \\\\, intercept special case, differentiating/differencing distinction).
  • Cox sentence correctly uses \diffloghaz(\vx) = \reglincomb notation, consistent with _def-difflog-hazard-from-baseline.qmd and _coxph-model-structure.qmd.
  • @def-coef-interp-procedure cross-reference placed correctly in all four downstream files (Poisson, logistic exercise, logistic MLE callout, Cox).
  • _sec_derivs_MLE.qmd callout clearly distinguishes interpretation differentiation (linear predictor) from MLE differentiation (log-likelihood).
  • _sec_linreg_coef_interp_procedure.qmd macro include pattern is consistent with sibling subfiles.

@d-morrison

Copy link
Copy Markdown
Owner

@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:")

@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

👀 Picked up by workflow run #27043881934. R/Quarto/renv setup runs first (~3-5 min); Claude itself responds after that.

@github-actions github-actions Bot requested a review from d-morrison June 5, 2026 22:43
@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

I'm on main and can't access the PR branch without git fetch/git checkout (blocked by permissions in this context). Since this is a prose+code PR trigger where the file lives on a non-checked-out branch, I'll write my full response as a PR comment. The post-step will post it.

Here's my response:


Explanation: how the exr-interaction-coef solution follows the procedure

The solution works through @def-coef-interp-procedure in order, applying step 2 twice (once per variable in the product):

Procedure step What the solution does
Step 1: Write down the linear predictor $\eta(m,a) = \b_0 + \b_M m + \b_A a + \b_{AM} \cdot m \cdot a$ (the interaction model, implicit)
Step 2a (first pass, w.r.t. $a$ — continuous) "Slope among males": $\deriv{a}\mu(1,a) = \b_A + \b_{AM}$
"Slope among females": $\deriv{a}\mu(0,a) = \b_A$
Step 2b (second pass, w.r.t. $m$ — discrete) "Difference in slopes": $(\b_A + \b_{AM}) - \b_A = \b_{AM}$
Step 3: Set remaining covariates to reference Not needed — $a$ cancels in the difference; no remaining covariates appear
Step 4: State $\b_{jk} = \cdots$ "Therefore $\b_{AM} = \deriv{a}\mu(1,a) - \deriv{a}\mu(0,a) = \ldots$"

The solution's three labeled sections map directly onto the two sub-applications of step 2:

  • "Slope among males" and "Slope among females" = step 2a applied at each value of $m$
  • "Difference in slopes" = step 2b (differencing those slopes w.r.t. $m$)

Proposed revision to the procedure

The current interaction-coefficient note says:

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 of $x_j$" and "difference in slopes" to match the solution's structure):

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$ (which will depend on $x_k$), then differentiate or difference that slope with respect to $x_k$ to obtain the difference in slopes, which equals $\b_{jk}$.

I've written the updated file locally but couldn't commit it to the PR branch (session checked out main rather than claude/issue-869-20260603-010210). The change is a one-for-one replacement of the 4-line interaction note in _subfiles/Linear-models-overview/_sec_linreg_coef_interp_procedure.qmd. Everything else in the file is unchanged.

— posted by @claude post-step from workflow run

@github-actions github-actions Bot removed the request for review from d-morrison June 5, 2026 23:53
@claude

claude Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Claude finished @d-morrison's task in 2m 57s —— View job


Code Review: PR #870 — Formal Procedure for Interpreting Regression Coefficients

  • Gather context and understand the request
  • Read the current procedure file and exr-interaction-coef solution
  • Review changed files for issues
  • Post explanation and proposed revision

How exr-interaction-coef follows the general procedure

The solution for $\b_{AM}$ applies step 2 twice in sequence — once per variable in the product $A \times M$:

Procedure step What the solution does
Step 1 — write down $\eta$ $\mu(m,a) = \b_0 + \b_M m + \b_A a + \b_{AM} m a$
Step 2a — differentiate w.r.t. $a$ (continuous) at $m=1$ "Slope among males": $\deriv{a}\mu(1,a) = \b_A + \b_{AM}$
Step 2a — differentiate w.r.t. $a$ at $m=0$ "Slope among females": $\deriv{a}\mu(0,a) = \b_A$
Step 2b — difference those slopes w.r.t. $m$ (discrete) "Difference in slopes": $(\b_A + \b_{AM}) - \b_A = \b_{AM}$
Step 3 — set remaining covariates Not needed: $a$ cancels in the differencing
Step 4 — state the result $\b_{AM} = \deriv{a}\mu(1,a) - \deriv{a}\mu(0,a)$

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}

Fix this →

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$.)

Fix this →


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.qmd hint correctly points students to apply the procedure to the log-odds linear predictor.

@github-actions github-actions Bot requested a review from d-morrison June 5, 2026 23:56
claude added 2 commits June 6, 2026 01:56
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.
@github-actions github-actions Bot removed the request for review from d-morrison June 6, 2026 01:56
@claude

claude Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Claude finished @d-morrison's task in 3m 47s —— View job


Code Review: PR #870 — Formal Procedure for Interpreting Regression Coefficients

  • Gather context
  • Read all changed files
  • Check recent commits for pending fixes
  • Review content for correctness, conventions, and style
  • Post review findings

Summary

All issues from every prior review round are resolved in the current branch (commit 074421c applied the three remaining nits: interaction-note wording, heading case, and step-3 completeness note). One substantive issue remains in the interaction coefficient note that was introduced by the d-morrison–requested revision.


Issues

1. Interaction note still says "difference" for the second step — but $x_k$ could be continuous

_subfiles/Linear-models-overview/_sec_linreg_coef_interp_procedure.qmd, lines 26–28:

   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}$.

The exr-interaction-coef solution has $x_j = A$ (continuous) and $x_k = M$ (discrete), so "difference those slopes" and "difference in slopes" fit that case. But the note is supposed to be general. For continuous $x_k$:

  • The slope $\b_j + \b_{jk} x_k$ is a function of $x_k$; the second application of step 2 should differentiate it, yielding $\b_{jk}$.
  • "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.
  • The label "difference in slopes" is misleading — for continuous $x_k$ it would be a derivative of the slope, not a finite difference.

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 $x_k$:

   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}$.

Fix this →


2. Step 3 header reads as unconditional (minor)

_sec_linreg_coef_interp_procedure.qmd, line 30:

Set any remaining covariates to their reference levels.

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."

Fix this →


Positives

  • All three nits from the 2026-06-05T22:37Z review applied in 074421c: interaction-note vocabulary ("slope of $x_j$" / "difference in slopes"), heading sentence-case, and $a$ cancels … so the result holds for all values of $A$ note.
  • Step-3 parentheticals in the example are clear and correctly distinguish the two sub-cases.
  • {{< slidebreak >}} used correctly; no --- separators in new content.
  • \b_* macros and \E{...} used consistently throughout both the definition and example blocks.
  • \\ (single line break) in the aligned example equation.
  • Intercept special case correctly placed inside #def-coef-interp-procedure and demonstrated in the example.
  • Cox parenthetical correctly says "differentiating or differencing … depending on whether $x_j$ is continuous or discrete."
  • Cross-references in Poisson, logistic exercise, logistic MLE callout, and Cox section are well-placed.
  • Section placed after ### Compare coefficient interpretations as requested.

@github-actions github-actions Bot requested a review from d-morrison June 6, 2026 02:01
claude added 2 commits June 9, 2026 07:54
- 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.
@github-actions github-actions Bot removed the request for review from d-morrison June 9, 2026 07:55
@claude

claude Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Claude finished @d-morrison's task in 3m 35s —— View job


Code Review: PR #870 — Formal Procedure for Interpreting Regression Coefficients

  • Gather context
  • Read all changed files
  • Review content for correctness, conventions, and style
  • Post review findings

Summary

The 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.


Issues

1. "at each value of $x_k$" in the interaction note is still wrong for continuous $x_k$ (unfixed from prior review)

_subfiles/Linear-models-overview/_sec_linreg_coef_interp_procedure.qmd, line 26:

   to obtain the **slope of $x_j$** at each value of $x_k$;

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 \\\\\\, \beta_*\b_*, and "difference in slopes" → "change in slopes", but this specific phrase was not changed. Current text still reads "at each value of $x_k$" rather than the suggested "(which is a function of $x_k$)".

Suggested replacement for line 26:

   to obtain the **slope of $x_j$** (which is a function of $x_k$);

Fix this →


2. \log\lambda(\vx) should be \logf{\lambda(\vx)} — macro inconsistency

_subfiles/count-regression/_sec_poisson_RRs.qmd, line 1 (new sentence):

$\eta(\vx) = \log\lambda(\vx)$

The rest of this file uses \logf{...} throughout (lines 19–22: \logf{\E{Y|...}}, \logf{t}). The project macro \logf is defined at latex-macros/macros.qmd line 288. The new sentence uses bare \log instead.

Fix: $\eta(\vx) = \logf{\lambda(\vx)}$

Fix this →


3. Step-3 header: conditional parenthetical at the end is slightly awkward (minor)

_sec_linreg_coef_interp_procedure.qmd, line 31:

3. **Set any remaining covariates to their reference levels (if any remain)**.

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

  • All issues from every previous review round are resolved.
  • "at each value" was the one outstanding item from the 2026-06-06T01:57 review; everything else from that round (interaction wording, heading case, step-3 completeness note) was applied in commit 074421c.
  • \b_* macros and \E{...} used consistently throughout both definition and example blocks.
  • {{< slidebreak >}} correctly used; \\ (not \\\\) in aligned example equation.
  • Intercept special case cleanly placed inside #def-coef-interp-procedure and demonstrated in the example.
  • "(choosing continuous/discrete as appropriate for $x_k$)" and "change in slopes" correctly generalize the interaction note for both variable types.
  • Cox parenthetical correctly distinguishes "differentiating or differencing … depending on whether $x_j$ is continuous or discrete."
  • Section placed after ### Compare coefficient interpretations as requested; sentence-case heading matches the #### heading inside the definition.
  • Cross-references in logistic MLE callout, Poisson RRs, logistic exercise hint, and Cox section are all well-placed and accurate.

@github-actions github-actions Bot requested a review from d-morrison June 9, 2026 07:59
claude added 2 commits June 19, 2026 07:55
- 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

Copy link
Copy Markdown
Owner

Addressed all three findings from the latest review (commit e4d382d, main merged in):

  • Address (substantive) — _sec_linreg_coef_interp_procedure.qmd:26: "slope of $x_j$ at each value of $x_k$" → "as a function of $x_k$". For continuous $x_k$ the slope is a function of $x_k$, not something evaluated at finite levels; "as a function of" is correct for both continuous and discrete $x_k$.
  • Address (macro consistency) — _sec_poisson_RRs.qmd:1: \log\lambda(\vx)\logf{\lambda(\vx)}, matching the \logf{…} convention used elsewhere in that file.
  • Address (minor) — _sec_linreg_coef_interp_procedure.qmd:31: moved the conditional to the front — "If any covariates remain, set them to their reference levels".

Checks: lintr::lint() ✓ on both files; spelling::spell_check_package() ✓; the two edited subfiles render cleanly (verified in an isolated include wrapper — neither edit touches R code; the full count-regression/Linear-models-overview chapter render depends on the GitHub-only dobson/rmb packages, which are outside this session's repo scope, so the CI build job is the full-render gate there).

@claude please re-review.


Generated by Claude Code

@github-actions github-actions Bot removed the request for review from d-morrison June 19, 2026 07:58
@claude

claude Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Claude finished @d-morrison's task in 3m 30s —— View job


Code Review: PR #870 — Formal Procedure for Interpreting Regression Coefficients

  • Gather context and understand the request
  • Read all changed files
  • Verify d-morrison's three fixes from commit e4d382d
  • Review for any remaining or new issues
  • Post review findings

Summary

All three issues from the 2026-06-09 review have been correctly addressed in commit e4d382d. I found no remaining issues. The PR is ready to merge.


Verification of Fixes

1. "as a function of $x_k$" (substantive)_sec_linreg_coef_interp_procedure.qmd:26

to obtain the slope of $x_j$ as a function of $x_k$;

✅ Correctly fixed. "As a function of $x_k$" is accurate for both continuous and discrete $x_k$; the previous "at each value of $x_k$" was wrong for continuous $x_k$.

2. \logf{\lambda(\vx)} (macro consistency)_sec_poisson_RRs.qmd:1

$\eta(\vx) = \logf{\lambda(\vx)}$

✅ Correctly fixed. Matches the \logf{...} convention used throughout the rest of that file (lines 19–22).

3. Conditional moved to front in step-3 header_sec_linreg_coef_interp_procedure.qmd:31

If any covariates remain, set them to their reference levels.

✅ Correctly fixed. The conditional now leads the imperative, preventing students from applying the step unconditionally.


Positives

  • All issues from all five previous review rounds are resolved.
  • \logit(\pi(\vx)) in the exercise hint is consistent with the \logit(...) pattern used throughout the logistic regression files.
  • \b_* macros and \E{...} used consistently throughout both definition and example blocks (no raw \beta_* in new content).
  • \\ (not \\\\) in the aligned example equation.
  • {{< slidebreak >}} (not ---) for the new section separator in _sec_linreg_understanding.qmd.
  • Sentence-case heading ### General procedure for interpreting coefficients matches the #### heading inside the definition block.
  • Intercept special case correctly placed inside #def-coef-interp-procedure and demonstrated in the example.
  • The interaction note correctly says "as a function of $x_k$" for the slope, "(choosing continuous/discrete as appropriate for $x_k$)" for the second differentiation/differencing, and "change in slopes" as an accessible label for the result — all three jointly handle both continuous and discrete $x_k$ correctly.
  • Step-3 parentheticals in the example are clear: "no remaining covariates appear after differentiating" for $\b_A$; "$a$ cancels in the differencing, so the result holds for all values of $A$" for $\b_M$.
  • Cross-references in Poisson, logistic exercise, logistic MLE callout, and Cox section are all well-placed.

@github-actions

Copy link
Copy Markdown
Contributor Author

👀 Picked up by workflow run #27813262878. R/Quarto/renv setup runs first (~3-5 min); Claude itself responds after that.

@github-actions github-actions Bot requested a review from d-morrison June 19, 2026 08:02
@github-actions

Copy link
Copy Markdown
Contributor Author

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 e4d382d are correctly applied:

  1. _sec_linreg_coef_interp_procedure.qmd:26 — "as a function of $x_k$" is in place. Correct and general: works for both continuous (where the slope literally is a function) and discrete $x_k$.

  2. _sec_poisson_RRs.qmd:1\logf{\lambda(\vx)} macro in use, consistent with the rest of the file.

  3. _sec_linreg_coef_interp_procedure.qmd:31 — Step 3 heading leads with the conditional: "If any covariates remain, set them to their reference levels."

I reviewed all six changed files and found no remaining issues:

  • The interaction-coefficient paragraph in the procedure is mathematically correct; "change in slopes" is the right umbrella term for both the continuous–continuous (mixed partial) and the continuous–discrete (difference-of-slopes) cases.
  • The cross-references added to _sec_derivs_MLE.qmd and _exm_wcgs_coef_interp.qmd point correctly to @def-coef-interp-procedure and describe the right step to apply.
  • The Cox sentence (_sec-understand-coxph.qmd) correctly identifies $\eta(\vx) = \diffloghaz(\vx) = \reglincomb$ as the linear predictor and notes the continuous/discrete branching.
  • All macros (\b_j, \b_0, \deriv{}, \E{}, \ba/\ea, \logf{}, \logit) are used consistently.

PR is ready to merge.

— posted by @claude post-step from workflow run

@github-actions

Copy link
Copy Markdown
Contributor Author
PR Preview Action v1.8.1
🚀 Preview available at: https://d-morrison.github.io/rme/pr-preview/pr-870/

Built to branch gh-pages at 2026-06-19 08:15 UTC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants