stats: R formula reporting — single-string formulas, surface the silent glmer/clmm main-effects fallback - #41
Open
ChrisW09 wants to merge 1 commit into
Open
stats: R formula reporting — single-string formulas, surface the silent glmer/clmm main-effects fallback#41ChrisW09 wants to merge 1 commit into
ChrisW09 wants to merge 1 commit into
Conversation
- Both R scripts serialized the formula with a bare deparse(), which splits at 60 characters — a five-factor formula became a character vector, jsonlite emitted a JSON array, and show() rendered a Python list verbatim in the paper-facing report. Now collapsed to one whitespace-normalized string. - glmm.R already fell back to main effects when the interaction model didn't converge, but logistic.py displayed the REQUESTED order's formula and never surfaced the fallback — missing interaction rows read as 'estimated, coefficient absent'. Both scripts now emit used_order; both Python consumers use the payload formula and append an explicit 'interactions not estimable' warning on fallback (matching the Gaussian layer's behavior). Fixes #8 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #8.
Bug 1 — formula arrives as a JSON array.
deparsesplits atwidth.cutoff=60, so any formula longer than 60 chars (five main effects, or any(a+b+c)^2interaction fit) became a character vector,jsonlite::toJSON(auto_unbox=TRUE)emitted a JSON array, andshow()rendered a Python list verbatim. Reproduced with the installed R:Both scripts now emit
gsub("\\\\s+", " ", paste(deparse(form), collapse = " ")).Bug 2 — silent interaction fallback. When the order-2
glmerfails to converge, glmm.R refits main effects and reportsused_order, butlogistic.pyignored the payload and displayed the requested order (verdict ~ (1|input_id) + (A+B)^2) with no warning — an absentA × Brow read as "estimated, coefficient absent" instead of "not fit". clmm.R had the same silent fallback. Both scripts now emitused_order;logistic.pyuses the payload formula and both consumers append an explicit "interactions not estimable — main effects only" warning, matching the Gaussian layer.Verification: the R packages (
ordinal/lme4) are not installed on this machine, so no live fit ran; verified instead by (a) reproducing the deparse array→string fix directly in R (above), (b)parse()-checking both edited scripts, (c) exercising the no-package JSON fallback path of both scripts, and (d) the full Python suite (R-dependent tests skip cleanly). A maintainer run withordinal/lme4installed would be a welcome double-check.Test: full cafe-core suite — 109 passed, 2 skipped (1 pre-existing failure = #4, fix in PR #34).
🤖 Generated with Claude Code