Repository navigation
Drivers: negative-binomial model of catches (#54) - #108
Merged
Merged
Conversation
A joint model of sharks per gillnet set: negative binomial with log(net-hours) as the offset, a natural-spline day of season, nursery and season effects (each against the average) and nine environment terms per +1 SD, fitted per species. New "All together" section on /drivers with forest plots (new ForestPlot chart), the adjusted seasonal curve, and a sea-temperature step-by-step comparison; a live finding reports how the raw SST link changes once the calendar is in the model. glm.ts holds a small generic NB/Poisson GLM (IRLS, ML theta, Wald contrasts, natural spline basis) with tests on simulated data. seasonDayLabel moves to #lib/format so pages can use it. Closes #54 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Luen
added a commit
that referenced
this pull request
Nov 3, 2026
Both branches added blocks at the same spots in stats.ts (normalP vs the chi-square helpers), findings.ts (catch-model vs lavage finding) and AGENTS.md; kept both. Restores the normalP assertions in stats.test.ts now that both helpers are on one branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Luen
added a commit
that referenced
this pull request
Nov 3, 2026
AGENTS.md: both sides added a repo-map line and a section before "Adding a new season"; kept both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
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.
Closes #54.
What
A joint model of catches on /drivers ("All together: a model of catches"):
log(net-hours)as the offset, natural cubic spline for day of the season, nursery and season as effect-coded fixed effects (each level vs the average), and nine environment terms per +1 SD (SST, moon illumination, tide height, wind, rain 24 h, cloud, waves, net-in vs sunset, crew size). Fitted for blacktips and sicklefin lemons separately; a species gets a nursery effect only where ≥ 10 of it were caught.ForestPlotcomponent: rate ratios with 95% intervals on a log scale, CSV download, tooltips, labels wrap on phones):sst-calendar: computed live; it only appears when the raw SST link is clearly negative and SST rises through the season.What it shows (real data, computed live)
The −0.19 Spearman link between SST and catch rate (the strongest single correlate) is the calendar. Alone, each +1 °C goes with ~25% fewer sharks per net-hour. With day of the season in the model, the rate ratio is 1.00 (0.85–1.18). Nursery and season effects are large; among the environment terms, only net-in time vs sunset and tide height clear 1 for all sharks. The page copy builds these statements from the numbers, so none are hard-coded.
Notes
glm.tsis a small generic NB/Poisson GLM (IRLS + ML θ, Wald contrasts viacontrast, natural spline basis). Tests check coefficient and θ recovery on simulated NB data, the Poisson pooled rate, Cholesky inversion and spline linearity.seasonDayLabelmoves to#lib/format(re-exported fromanalytics/common) so pages can label season days.Checks
pnpm lint,pnpm check,pnpm test(70),pnpm build,pnpm test:e2e(29), axe on real-data /drivers, desktop + 375 px layout checked in the browser. No importer change.🤖 Generated with Claude Code