aboutsummaryrefslogtreecommitdiff
path: root/R/transform_odeparms.R
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2014-07-21 08:20:44 +0200
committerJohannes Ranke <jranke@uni-bremen.de>2014-07-21 09:20:58 +0200
commita1567638a3ba9f4d62fa199525097a94ddfd7912 (patch)
treea223ff07ae669b61c44b97dcbfd5a48f5243ac24 /R/transform_odeparms.R
parent8def5006fc81c032c3fc99751e062cdb32a81cc1 (diff)
Bugfix, model shorthand, state.ini[[1]] from observed data
- The bug occurred when using transform_rates=FALSE for FOMC, DFOP or HS - Make it possible to use mkinfit("SFO", ...) - Take initial mean value at time zero for the variable with the highest value in the observed data - Update of vignette/FOCUS_L - Improve the Makefile to build single vignettes
Diffstat (limited to 'R/transform_odeparms.R')
-rw-r--r--R/transform_odeparms.R22
1 files changed, 15 insertions, 7 deletions
diff --git a/R/transform_odeparms.R b/R/transform_odeparms.R
index 912a5c0a..f518ae32 100644
--- a/R/transform_odeparms.R
+++ b/R/transform_odeparms.R
@@ -69,7 +69,11 @@ 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]
+ }
}
}
if (!is.na(parms["g"])) {
@@ -130,12 +134,16 @@ 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]
+ }
+ }
}
if (!is.na(transparms["g_ilr"])) {
g_ilr <- transparms["g_ilr"]

Contact - Imprint