diff options
| author | Johannes Ranke <jranke@uni-bremen.de> | 2020-05-29 16:05:11 +0200 | 
|---|---|---|
| committer | Johannes Ranke <jranke@uni-bremen.de> | 2020-05-29 16:05:11 +0200 | 
| commit | e6f9e9ca89e35e610d9895b979f1351a47451db0 (patch) | |
| tree | dd9d389c05e35db7a86abd578751199cd2c6a1be /tests/testthat/test_twa.R | |
| parent | 510436646b1bdd5b8cfab70be29334bd3cc9c828 (diff) | |
Improve handling of warnings, reorganize tests
Diffstat (limited to 'tests/testthat/test_twa.R')
| -rw-r--r-- | tests/testthat/test_twa.R | 26 | 
1 files changed, 26 insertions, 0 deletions
| diff --git a/tests/testthat/test_twa.R b/tests/testthat/test_twa.R new file mode 100644 index 00000000..a8fc0bd9 --- /dev/null +++ b/tests/testthat/test_twa.R @@ -0,0 +1,26 @@ +context("Calculation of maximum time weighted average concentrations (TWAs)") + +test_that("Time weighted average concentrations are correct", { +  skip_on_cran() + +  outtimes_10 <- seq(0, 10, length.out = 10000) + +  ds <- "FOCUS_C" +  for (model in models) { +    fit <- fits[[model, ds]] +    bpar <- summary(fit)$bpar[, "Estimate"] +    pred_10 <- mkinpredict(fit$mkinmod, +                odeparms = bpar[2:length(bpar)], +                odeini = c(parent = bpar[[1]]), +                outtimes = outtimes_10) +    twa_num <- mean(pred_10[, "parent"]) +    names(twa_num) <- 10 +    twa_ana <- max_twa_parent(fit, 10) + +    # Test for absolute difference (scale = 1) +    # The tolerance can be reduced if the length of outtimes is increased, +    # but this needs more computing time so we stay with lenght.out = 10k +    expect_equal(twa_num, twa_ana, tolerance = 0.003, scale = 1) +  } +}) + | 
