From ab85b9157db8ebb7a9c22bc6267b519642805402 Mon Sep 17 00:00:00 2001 From: pratikunterwegs Date: Tue, 5 Mar 2024 11:49:45 +0000 Subject: [PATCH] Add tests for effect of cumulative contact intervs, WIP #187 --- tests/testthat/test-model_default.R | 22 ++++++++++++++++++++++ tests/testthat/test-model_vacamole.R | 22 ++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/tests/testthat/test-model_default.R b/tests/testthat/test-model_default.R index a9cdb129..3f8dc01d 100644 --- a/tests/testthat/test-model_default.R +++ b/tests/testthat/test-model_default.R @@ -166,6 +166,28 @@ test_that("Default model: contacts interventions and stats. correctness", { expect_true( all(epidemic_size(data_baseline) > epidemic_size(data)) ) + + # expect model runs with multiple contacts interventions + # expect that effect of multiple interventions is greater than single + intervention_02 <- intervention( + "work_closure", "contacts", 0, time_end, c(0.1, 0.5) + ) + combined_interventions <- c(intervention, intervention_02) + + expect_no_condition( + model_default( + uk_population, + intervention = list(contacts = combined_interventions) + ) + ) + data_combined <- model_default( + uk_population, + intervention = list(contacts = combined_interventions) + ) + # expect epidemic size is lower for combined intervention + expect_true( + all(epidemic_size(data_combined) < epidemic_size(data)) + ) }) test_that("Default model: rate interventions", { diff --git a/tests/testthat/test-model_vacamole.R b/tests/testthat/test-model_vacamole.R index 899f278c..703fddcb 100644 --- a/tests/testthat/test-model_vacamole.R +++ b/tests/testthat/test-model_vacamole.R @@ -229,6 +229,28 @@ test_that("Vacamole model: contacts interventions and stats. correctness", { expect_true( all(epidemic_size(data_baseline) > epidemic_size(data)) ) + + # expect model runs with multiple contacts interventions + # expect that effect of multiple interventions is greater than single + intervention_02 <- intervention( + "work_closure", "contacts", 0, time_end, c(0.1, 0.5) + ) + combined_interventions <- c(intervention, intervention_02) + + expect_no_condition( + model_vacamole( + uk_population, + intervention = list(contacts = combined_interventions) + ) + ) + data_combined <- model_vacamole( + uk_population, + intervention = list(contacts = combined_interventions) + ) + # expect epidemic size is lower for combined intervention + expect_true( + all(epidemic_size(data_combined) < epidemic_size(data)) + ) }) test_that("Vacamole model: rate interventions", {