Skip to content

Commit

Permalink
add skeleton of test for reconhub#28
Browse files Browse the repository at this point in the history
  • Loading branch information
jrcpulliam committed Dec 12, 2018
1 parent 231b622 commit f7502e2
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion tests/testthat/test-fit.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,31 @@ 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)
iP <- incidence(dat_dates_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
})

0 comments on commit f7502e2

Please sign in to comment.