aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJohannes Ranke <johannes.ranke@jrwb.de>2025-09-12 22:16:13 +0200
committerJohannes Ranke <johannes.ranke@jrwb.de>2025-09-12 22:16:13 +0200
commit17af45b984d348505527140470c7fff204748ea6 (patch)
tree4a7409236626c86e07746f7dfc736745f83a99d6 /tests
parent3ae975f6039da0edc3ae6298bcac388e7346e73f (diff)
Facilitate centering covariates
The motivation for this is to obtain confidence intervals for covariate dependent parameters that are valid for a median/mean value of the covariate. Implementation by adding an argument to the 'saem' function, and adapting the relevant functions working with 'saem' objects. Vignettes, the template and tests were updated to use the new functionality.
Diffstat (limited to 'tests')
-rw-r--r--tests/testthat/test_mixed.R20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/testthat/test_mixed.R b/tests/testthat/test_mixed.R
index b9715096..99a5fd3a 100644
--- a/tests/testthat/test_mixed.R
+++ b/tests/testthat/test_mixed.R
@@ -102,15 +102,35 @@ test_that("Reading spreadsheets, finding ill-defined parameters and covariate mo
error_model = "const")
lambda_sforb_saem_pH <- saem(lambda_sforb, covariates = covariates,
covariate_models = list(log_k_lambda_bound_free ~ pH))
+
expect_equal(
as.character(illparms(lambda_sforb_saem_pH)),
c("sd(lambda_free_0)", "sd(log_k_lambda_free_bound)"))
lambda_endpoints <- endpoints(lambda_sforb_saem_pH)
+
expect_equal(lambda_endpoints$covariates$pH, 6.45)
expect_equal(
round(as.numeric(lambda_endpoints$distimes), 0),
c(47, 422, 127, 7, 162))
+
+ # We should get the same endpoints when the covariates are centered
+ lambda_sforb_saem_pH_centered <- saem(lambda_sforb, covariates = covariates,
+ covariate_models = list(log_k_lambda_bound_free ~ pH), center_covariates = "median")
+ lambda_endpoints_centered <- endpoints(lambda_sforb_saem_pH_centered)
+
+ expect_equal(lambda_endpoints_centered$covariates$pH, 6.45)
+ expect_equal(
+ round(as.numeric(lambda_endpoints_centered$distimes), 0),
+ c(47, 422, 127, 7, 162))
+
+ # Also check endpoints obtained for a different pH
+ lambda_endpoints_centered_7 <- endpoints(lambda_sforb_saem_pH_centered, covariates = c(pH = 7))
+ expect_equal(lambda_endpoints_centered_7$covariates$pH, 7)
+ expect_equal(
+ round(as.numeric(lambda_endpoints_centered_7$distimes), 0),
+ c(39, 283, 85, 7, 106))
+
})
test_that("SFO-SFO saemix specific analytical solution work", {

Contact - Imprint