diff options
| author | Johannes Ranke <jranke@uni-bremen.de> | 2015-04-16 11:06:39 +0200 | 
|---|---|---|
| committer | Johannes Ranke <jranke@uni-bremen.de> | 2015-04-16 11:27:56 +0200 | 
| commit | c504e823809aa8a299ed5326a22505f82d891ce5 (patch) | |
| tree | 302b7cfb6265cc725f3f0a1a5ca00387d1b7f45a | |
| parent | ec9e65053b214fa30e8b947ccbc47930eeaa01a4 (diff) | |
Update copyright header, improve documentation of solution_type
| -rw-r--r-- | R/mkinfit.R | 29 | ||||
| -rw-r--r-- | R/mkinmod.R | 2 | ||||
| -rw-r--r-- | R/mkinpredict.R | 2 | ||||
| -rw-r--r-- | man/mkinfit.Rd | 5 | 
4 files changed, 22 insertions, 16 deletions
| diff --git a/R/mkinfit.R b/R/mkinfit.R index 38f76674..5118519a 100644 --- a/R/mkinfit.R +++ b/R/mkinfit.R @@ -1,4 +1,4 @@ -# Copyright (C) 2010-2014 Johannes Ranke
 +# Copyright (C) 2010-2015 Johannes Ranke
  # Portions of this code are copyright (C) 2013 Eurofins Regulatory AG
  # Contact: jranke@uni-bremen.de
  # The summary function is an adapted and extended version of summary.modFit
 @@ -26,7 +26,7 @@ mkinfit <- function(mkinmod, observed,    state.ini = "auto", 
    fixed_parms = NULL,
    fixed_initials = names(mkinmod$diffs)[-1],
 -  solution_type = "auto",
 +  solution_type = c("auto", "analytical", "eigen", "deSolve"),
    method.ode = "lsoda",
    use_compiled = "auto",
    method.modFit = c("Port", "Marq", "SANN", "Nelder-Mead", "BFGS", "CG", "L-BFGS-B"),
 @@ -89,7 +89,7 @@ mkinfit <- function(mkinmod, observed,           " not used in the model")
    }
 -  # Warn that the sum of formation fractions may exceed one they are not
 +  # Warn that the sum of formation fractions may exceed one if they are not
    # fitted in the transformed way
    if (mkinmod$use_of_ff == "max" & transform_fractions == FALSE) {
      warning("The sum of formation fractions may exceed one if you do not use ",
 @@ -112,7 +112,7 @@ mkinfit <- function(mkinmod, observed,        stop("Fixing formation fractions is not supported when using the ilr ",
             "transformation.")
      }
 - }
 +  }
    # Set initial parameter values, including a small increment (salt)
    # to avoid linear dependencies (singular matrix) in Eigenvalue based solutions
 @@ -208,8 +208,9 @@ mkinfit <- function(mkinmod, observed,    # Decide if the solution of the model can be based on a simple analytical
    # formula, the spectral decomposition of the matrix (fundamental system)
    # or a numeric ode solver from the deSolve package
 -  if (!solution_type %in% c("auto", "analytical", "eigen", "deSolve"))
 -     stop("solution_type must be auto, analytical, eigen or de Solve")
 +  # Prefer deSolve over eigen if a compiled model is present and use_compiled
 +  # is not set to FALSE
 +  solution_type = match.arg(solution_type)
    if (solution_type == "analytical" && length(mkinmod$spec) > 1)
       stop("Analytical solution not implemented for models with metabolites.")
    if (solution_type == "eigen" && !is.matrix(mkinmod$coefmat))
 @@ -218,13 +219,17 @@ mkinfit <- function(mkinmod, observed,      if (length(mkinmod$spec) == 1) {
        solution_type = "analytical"
      } else {
 -      if (is.matrix(mkinmod$coefmat)) {
 -        solution_type = "eigen"
 -        if (max(observed$value, na.rm = TRUE) < 0.1) {
 -          stop("The combination of small observed values (all < 0.1) and solution_type = eigen is error-prone")
 -        }
 -      } else {
 +      if (!is.null(mkinmod$compiled) & use_compiled[1] != FALSE) {
          solution_type = "deSolve"
 +      } else {
 +        if (is.matrix(mkinmod$coefmat)) {
 +          solution_type = "eigen"
 +          if (max(observed$value, na.rm = TRUE) < 0.1) {
 +            stop("The combination of small observed values (all < 0.1) and solution_type = eigen is error-prone")
 +          }
 +        } else {
 +          solution_type = "deSolve"
 +        }
        }
      }
    }
 diff --git a/R/mkinmod.R b/R/mkinmod.R index 37cd02b4..e73c56c6 100644 --- a/R/mkinmod.R +++ b/R/mkinmod.R @@ -1,4 +1,4 @@ -# Copyright (C) 2010-2014 Johannes Ranke {{{
 +# Copyright (C) 2010-2015 Johannes Ranke {{{
  # Contact: jranke@uni-bremen.de
  # This file is part of the R package mkin
 diff --git a/R/mkinpredict.R b/R/mkinpredict.R index 864eefbe..3e3ca0bf 100644 --- a/R/mkinpredict.R +++ b/R/mkinpredict.R @@ -1,4 +1,4 @@ -# Copyright (C) 2010-2014 Johannes Ranke +# Copyright (C) 2010-2015 Johannes Ranke  # Some lines in this code are copyright (C) 2013 Eurofins Regulatory AG  # Contact: jranke@uni-bremen.de diff --git a/man/mkinfit.Rd b/man/mkinfit.Rd index 4250bfda..5f43e145 100644 --- a/man/mkinfit.Rd +++ b/man/mkinfit.Rd @@ -21,7 +21,7 @@ mkinfit(mkinmod, observed,    parms.ini = "auto",    state.ini = "auto",    fixed_parms = NULL, fixed_initials = names(mkinmod$diffs)[-1],  -  solution_type = "auto", +  solution_type = c("auto", "analytical", "eigen", "deSolve")    method.ode = "lsoda",    use_compiled = "auto",    method.modFit = c("Port", "Marq", "SANN", "Nelder-Mead", "BFGS", "CG", "L-BFGS-B"), @@ -105,7 +105,8 @@ mkinfit(mkinmod, observed,    }    \item{use_compiled}{      If set to \code{FALSE}, no compiled version of the \code{\link{mkinmod}}  -    model is used, even if is present.  +    model is used, in the calls to \code{\link{mkinpredict}} even if +    a compiled verion is present.     }    \item{method.modFit}{      The optimisation method passed to \code{\link{modFit}}.   | 
