From 4bf5aeb552bab6e4fac98acf0b590e3f46e53354 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Wed, 2 Jul 2014 17:30:56 +0200 Subject: Set implicit formation fraction to 1 even if set otherwise in parms.ini --- R/mkinfit.R | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'R') diff --git a/R/mkinfit.R b/R/mkinfit.R index ae30be43..8ad91981 100644 --- a/R/mkinfit.R +++ b/R/mkinfit.R @@ -110,6 +110,14 @@ mkinfit <- function(mkinmod, observed, if (mkinmod$use_of_ff == "max") { for (box in mod_vars) { f_names <- mkinmod$parms[grep(paste0("^f_", box), mkinmod$parms)] + # When we have no sink and only one pathway, we get an implicitly + # fixed parameter which we need in the model + if (!mkinmod$spec[[box]]$sink && length(f_names) == 1) { + if (f_names %in% names(parms.ini)) warning("Setting ", f_names, " to 1") + parms.ini[f_names] = 1 + defaultpar.names <- setdiff(defaultpar.names, f_names) + f_fixed_implicit[f_names] = 1 + } f_default_names <- intersect(f_names, defaultpar.names) f_specified_names <- setdiff(f_names, defaultpar.names) sum_f_specified = sum(parms.ini[f_specified_names]) @@ -119,13 +127,7 @@ mkinfit <- function(mkinmod, observed, } if (mkinmod$spec[[box]]$sink) n_unspecified = length(f_default_names) + 1 else { - # When we have no sink and only one pathway, we get an implicitly - # fixed parameter which we need in the model n_unspecified = length(f_default_names) - if (length(f_names) == 1) { - f_fixed_implicit[f_names] = 1 - fixed_parms = c(fixed_parms, f_names) - } } parms.ini[f_default_names] <- (1 - sum_f_specified) / n_unspecified } -- cgit v1.2.1