diff options
author | Johannes Ranke <jranke@uni-bremen.de> | 2022-08-08 10:11:04 +0200 |
---|---|---|
committer | Johannes Ranke <jranke@uni-bremen.de> | 2022-08-08 10:11:04 +0200 |
commit | 22d21cf5efcfb52c59c969d393bb0be077e982dd (patch) | |
tree | c8d97e7fff25d42019bb5a5908a5ce228cac6fb5 /R/saem.R | |
parent | 546c540fecb60b51c3e265911282881315a8c937 (diff) |
Fix fitting HS with saemix transformations
Diffstat (limited to 'R/saem.R')
-rw-r--r-- | R/saem.R | 27 |
1 files changed, 19 insertions, 8 deletions
@@ -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) } } } |