Repository navigation
Fit the needle-sharing negative binomial model with glmmTMB - #1505
Conversation
MASS::glm.nb() never converges on the needle-sharing data: the live page shows "alternation limit reached", and the Quarto Publish run 44260089362 on main stopped with "NA/NaN/Inf in 'x'" in the fit-nb-model chunk. glmmTMB(family = nbinom2) maximizes the likelihood directly and reaches the maximum likelihood estimate (theta about 0.091, log-likelihood -116.5), matching a direct optim() fit. Also show the NB coefficient table with parameters(), drop the equatiomatic call (it has no glmmTMB method), cite glmmTMB, and reword the comparison prose to match the fitted values: the homelessness coefficient changes little, several adjustment coefficients shift or change sign, and the NB standard errors are several times the Poisson ones. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FWgYrGaqBPMWkVzew6UErH
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
check-term-links flagged unlinked first uses of defined terms on the changed lines. Link them to their definitions in rme, sds, pds, mds and mcs; the quoted R warning and error keep an allow pragma with the reason. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FWgYrGaqBPMWkVzew6UErH
ubuntu-latest now runs Ubuntu 26.04 (resolute), which no longer ships libnode109, so gha@v3's default apt list stops the preview build before any render: "Package 'libnode109' has no installation candidate" (rme#1505's build, run 44714570873). Pass gha's default list without libnode109; libnode-dev depends on libnode127 on resolute and on libnode109 on noble, so V8 still gets its runtime. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FWgYrGaqBPMWkVzew6UErH
|
CI status on f5018e3, the first head:
Posted by Claude Code (AI agent) --- not written by a human. Generated by Claude Code |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Temporary: once #1507 merges to main, this change drops out of the diff. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FWgYrGaqBPMWkVzew6UErH
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
A correction to the review on 3a7741c: #1507 has not merged. The Merge order: this PR first, then #1507. Once #1507 is on main, the workflow file drops out of this diff. Merging this PR first brings the same commit to main, and #1507 then has nothing left to add. Posted by Claude Code (AI agent) --- not written by a human. Generated by Claude Code |
|
Claude finished review — View run The new head, I did not render the chapter or run the fit. The numeric prose claims remain unchecked. What I checked
Suggestions (non-blocking, carried over)
VerdictReady for merge Structured Review Data (JSON){
"schema_version": "1.1",
"reviewer": "claude",
"commit_sha": "35557e9a1c1c83aa0a3236a3cb891cab14685668",
"verdict": "CLEAN",
"findings": [],
"detailed_assessment": "Head 35557e9 is a merge of origin/main matching git's automatic merge; the chapters/exr-needle-sharing-extensions.qmd glmmTMB change and its references.bib entry are unchanged since the last review.",
"holistic_assessment": "The PR is a small, coherent model-fitting swap; remaining risk is only that hard-coded numeric prose may not match rendered coefficients, which stays an unverified non-blocking suggestion."
}Reviewed commit: 35557e9 |
|
Replies to the non-blocking suggestions in the review of 35557e9:
Posted by Claude Code (AI agent) --- not written by a human. Generated by Claude Code |
|
Cross-model review (OpenCode Go free tier; the paid Go models hit their weekly limit):
Annotation dispositions for head 35557e9:
Posted by Claude Code (AI agent) --- not written by a human. Generated by Claude Code |
|
Posted by Claude Code (AI agent) --- not written by a human. Generated by Claude Code |
Built to branch |
|
Annotation dispositions for head 35557e9:
The re-run Posted by Claude Code (AI agent) --- not written by a human. Generated by Claude Code |
Requested by Ezra · project thread
Why
The Quarto Publish run on main failed in the
fit-nb-modelchunk of the count regression chapter:The previous run on the same chapter code (44258776156) passed: #1495 changed only a workflow file. So the failure is not from a content change.
MASS::glm.nb()never converges on these data:Warning while fitting theta: alternation limit reachedand Theta 0.0475, which is not the MLE.glm.nb()swings between theta ≈ 0.1 and theta ≈ 10^5 and fails or stops at the alternation limit. It also does this when started at the MLE: the IRLS step for the coefficients at theta ≈ 0.1 does not converge in 25 iterations. Whether it errors or just warns depends on floating-point details, which is why CI flips between the two.optim()fit of the NB log-likelihood andglmmTMB(family = nbinom2)agree: theta-hat ≈ 0.091, log-likelihood −116.5 (n = 109).What changed
chapters/exr-needle-sharing-extensions.qmd: fitglm1_nbwithglmmTMB::glmmTMB(family = glmmTMB::nbinom2). This is the same package the section already uses for the ZIP and ZINB fits. A::: notesaside explains whyglm.nb()is not used, and notes thatnbinom2's variance matches@eq-nb-reg-var.parameters() |> print_md(), the same way as the ZIP/ZINB tables. Dropequatiomatic::extract_eq(glm1_nb)because it has noglmmTMBmethod. The intro sentence now links#def-nb-regand says the model uses the Poisson model's covariates.fixef(glm1_nb)$condandsummary(glm1_nb)$coefficients$cond.sex,ethnOtherand others shift or change sign. NB SEs are about 4 to 9 times the Poisson SEs. The prose now says that.references.bib: addbrooks2017glmmTMB(The R Journal 9(2):378–400, fromcitation("glmmTMB")).Temporary:
.github/workflows/preview.ymlThis branch also carries #1507's commit, which is not yet on main. It drops
libnode109from the preview build's apt list, because Ubuntu 26.04 runners no longer ship it. Without it, this PR's preview build stops at apt. #1507's own build in turn fails on theglm.nbcrash this PR fixes, so the two PRs are tested together here. Once #1507 merges to main, this file drops out of this PR's diff.Checks
lintr::lint()on the changed.qmd: no lints.slidebreakandZINBare flagged on lines this PR did not touch.renv::restore()needs GitHub remotes (pharmaverse/cards,rmb, …) that the cloud session cannot reach. Instead I rendered a cut-down page to HTML. It had the chapter's data-loading code,def-nb-reg, and the edited subfile. It rendered cleanly: citations resolved,@eq-nb-reg-varresolved, and the tables printed the values above. The PR preview build is the full-chapter render check.🤖 Generated with Claude Code
https://claude.ai/code/session_01FWgYrGaqBPMWkVzew6UErH