Skip to content

Add testing to the outbreak model with test sensitivity#196

Merged
joshwlambert merged 15 commits intoepiforecasts:mainfrom
joshwlambert:test_sensitivity
Mar 2, 2026
Merged

Add testing to the outbreak model with test sensitivity#196
joshwlambert merged 15 commits intoepiforecasts:mainfrom
joshwlambert:test_sensitivity

Conversation

@joshwlambert
Copy link
Copy Markdown
Collaborator

@joshwlambert joshwlambert commented Jan 21, 2026

This PR addresses #176 by adding testing to the epidemic model. The testing is assumed to be conducted for all symptomatic individuals in the model and the test_sensitivity argument added to intervention_opts() controls which proportion of individuals get a false negative test result using binomial sampling.

Symptomatic individuals in the model that are tested and get a false negative are not isolated throughout their infectious period (the same as asymptomatic individuals).

The variable missed is renamed to traced and the boolean inverted. The argument symptomatic_ascertained is renamed to symptomatic_traced. These two changes harmonise the variable naming in the simulation code, addressing #208.

Summary by CodeRabbit

Release Notes

  • New Features

    • Added test sensitivity parameter to intervention options (0–1 range) for diagnostic test accuracy configuration; false negative results now prevent case isolation and contact tracing.
  • Documentation

    • Updated intervention options documentation to describe the new test sensitivity parameter and its impact on isolation behaviour.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 21, 2026

Walkthrough

The changes introduce test sensitivity as a new intervention option. A test_sensitivity parameter (default 1) is added to intervention_opts and documented. The outbreak simulation logic now models test outcomes using rbinom sampling, applying false negative rates to adjust isolation behaviour for symptomatic cases, alongside related dependency imports and global variable declarations.

Changes

Cohort / File(s) Summary
Core Options Infrastructure
R/opts.R, man/intervention_opts.Rd
Added test_sensitivity parameter (numeric, 0-1, default 1) to intervention_opts function. Updated function signature and documentation to describe parameter behaviour regarding false negatives in testing.
Simulation Logic
R/outbreak_step.R
Added rbinom import. Introduced test_positive temporary column in new_cases sampling pipeline. For symptomatic non-missed cases, generates test results using rbinom with interventions\$test_sensitivity probability. Sets isolation time to Inf on false negatives to model missed isolation. Removes test_positive column from final output.
Package Configuration
NAMESPACE
Added importFrom directive for rbinom from stats package.
Global Declarations
R/globals.R
Added test_positive to globalVariables declaration under outbreak_step category.
Test Updates
tests/testthat/test-opts.R
Updated test expectations to validate new test_sensitivity field in ringbp_intervention_opts structure returned by intervention_opts.

Possibly related PRs

Suggested labels

testing

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding test sensitivity functionality to the outbreak model for testing symptomatic individuals.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
R/outbreak_step.R (1)

17-22: Update the interventions parameter doc to include test_sensitivity.
The description still says it contains only quarantine, which is now outdated.

✏️ Proposed doc tweak
-#'   [intervention_opts()]. Contains one element: `quarantine`
+#'   [intervention_opts()]. Contains two elements: `quarantine` and
+#'   `test_sensitivity`

Copy link
Copy Markdown
Contributor

@sbfnk sbfnk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me except minor doc comments - for future issue testing of contacts (irrespective of symptoms) would be a good addition.

Comment thread R/opts.R Outdated
Comment thread R/opts.R Outdated
Comment thread R/opts.R Outdated
Copy link
Copy Markdown
Collaborator

@pearsonca pearsonca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor items to consider

Comment thread R/outbreak_step.R Outdated
Comment thread R/outbreak_step.R Outdated
joshwlambert and others added 3 commits February 16, 2026 13:30
Co-authored-by: Sebastian Funk <sebastian.funk@lshtm.ac.uk>
Co-authored-by: Carl A. B. Pearson <pearsonca@users.noreply.github.com>
Copy link
Copy Markdown
Collaborator

@pearsonca pearsonca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extracted one remaining concern i had as new issue; otherwise LGTM

Comment thread R/outbreak_step.R Outdated
@joshwlambert joshwlambert added this pull request to the merge queue Mar 2, 2026
Merged via the queue into epiforecasts:main with commit 3df0d3f Mar 2, 2026
8 checks passed
@joshwlambert joshwlambert deleted the test_sensitivity branch March 2, 2026 14:34
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.

3 participants