aboutsummaryrefslogtreecommitdiff
path: root/R/transform_odeparms.R
diff options
context:
space:
mode:
Diffstat (limited to 'R/transform_odeparms.R')
-rw-r--r--R/transform_odeparms.R37
1 files changed, 28 insertions, 9 deletions
diff --git a/R/transform_odeparms.R b/R/transform_odeparms.R
index a36b7eae..778f56cd 100644
--- a/R/transform_odeparms.R
+++ b/R/transform_odeparms.R
@@ -75,12 +75,22 @@ transform_odeparms <- function(parms, mkinmod,
# and HS parameter tb if transformation of rates is requested
for (pname in c("alpha", "beta", "k1", "k2", "tb")) {
if (!is.na(parms[pname])) {
- transparms[paste0("log_", pname)] <- ifelse(transform_rates, log(parms[pname]), parms[pname])
+ if (transform_rates) {
+ transparms[paste0("log_", pname)] <- log(parms[pname])
+ } else {
+ transparms[pname] <- parms[pname]
+ }
}
}
+
+ # DFOP parameter g is treated as a fraction
if (!is.na(parms["g"])) {
g <- parms["g"]
- transparms["g_ilr"] <- ifelse(transform_fractions, ilr(c(g, 1 - g)), g)
+ if (transform_fractions) {
+ transparms["g_ilr"] <- ilr(c(g, 1 - g))
+ } else {
+ transparms["g"] <- g
+ }
}
return(transparms)
@@ -142,16 +152,25 @@ backtransform_odeparms <- function(transparms, mkinmod,
# Transform parameters also for FOMC, DFOP and HS models
for (pname in c("alpha", "beta", "k1", "k2", "tb")) {
- pname_trans = paste0("log_", pname)
- if (!is.na(transparms[pname_trans])) {
- parms[pname] <- ifelse(transform_rates,
- exp(transparms[pname_trans]),
- transparms[pname])
- }
+ if (transform_rates) {
+ pname_trans = paste0("log_", pname)
+ if (!is.na(transparms[pname_trans])) {
+ parms[pname] <- exp(transparms[pname_trans])
+ }
+ } else {
+ if (!is.na(transparms[pname])) {
+ parms[pname] <- transparms[pname]
+ }
+ }
}
+
+ # DFOP parameter g is treated as a fraction
if (!is.na(transparms["g_ilr"])) {
g_ilr <- transparms["g_ilr"]
- parms["g"] <- ifelse(transform_fractions, invilr(g_ilr)[1], g_ilr)
+ parms["g"] <- invilr(g_ilr)[1]
+ }
+ if (!is.na(transparms["g"])) {
+ parms["g"] <- transparms["g"]
}
return(parms)

Contact - Imprint