From f7502e21a1c63c58f67efbb68214c19c283adc15 Mon Sep 17 00:00:00 2001 From: jrcpulliam Date: Wed, 12 Dec 2018 17:06:08 +0100 Subject: [PATCH] add skeleton of test for #28 --- tests/testthat/test-fit.R | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/tests/testthat/test-fit.R b/tests/testthat/test-fit.R index d2af507..b26917e 100644 --- a/tests/testthat/test-fit.R +++ b/tests/testthat/test-fit.R @@ -65,7 +65,7 @@ test_that("internals for fitting", { test_that("fitting results are the same for incidence fits on Dates and POSIXct", { days <- 1:14 dat_cases <- round(exp(.2*(days))) - dat_dates_Date <- rep(as.Date(Sys.Date()+days), days) + dat_dates_Date <- rep(as.Date(Sys.Date()+days), dat_cases) dat_dates_POSIXct <- as.POSIXct(dat_dates_Date) iD <- incidence(dat_dates_Date) @@ -73,3 +73,23 @@ test_that("fitting results are the same for incidence fits on Dates and POSIXct" expect_equal(fit(iP),fit(iD)) }) + +test_that("doubling / halving time makes sense when CI of r crosses 0", { + # estimate of r is negative + days <- 1:14 + dat_cases <- round(20*exp(-.2*(days))) + dat_dates <- rep(as.Date(Sys.Date()+days), dat_cases) + + i <- incidence(dat_dates) + f <- fit(i) + + # estimate of r is positive + days <- 1:14 + dat_cases <- round(exp(.2*(days))) + dat_dates <- rep(as.Date(Sys.Date()+days), dat_cases) + + i <- incidence(dat_dates) + f <- fit(i) + + # add test +})