-
Notifications
You must be signed in to change notification settings - Fork 0
/
testthat.R
79 lines (72 loc) · 1.75 KB
/
testthat.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
test_that("transformDF handles NA transformations correctly", {
df <- data.frame(
name = "no_transform",
Trans. = NA,
Trans.Lower = NA,
Trans.Upper = NA,
lower = 0,
est = 1,
upper = 2
)
result <- transformDF(df)
expect_equal(result$lower, 0)
expect_equal(result$est, 1)
expect_equal(result$upper, 2)
})
test_that("transformDF applies exponential transformation correctly", {
df <- data.frame(
name = "exp_transform",
Trans. = "exp",
Trans.Lower = NA,
Trans.Upper = NA,
lower = 0,
est = 1,
upper = 2
)
result <- transformDF(df)
expect_equal(result$lower, exp(0))
expect_equal(result$est, exp(1))
expect_equal(result$upper, exp(2))
})
test_that("transform_df applies expit transformation correctly", {
df <- data.frame(
name = "lvc",
Trans. = "expit",
Trans.Lower = 0.1,
Trans.Upper = 20,
lower = -Inf,
est = 0,
upper = Inf
)
result <- transformDF(df)
expect_equal(result$lower, NaN)
expect_equal(result$est, 10.05)
expect_equal(result$upper, NaN)
})
test_that("transform_df applies probitInv transformation correctly", {
df <- data.frame(
name = "probitInv_transform",
Trans. = "probitInv",
Trans.Lower = 0.1,
Trans.Upper = 5,
lower = -Inf,
est = 0,
upper = Inf
)
result <- transformDF(df)
expect_equal(result$lower, rxode2::probitInv(-Inf,0.1,5))
expect_equal(result$est, rxode2::probitInv(0,0.1,5))
expect_equal(result$upper, rxode2::probitInv(Inf,0.1,5))
})
test_that("transformDF returns thesame table for unknown transformation", {
df <- data.frame(
name = "lvc",
Trans. = "",
Trans.Lower = NA,
Trans.Upper = NA,
lower = 0,
est = 1,
upper = 2
)
expect_equal(transformDF(df), df)
})