Debian Codegraph @

tests/testthat/test-drc.R

raw
1 skip_on_cran()
2
3 skip_if_not_installed("modeltests")
4 library(modeltests)
5
6 skip_if_not_installed("drc")
7 suppressPackageStartupMessages(library(drc))
8
9 mod <- drm(
10 dead / total ~ conc,
11 type,
12 weights = total,
13 data = selenium,
14 fct = LL.2(),
15 type = "binomial"
16 )
17
18 mod2 <- drm(rootl ~ conc, data = ryegrass, fct = W2.4())
19
20 test_that("drc tidier arguments", {
21 check_arguments(tidy.drc)
22 check_arguments(glance.drc)
23 check_arguments(augment.drc, strict = FALSE)
24 })
25
26 test_that("tidy.drc", {
27 td1 <- tidy(mod)
28 td3 <- tidy(mod, conf.int = TRUE)
29
30 check_tidy_output(td1, strict = FALSE)
31 check_tidy_output(td3, strict = FALSE)
32
33 td1 <- tidy(mod2)
34 td3 <- tidy(mod2, conf.int = TRUE)
35
36 check_tidy_output(td1, strict = FALSE)
37 check_tidy_output(td3, strict = FALSE)
38 })
39
40 test_that("glance.drc", {
41 gl1 <- glance(mod)
42 gl2 <- glance(mod2)
43
44 check_glance_outputs(gl1, gl2)
45 })
46
47 test_that("augment.drc", {
48 expect_snapshot(error = TRUE, augment(mod))
49
50 check_augment_function(
51 augment.drc,
52 mod,
53 data = selenium,
54 newdata = selenium
55 )
56
57 expect_snapshot(error = TRUE, augment(mod2))
58
59 check_augment_function(
60 augment.drc,
61 mod2,
62 data = ryegrass,
63 newdata = ryegrass
64 )
65 })
66
67 test_that("confidence merge issue regression test (#798)", {
68 td <- tidy(mod, conf.int = TRUE)
69
70 expect_false(any(is.na(td$conf.low)))
71 expect_false(any(is.na(td$conf.high)))
72 })