Skip to content
Snippets Groups Projects
Commit 4bb83eba authored by Sebastian Henz's avatar Sebastian Henz
Browse files

test ec reference argument, closes #35

parent 1fc80c93
No related branches found
No related tags found
1 merge request!28Improve ec() and axis concentration handling
...@@ -17,12 +17,16 @@ ...@@ -17,12 +17,16 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
# shared model for some of the tests
model <- ecxsys(
concentration = c(0, 0.05, 0.5, 5, 30),
hormesis_concentration = 0.5,
effect_tox_observed = c(90, 81, 92, 28, 0),
effect_tox_env_observed = c(29, 27, 33, 5, 0)
)
test_that("all input formats produce identical models", { test_that("all input formats produce identical models", {
model <- ecxsys(
concentration = c(0, 0.05, 0.5, 5, 30),
hormesis_concentration = 0.5,
effect_tox_observed = c(90, 81, 92, 28, 0)
)
# using the ecxsys() output or the curves therein directly: # using the ecxsys() output or the curves therein directly:
ec10_a <- ec(model, "effect_tox_sys", 10) ec10_a <- ec(model, "effect_tox_sys", 10)
ec10_b <- ec(model$curves, "effect_tox_sys", 10) ec10_b <- ec(model$curves, "effect_tox_sys", 10)
...@@ -46,12 +50,6 @@ test_that("all input formats produce identical models", { ...@@ -46,12 +50,6 @@ test_that("all input formats produce identical models", {
test_that("ec values have not changed", { test_that("ec values have not changed", {
model <- ecxsys(
concentration = c(0, 0.05, 0.5, 5, 30),
hormesis_concentration = 0.5,
effect_tox_observed = c(90, 81, 92, 28, 0),
effect_tox_env_observed = c(29, 27, 33, 5, 0)
)
expect_equal( expect_equal(
ec(model, "effect_tox_sys", 50), ec(model, "effect_tox_sys", 50),
list(effect = 44.95368, concentration = 3.375735), list(effect = 44.95368, concentration = 3.375735),
...@@ -107,3 +105,17 @@ test_that("ec warns when response_level is outside the range of the curve", { ...@@ -107,3 +105,17 @@ test_that("ec warns when response_level is outside the range of the curve", {
fixed = TRUE fixed = TRUE
) )
}) })
test_that("reference argument works", {
expect_equal(
ec(model, "effect_tox_LL5", 50, reference = 100),
list(effect = 50, concentration = 2.208119),
tolerance = 1e-4
)
expect_equal(
ec(model, "effect_tox_LL5", 50, reference = 75),
list(effect = 37.5, concentration = 3.342715),
tolerance = 1e-4
)
})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment