Skip to content

stats: R formula reporting — single-string formulas, surface the silent glmer/clmm main-effects fallback - #41

Open
ChrisW09 wants to merge 1 commit into
mainfrom
fix/r-formula-reporting
Open

stats: R formula reporting — single-string formulas, surface the silent glmer/clmm main-effects fallback#41
ChrisW09 wants to merge 1 commit into
mainfrom
fix/r-formula-reporting

Conversation

@ChrisW09

Copy link
Copy Markdown
Collaborator

Fixes #8.

Bug 1 — formula arrives as a JSON array. deparse splits at width.cutoff=60, so any formula longer than 60 chars (five main effects, or any (a+b+c)^2 interaction fit) became a character vector, jsonlite::toJSON(auto_unbox=TRUE) emitted a JSON array, and show() rendered a Python list verbatim. Reproduced with the installed R:

bare deparse: {"f":["verdict ~ (1 | input_id) + model + prompt + retrieval + reranker + ","    chunking"]}
collapsed:    {"f":"verdict ~ (1 | input_id) + model + prompt + retrieval + reranker + chunking"}

Both scripts now emit gsub("\\\\s+", " ", paste(deparse(form), collapse = " ")).

Bug 2 — silent interaction fallback. When the order-2 glmer fails to converge, glmm.R refits main effects and reports used_order, but logistic.py ignored the payload and displayed the requested order (verdict ~ (1|input_id) + (A+B)^2) with no warning — an absent A × B row read as "estimated, coefficient absent" instead of "not fit". clmm.R had the same silent fallback. Both scripts now emit used_order; logistic.py uses 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 with ordinal/lme4 installed 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

- 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

stats: R-layer formula reporting — silent glmer main-effects fallback; long formulas arrive as JSON arrays

1 participant