tests/testthat/test-estimate_delay.R

skip_on_cran()

delays <- rlnorm(1:250, log(5), 0.2)
samples <- 1000
dist <- "lognormal"

# Run dist_fit
dist_fit_out <- dist_fit(
  delays,
  samples = samples,
  dist = dist,
  cores = ifelse(interactive(), 4, 1)
)

# Run bootstrapped_dist_fit
bootstrapped_dist_fit_out <- bootstrapped_dist_fit(
  delays,
  samples = samples,
  bootstraps = 2,
  dist = dist
)

test_that("dist_fit produces expected output", {
  expect_s4_class(dist_fit_out, "stanfit")
  expect_equal(length(extract(dist_fit_out)$mu), samples)
  expect_equal(length(extract(dist_fit_out)$sigma), samples)
})

test_that("bootstrapped_dist_fit produces expected output", {
  expect_s3_class(bootstrapped_dist_fit_out, "dist_spec")
})

Try the EpiNow2 package in your browser

Any scripts or data that you put into this service are public.

EpiNow2 documentation built on Oct. 31, 2024, 5:09 p.m.