aboutsummaryrefslogtreecommitdiff
path: root/R
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2022-08-08 10:11:04 +0200
committerJohannes Ranke <jranke@uni-bremen.de>2022-08-08 10:11:04 +0200
commit22d21cf5efcfb52c59c969d393bb0be077e982dd (patch)
treec8d97e7fff25d42019bb5a5908a5ce228cac6fb5 /R
parent546c540fecb60b51c3e265911282881315a8c937 (diff)
Fix fitting HS with saemix transformations
Diffstat (limited to 'R')
-rw-r--r--R/saem.R27
1 files changed, 19 insertions, 8 deletions
diff --git a/R/saem.R b/R/saem.R
index 36997ad7..d2240ea5 100644
--- a/R/saem.R
+++ b/R/saem.R
@@ -252,7 +252,7 @@ saemix_model <- function(object, solution_type = "auto", transformations = c("mk
}
degparms_fixed <- object[[1]]$bparms.fixed
- # Transformations are done in the degradation function
+ # Transformations are done in the degradation function by default
transform.par = rep(0, length(degparms_optim))
odeini_optim_parm_names <- grep('_0$', names(degparms_optim), value = TRUE)
@@ -339,13 +339,24 @@ saemix_model <- function(object, solution_type = "auto", transformations = c("mk
}
}
if (parent_type == "HS") {
- model_function <- function(psi, id, xidep) {
- tb <- exp(psi[id, 4])
- t <- xidep[, "time"]
- k1 = exp(psi[id, 2])
- psi[id, 1] * ifelse(t <= tb,
- exp(- k1 * t),
- exp(- k1 * tb) * exp(- exp(psi[id, 3]) * (t - tb)))
+ if (transformations == "mkin") {
+ model_function <- function(psi, id, xidep) {
+ tb <- exp(psi[id, 4])
+ t <- xidep[, "time"]
+ k1 <- exp(psi[id, 2])
+ psi[id, 1] * ifelse(t <= tb,
+ exp(- k1 * t),
+ exp(- k1 * tb) * exp(- exp(psi[id, 3]) * (t - tb)))
+ }
+ } else {
+ model_function <- function(psi, id, xidep) {
+ tb <- exp(psi[id, 4])
+ t <- xidep[, "time"]
+ psi[id, 1] * ifelse(t <= tb,
+ exp(- psi[id, 2] * t),
+ exp(- psi[id, 2] * tb) * exp(- psi[id, 3] * (t - tb)))
+ }
+ transform.par = c(0, 1, 1, 1)
}
}
}

Contact - Imprint