Skip to content

test(estimation): use an over-dispersed fixture for the NB fits - #67

Merged
hyperpolymath merged 2 commits into
mainfrom
arena/01a0da7b-metamanifold-webui
Sep 25, 2026
Merged

hyperpolymath merged 2 commits into
mainfrom
arena/01a0da7b-metamanifold-webui

Conversation

@arena-ai-coding-agent

Copy link
Copy Markdown

Why

After #66, the fits run. Run 36194648664 shows the remaining 19 failures and 6 errors. They all come from one fixture in test/unit/test_estimation.jl: two of its three features fail inside MASS::glm.nb (n_tested = 1, n_failed = 2, status partial).

The fixture is under-dispersed: its variance is below its mean in every group block (taxon 1, group A: mean 10.2, variance 3.1; taxon 2, group B: mean 30.3, variance 1.5). Under a negative binomial model, variance = μ + μ²/θ ≥ μ, so the maximum-likelihood θ for this data is infinite. A direct likelihood fit of the old table gives θ = 2e8 to 2e17 for every taxon under both offsets. theta.ml then stops at its iteration limit, and the estimator marks the fit failed. That is the right behaviour, and this PR does not change it.

What

  • counts_effect is replaced by a table with the same written-in group means (10→40, 30→30, 50→5). Each block has a variance near μ + μ²/6, all counts are ≥ 1 (so RLE is defined), and the numbers are deterministic literals.
  • A comment explains why the fixture has to be over-dispersed and records the outside-R check.
  • CHANGELOG.md entry.

Evidence (outside R: there is no R/Julia in the authoring sandbox)

Two independent NB2 maximum-likelihood fits (a direct scipy likelihood and statsmodels NegativeBinomial) agree to 4 decimals, converge, and raise no warnings. The table uses the two offsets the tests use:

taxon offset slope log2FC θ p
t_up log lib size 1.4986 2.16 5.98 4e-14
t_flat log lib size 0.1578 0.23 7.63 0.34
t_down log lib size −2.0470 −2.95 11.97 4e-29
t_up RLE 1.5451 2.23 3.52 2e-10
t_flat RLE 0.2378 0.34 14.89 0.07
t_down RLE −2.0510 −2.96 2.99 1e-13

Every assertion in the testsets holds against these numbers: estimate ≈ log 4 ± 0.5, log2FC ≈ 2 ± 0.8, |flat| < 0.6, down < 0, p(up) < 0.01. The parity with glm.nb itself is what this PR's CI run checks.

@coderabbitai

coderabbitai Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: f29a9adb-925d-4559-801b-002cd44c613d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@hyperpolymath
hyperpolymath merged commit 17d8c0d into main Sep 25, 2026
3 of 5 checks passed
@hyperpolymath
hyperpolymath deleted the arena/01a0da7b-metamanifold-webui branch September 25, 2026 22:26
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.

1 participant