aboutsummaryrefslogtreecommitdiff
path: root/R/transform_odeparms.R
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2014-11-12 13:44:17 +0100
committerJohannes Ranke <jranke@uni-bremen.de>2014-11-12 13:44:17 +0100
commit401570aa9e58c4a2f2e939f37f496453d97d3f33 (patch)
tree27fbf0df9896c251506e084e0971fb26cda6da9a /R/transform_odeparms.R
parentb4d253edcf71fbf4175bc73cdb9593eea816c358 (diff)
parent3516b626be1aeb639d0735e79449424d2e987d7a (diff)
Merge branch 'master' into iore
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