aboutsummaryrefslogtreecommitdiff
path: root/R
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2016-03-23 17:03:09 +0100
committerJohannes Ranke <jranke@uni-bremen.de>2016-03-23 18:00:06 +0100
commit7875935fdfc3c55e0ef328b3c3a4512a30011df1 (patch)
treecb0c1596d34d4db08271890ac922f026a53206cf /R
parentc9667fbfd5a8c9601ac0c977776b12fe7d9b19dd (diff)
Added 'from_max_mean' to 'mkinfit'.
- Now it is easier to do decline kinetics from the maximum occurrence - Static documentation rebuilt by staticdocs::build_site() - Fixed an URL in the README, thanks to the win-builder check with R-devel
Diffstat (limited to 'R')
-rw-r--r--R/mkinfit.R15
1 files changed, 14 insertions, 1 deletions
diff --git a/R/mkinfit.R b/R/mkinfit.R
index 4a5be20a..929c73f0 100644
--- a/R/mkinfit.R
+++ b/R/mkinfit.R
@@ -1,4 +1,4 @@
-# Copyright (C) 2010-2015 Johannes Ranke
+# Copyright (C) 2010-2016 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,6 +26,7 @@ mkinfit <- function(mkinmod, observed,
state.ini = "auto",
fixed_parms = NULL,
fixed_initials = names(mkinmod$diffs)[-1],
+ from_max_mean = FALSE,
solution_type = c("auto", "analytical", "eigen", "deSolve"),
method.ode = "lsoda",
use_compiled = "auto",
@@ -79,6 +80,18 @@ mkinfit <- function(mkinmod, observed,
# Subset observed data with names of observed data in the model
observed <- subset(observed, name %in% obs_vars)
+ # Obtain data for decline from maximum mean value if requested
+ if (from_max_mean) {
+ # This is only used for simple decline models
+ if (length(obs_vars) > 1)
+ stop("Decline from maximum is only implemented for models with a single observed variable")
+
+ means <- aggregate(value ~ time, data = observed, mean, na.rm=TRUE)
+ t_of_max <- means[which.max(means$value), "time"]
+ observed <- subset(observed, time >= t_of_max)
+ observed$time <- observed$time - t_of_max
+ }
+
# Define starting values for parameters where not specified by the user
if (parms.ini[[1]] == "auto") parms.ini = vector()

Contact - Imprint