Skip to content

Charts: statistics behind every trend and difference (#119, #118, #120) - #122

Merged
Luen merged 2 commits into
mainfrom
chart-stats
Nov 3, 2026
Merged

Luen merged 2 commits into
mainfrom
chart-stats

Conversation

@Luen

@Luen Luen commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #119. Closes #118. Part of #120: the chart now tests the season swing; #120 stays open for the lab to say whether fieldwork changed in 2018-19.

Why

Many charts showed a trend, a relationship or a difference between groups with nothing to say whether it's real. The "Best moon for finding pups" finding picked the highest of eight raw catch rates, so it would always name some phase as best. On this dataset the phases don't differ, as Debaere et al. (2024) also found.

What

  • analytics/tests.ts picks the right test for each kind of chart and words it the same way everywhere:

    • Catch-rate differences: rateTest / rateText / rateSlopeText fit negative-binomial likelihood-ratio tests on timed sets, with log(net-hours) as the offset. They report the test raw and adjusted for nursery, season and a day-of-season spline; skip leaves out the factor being tested, and the text names only what was actually adjusted for.
    • Which groups stand out: rateEffects gives each group's adjusted rate ratio against the average group, with a 95% interval.
    • Other tests: Kruskal–Wallis (groupsText), χ² for shares (tableText), one-value-per-season linear trends with R² (trendText), linear fit with R² plus Spearman for scatters (fitText, rankText), and Welch's t-test (twoGroupText).
    • New in stats.ts: kruskal (with the tie correction) and pairedT.
  • ChartCard stats: a "Statistics" line under the chart, styled the same everywhere.

  • Pages covered:

    Charts that are purely descriptive (maps, calendars, logger coverage, inventories, word counts) have no test, and charts that already stated their test in a note keep it.

  • Findings:

  • Overview "Catch rate per season" (Analysis: why catch rates swing in 2018-19 (blacktips down, lemons up) #120): says whether seasons differ once nursery and day of the season are held fixed, and names the seasons whose 95% interval excludes the average.

Results on the real data (examples, all computed live)

  • Moon phase: no detectable difference (adjusted p ≈ 0.42); illumination and "moon up" don't matter either.
  • Seasons:
    • blacktips differ (p ≈ 0.03): 2018–19 ≈ 0.76× and 2025–26 ≈ 0.74× the average season;
    • lemons differ (p < 0.001): 2018–19 ≈ 2.3× and 2019–20 ≈ 2.0×, while 2015–16, 2023–24 and 2025–26 are low;
    • neither species has a linear trend over the 12 seasons.
  • Crew size: looks significant raw (p ≈ 0.002) but not once adjusted for nursery, season and day of the season (p ≈ 0.94). The same calendar confounding that Analysis: negative-binomial GLM/GAM of catch with effort offset #54 found for sea temperature.
  • Human pressure: 2 of 16 nursery-level correlations reach p < 0.05; the stats line also reports how many pass a Bonferroni correction, so the result isn't overstated.

Notes

Checks

  • pnpm lint, pnpm check
  • pnpm test: 82 passed. New tests:
    • Kruskal–Wallis and paired t against hand-computed values;
    • rateTest detects a simulated 2× difference, finds none under the null, and labels the adjustment correctly;
    • the wording helpers.
  • Opt-in real-data test
  • pnpm build && pnpm test:e2e: 31 passed, including axe in light and dark
  • Read every statistics line on 18 pages against the real data in the dev server

🤖 Generated with Claude Code

- analytics/tests.ts: negative-binomial likelihood-ratio tests of catch
  rates (raw and adjusted for nursery, season and day of the season, naming
  what was adjusted), per-group rate ratios, and worded Kruskal-Wallis, chi2,
  trend, linear-fit/Spearman and Welch tests. stats.ts gains kruskal and
  pairedT.
- ChartCard `stats` line, used on the overview, seasons, nurseries, nursery
  profiles, morphometrics, neonates, growth, recaptures, physiology, drivers,
  ocean, tides, moon, time of day, pressure, effort, water quality and adults.
- Moon finding (#118): names a best phase only when the phases differ beyond
  chance; otherwise reports no effect, as Debaere et al. (2024) did.
- Overview catch rate per season (#120): adjusted season test and the
  seasons whose interval excludes the average (2018-19 and 2019-20 lemons).
- Nursery, weekend and heat-stress findings report their tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Luen Luen added analytics Charts, statistics and analyses design Visual design, theme and charts findings Interesting, quirky and fun findings labels 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>
@Luen
Luen merged commit ebf5a0b into main Nov 3, 2026
5 checks passed
@Luen
Luen deleted the chart-stats branch November 3, 2026 23:20
@Luen Luen mentioned this pull request Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

analytics Charts, statistics and analyses design Visual design, theme and charts findings Interesting, quirky and fun findings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Charts: back up trends and differences with statistics (R², p) Findings: 'Best moon for finding pups' picks the best of eight phases without a test

1 participant