From 3e86aec575ba310303a19a4c5c4fbd40dee5e019 Mon Sep 17 00:00:00 2001 From: jasmineirx Date: Wed, 13 Aug 2025 17:30:41 -0400 Subject: [PATCH 1/2] shift covariayes for ss tests --- tests/testthat/test-get_map_estimates.ss.R | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/tests/testthat/test-get_map_estimates.ss.R b/tests/testthat/test-get_map_estimates.ss.R index 7bfc2d9..cd356be 100644 --- a/tests/testthat/test-get_map_estimates.ss.R +++ b/tests/testthat/test-get_map_estimates.ss.R @@ -65,8 +65,6 @@ test_that("MAP works with linear steady state equations", { ############################# ## Set up model and regimen - # covariates <- list(WT = new_covariate(c(70, 80), times = c(0, 120))) - covariates <- list(WT = PKPDsim::new_covariate(c(70, 120), times = c(0, 120))) model2 <- PKPDsim::new_ode_model( code = " CLi = CL * pow(WT/70.0, 0.75) @@ -84,13 +82,25 @@ test_that("MAP works with linear steady state equations", { interval <- 24 reg <- PKPDsim::new_regimen(amt = 1000, n = 30, interval = interval, type = "oral") t_tdm <- max(reg$dose_times) + c(1, 3, 6, 8, 12) + covariates <- list( + WT = PKPDsim::new_covariate( + value = c(70, 120), + times = max(reg$dose_times) + c(0, 120) + ) + ) + covariates_ss <- list( + WT = PKPDsim::new_covariate( + value = c(70, 120), + times = c(0, 120) + ) + ) tdm <- PKPDsim::sim( model2, parameters = par_true, covariates = covariates, regimen = reg, t_obs = t_tdm, - only_obs=TRUE + only_obs = TRUE ) ## plot @@ -125,7 +135,7 @@ test_that("MAP works with linear steady state equations", { model = model2, data = tdm2, regimen = reg_ss, - covariates = covariates, + covariates = covariates_ss, # time rezeroed fixed = c("KA"), omega = c(0.1, 0.05, 0.1), error = list(prop = 0.1, add = 0.1) @@ -143,7 +153,7 @@ test_that("MAP works with linear steady state equations", { data = tdm2, regimen = reg_ss, fixed = c("KA"), - covariates = covariates, + covariates = covariates_ss, omega = c(0.1, 0.05, 0.1), error = list(prop = 0.1, add = 0.1), steady_state_analytic = list( From a905c050ae7a05aa1150cca0810db41f355604bd Mon Sep 17 00:00:00 2001 From: jasmineirx Date: Fri, 15 Aug 2025 12:40:05 -0400 Subject: [PATCH 2/2] rearrange declarations in tests --- tests/testthat/test-get_map_estimates.ss.R | 23 +++++++++++----------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/tests/testthat/test-get_map_estimates.ss.R b/tests/testthat/test-get_map_estimates.ss.R index cd356be..cfd7da4 100644 --- a/tests/testthat/test-get_map_estimates.ss.R +++ b/tests/testthat/test-get_map_estimates.ss.R @@ -65,18 +65,6 @@ test_that("MAP works with linear steady state equations", { ############################# ## Set up model and regimen - model2 <- PKPDsim::new_ode_model( - code = " - CLi = CL * pow(WT/70.0, 0.75) - dAdt[1] = -KA*A[1] - dAdt[2] = KA*A[1] - (CLi/V)*A[2] - ", - obs = list(cmt = 2, scale = "V"), - declare_variables = "CLi", - dose = list(cmt = 1), - covariates = covariates - ) - par_true <- list(CL=2.5, V=45, KA=0.5) par <- list(CL=2, V=30, KA=0.5) interval <- 24 @@ -94,6 +82,17 @@ test_that("MAP works with linear steady state equations", { times = c(0, 120) ) ) + model2 <- PKPDsim::new_ode_model( + code = " + CLi = CL * pow(WT/70.0, 0.75) + dAdt[1] = -KA*A[1] + dAdt[2] = KA*A[1] - (CLi/V)*A[2] + ", + obs = list(cmt = 2, scale = "V"), + declare_variables = "CLi", + dose = list(cmt = 1), + covariates = covariates + ) tdm <- PKPDsim::sim( model2, parameters = par_true,