Skip to content

Document the simulated route to a serial interval for shared-trajectory models - #1246

Merged
sbfnk merged 6 commits into
mainfrom
issue-1223-serial-interval-from-a-shared-trajectory
Nov 25, 2026
Merged

sbfnk merged 6 commits into
mainfrom
issue-1223-serial-interval-from-a-shared-trajectory

Conversation

@sbfnk-bot

@sbfnk-bot sbfnk-bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

serial_interval(model, infector, infectee) stays analytic. It does not yet handle a model whose onset and infectiousness share a within-host trajectory, and the docstring says so. For now, fit a distribution to realised_serial_intervals(states) of simulated states. The tutorial on calibrating a trajectory says that serial_interval does not yet handle such a model, so it throws.

The error for a per-case generation time, which a trajectory-driven kernel gives, now ends with a conditional pointer to realised_serial_intervals. The errors for a missing or per-case incubation period keep their original messages.

Checked with test/test_serial_interval.jl, including new tests that the trajectory model's error names realised_serial_intervals and that the missing-incubation error does not. I did not run the docs build. No new function is added, so there is no seeding question.

This PR closes #1223.

sbfnk-bot and others added 3 commits November 24, 2026 23:10
…oute

Co-authored-by: sbfnk <sebastian.funk@lshtm.ac.uk>
Co-authored-by: sbfnk <sebastian.funk@lshtm.ac.uk>
Co-authored-by: sbfnk <sebastian.funk@lshtm.ac.uk>
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Benchmark comparison vs base

Minimum time per call. Buckets are PR time as a % of base, so lower is faster (🟢 faster, ⚪ within 5%, 🔴 slower). Counts of benchmarks per bucket:

Group 🟢 <50% 🟢 50–75% 🟢 75–95% ⚪ 95–105% 🔴 105–125% 🔴 125–150% 🔴 >150%
Evaluation · · 1 17 1 · ·
Evaluation — 19 benchmarks (by time change)
Benchmark base PR time memory
simulation: homogeneous 16.91 ms 19.58 ms 🔴 1.16× ⚪ 1.0×
simulation: households 605.95 μs 571.85 μs 🟢 0.94× ⚪ 1.0×
simulation: homogeneous, susceptibility trait 20.49 ms 21.45 ms ⚪ 1.05× ⚪ 1.0×
simulation: homogeneous SI, max_time 15.62 ms 16.24 ms ⚪ 1.04× ⚪ 1.0×
evaluation: compile_contact_pairs 18.15 μs 17.51 μs ⚪ 0.96× ⚪ 1.0×
evaluation: ChainSizes loglikelihood 260.0 ns 251.0 ns ⚪ 0.97× —
simulation: network, live kernel 2.43 ms 2.36 ms ⚪ 0.97× ⚪ 1.0×
evaluation: chain size loglikelihood 931.0 ns 911.0 ns ⚪ 0.98× —
evaluation: extinction_probability 641.0 ns 650.0 ns ⚪ 1.01× ⚪ 1.0×
evaluation: pairwise_surv_loglik 13.56 μs 13.72 μs ⚪ 1.01× ⚪ 1.0×
simulation: branching process 820.94 μs 812.34 μs ⚪ 0.99× ⚪ 1.0×
simulation: network, shared kernel 101.46 μs 102.45 μs ⚪ 1.01× ⚪ 1.0×
evaluation: PoissonLognormal pdf, large count 21.9 μs 22.09 μs ⚪ 1.01× ⚪ 1.0×
evaluation: PoissonLognormal pdf 21.62 μs 21.77 μs ⚪ 1.01× ⚪ 1.0×
simulation: branching process, interventions 9.69 μs 9.66 μs ⚪ 1.0× ⚪ 1.0×
evaluation: PoissonWeibull pdf, large count 28.18 μs 28.26 μs ⚪ 1.0× ⚪ 1.0×
simulation: network, live kernel with policy 2.44 ms 2.45 ms ⚪ 1.0× ⚪ 1.0×
simulation: branching process, HeldCapacity with DeferRefused 889.28 ms 889.09 ms ⚪ 1.0× ⚪ 1.0×
evaluation: PoissonWeibull pdf 29.51 μs 29.51 μs ⚪ 1.0× ⚪ 1.0×
AD gradients — 0 benchmarks (by time change)

none

@codecov

codecov Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.84%. Comparing base (f26167f) to head (0789a1e).
⚠️ Report is 26 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1246      +/-   ##
==========================================
+ Coverage   97.79%   97.84%   +0.05%     
==========================================
  Files         104      104              
  Lines       11757    12176     +419     
==========================================
+ Hits        11498    11914     +416     
- Misses        259      262       +3     
Flag Coverage Δ
epibranch-ad 29.48% <ø> (?)
epibranch-analytical 40.62% <ø> (-0.17%) ⬇️
epibranch-engine 52.60% <ø> (-5.40%) ⬇️
epibranch-inference 43.64% <ø> (-0.16%) ⬇️
epibranch-interventions 54.12% <ø> (+0.17%) ⬆️
epibranch-population 53.97% <ø> (-0.02%) ⬇️
epihouseholds 96.94% <ø> (ø)
epinetwork 95.40% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sbfnk-bot
sbfnk-bot marked this pull request as ready for review November 25, 2026 00:33
@sbfnk-bot
sbfnk-bot requested a review from sbfnk as a code owner November 25, 2026 00:33
@sbfnk-bot

Copy link
Copy Markdown
Collaborator Author

Relayed for @sbfnk:

The docstring, the error suffix, the tutorial sentence and the changelog entry present simulation as the only route, but the interval can be computed from trajectory draws, and #1254 plans that method. Reword them to say that serial_interval does not handle a model with a shared trajectory yet, and that for now the route is a distribution fitted to realised_serial_intervals of simulated states. Drop "has no closed form". The PR still closes #1223; #1254 takes the follow-up.

sbfnk-bot and others added 2 commits November 25, 2026 11:29
Co-authored-by: sbfnk <sebastian.funk@lshtm.ac.uk>
Co-authored-by: sbfnk <sebastian.funk@lshtm.ac.uk>
@sbfnk-bot

Copy link
Copy Markdown
Collaborator Author

Reworded the docstring, the error suffix (shared by the per-case generation time, missing or per-case incubation period, and trajectory errors), the tutorial sentence and the changelog entry. They now say serial_interval does not yet handle a model with a shared trajectory, and that for now the route is a distribution fitted to realised_serial_intervals of simulated states. "No closed form" is gone. Checked with test/test_serial_interval.jl; I did not run the docs build. #1254 takes the follow-up.

Co-authored-by: sbfnk <sebastian.funk@lshtm.ac.uk>
@sbfnk
sbfnk enabled auto-merge November 25, 2026 11:59
@sbfnk
sbfnk merged commit 9c65f39 into main Nov 25, 2026
28 checks passed
@sbfnk
sbfnk deleted the issue-1223-serial-interval-from-a-shared-trajectory branch November 25, 2026 12:19
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.

Serial interval from a shared trajectory

2 participants