Repository navigation
Biology: sex ratio by nursery and season with a binomial mixed model (#117) - #121
Merged
Merged
Conversation
…117) - analytics/glmm.ts: logistic regression with crossed random intercepts, Laplace approximation (PIRLS as lme4's nAGQ = 0, SDs by Nelder-Mead), and a boundary-corrected likelihood-ratio test per random effect. Tested on an exact logistic case and simulated crossed designs. - analytics/sex.ts: one row per individual at its first capture, nursery and season as random effects, per species; typical share, SDs, tests and each nursery's estimate. - /morphometrics#sex: model summary, female share by nursery (nurseries with >= 20 sharks), and the season test on the per-season charts. - Sex-ratio findings say whether nurseries differ, from the model. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 3, 2026
Luen
added a commit
that referenced
this pull request
Nov 3, 2026
Keep both findings imports and repo-map lines. The mixed-model tests on the /morphometrics sex charts move from notes to the ChartCard stats line, and the per-nursery charts get one too. 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 #117.
What
A mixed model of sex for individually identified sharks:
Unit: each shark is counted once, at its first capture.
Random effects: the nursery and the season of that capture, as crossed random intercepts, fitted per species.
Model type: because the outcome is female yes/no, this is the logistic (binomial) form of a linear mixed model.
analytics/glmm.tsis a new, generic fitter:glmer(nAGQ = 0)) and choosing the standard deviations by Nelder–Mead;Validation (
glmm.test.ts): R isn't available in CI, so the fitter is checked against:I also checked recovery over six simulated seeds per scenario. For true SDs of 1/0, 0.5/0.3 and 0/0, the estimates were 0.70–1.36/0, 0.37–0.67/0.25–0.42 and about 0/0, with the tests matching each case.
analytics/sex.tsruns the model per species and reports:/morphometrics#sex:Sex-ratio findings now say whether nurseries differ, from the model.
Results on the real data (as the page computes them)
Checks
pnpm lint,pnpm checkpnpm test: 80 passed, including 3 new GLMM tests🤖 Generated with Claude Code