From 316f1360d1e12eefe491f86b0bbcd6dcf091c736 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Sat, 12 Jul 2014 08:32:08 +0200 Subject: First working fits with IORE model --- R/mkinmod.R | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'R/mkinmod.R') diff --git a/R/mkinmod.R b/R/mkinmod.R index eb290719..321887fc 100644 --- a/R/mkinmod.R +++ b/R/mkinmod.R @@ -41,9 +41,8 @@ mkinmod <- function(..., use_of_ff = "min", speclist = NULL) map <- list() # }}} - # Do not return a coefficient matrix mat when FOMC, DFOP or HS are used for - # the parent compound {{{ - if(spec[[1]]$type %in% c("FOMC", "DFOP", "HS")) { + # Do not return a coefficient matrix mat when FOMC, IORE, DFOP or HS is used for the parent {{{ + if(spec[[1]]$type %in% c("FOMC", "IORE", "DFOP", "HS")) { mat = FALSE } else mat = TRUE #}}} @@ -55,8 +54,8 @@ mkinmod <- function(..., use_of_ff = "min", speclist = NULL) # Check the type component of the compartment specification {{{ if(is.null(spec[[varname]]$type)) stop( "Every part of the model specification must be a list containing a type component") - if(!spec[[varname]]$type %in% c("SFO", "FOMC", "DFOP", "HS", "SFORB")) stop( - "Available types are SFO, FOMC, DFOP, HS and SFORB only") + if(!spec[[varname]]$type %in% c("SFO", "FOMC", "IORE", "DFOP", "HS", "SFORB")) stop( + "Available types are SFO, FOMC, IORE, DFOP, HS and SFORB only") if(spec[[varname]]$type %in% c("FOMC", "DFOP", "HS") & match(varname, obs_vars) != 1) { stop(paste("Types FOMC, DFOP and HS are only implemented for the first compartment,", "which is assumed to be the source compartment")) @@ -65,6 +64,7 @@ mkinmod <- function(..., use_of_ff = "min", speclist = NULL) new_boxes <- switch(spec[[varname]]$type, SFO = varname, FOMC = varname, + IORE = varname, DFOP = varname, HS = varname, SFORB = paste(varname, c("free", "bound"), sep = "_") @@ -85,20 +85,36 @@ mkinmod <- function(..., use_of_ff = "min", speclist = NULL) # Turn on sink if this is not explicitly excluded by the user by # specifying sink=FALSE if(is.null(spec[[varname]]$sink)) spec[[varname]]$sink <- TRUE - if(spec[[varname]]$type %in% c("SFO", "SFORB")) { # {{{ Add SFO or SFORB decline term + if(spec[[varname]]$type %in% c("SFO", "IORE", "SFORB")) { # {{{ Add decline term if (use_of_ff == "min") { # Minimum use of formation fractions if(spec[[varname]]$sink) { # If sink is required, add first-order sink term k_compound_sink <- paste("k", box_1, "sink", sep = "_") + if(spec[[varname]]$type == "IORE") { + k_compound_sink <- paste("k.iore", box_1, "sink", sep = "_") + } parms <- c(parms, k_compound_sink) decline_term <- paste(k_compound_sink, "*", box_1) + if(spec[[varname]]$type == "IORE") { + N <- paste("N", box_1, sep = "_") + parms <- c(parms, N) + decline_term <- paste0(decline_term, "^", N) + } } else { # otherwise no decline term needed here decline_term = "0" } } else { k_compound <- paste("k", box_1, sep = "_") + if(spec[[varname]]$type == "IORE") { + k_compound <- paste("k.iore", box_1, sep = "_") + } parms <- c(parms, k_compound) decline_term <- paste(k_compound, "*", box_1) + if(spec[[varname]]$type == "IORE") { + N <- paste("N", box_1, sep = "_") + parms <- c(parms, N) + decline_term <- paste0(decline_term, "^", N) + } } } #}}} if(spec[[varname]]$type == "FOMC") { # {{{ Add FOMC decline term -- cgit v1.2.1