aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjranke <jranke@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>2012-07-03 15:46:14 +0000
committerjranke <jranke@edb9625f-4e0d-4859-8d74-9fd3b1da38cb>2012-07-03 15:46:14 +0000
commit5b28712ad11470293e7ab6746718ab3edcfe966b (patch)
tree4d1b3329e04ca007048317536b5dd596bab29eec
parente832b2255ad18d85e4ea9cc445ee87825a71c3a8 (diff)
- Add rtol argument in order to increase the precision of deSolve based
predictions for complex models - Improve default values for atol and set rtol default to 1e-10 git-svn-id: svn+ssh://svn.r-forge.r-project.org/svnroot/kinfit/pkg/mkin@49 edb9625f-4e0d-4859-8d74-9fd3b1da38cb
-rw-r--r--DESCRIPTION4
-rw-r--r--R/mkinfit.R7
-rw-r--r--R/mkinplot.R2
-rw-r--r--R/mkinpredict.R3
-rw-r--r--man/mkinfit.Rd10
-rw-r--r--man/mkinpredict.Rd29
6 files changed, 33 insertions, 22 deletions
diff --git a/DESCRIPTION b/DESCRIPTION
index 46dda22..62c9881 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -2,8 +2,8 @@ Package: mkin
Type: Package
Title: Routines for fitting kinetic models with one or more state
variables to chemical degradation data
-Version: 0.9-05
-Date: 2012-06-28
+Version: 0.9-06
+Date: 2012-07-03
Author: Johannes Ranke, Katrin Lindenberger, René Lehmann
Maintainer: Johannes Ranke <jranke@uni-bremen.de>
Description: Calculation routines based on the FOCUS Kinetics Report (2006).
diff --git a/R/mkinfit.R b/R/mkinfit.R
index 3100b30..0215596 100644
--- a/R/mkinfit.R
+++ b/R/mkinfit.R
@@ -29,7 +29,7 @@ mkinfit <- function(mkinmod, observed,
solution_type = "auto",
plot = FALSE, quiet = FALSE,
err = NULL, weight = "none", scaleVar = FALSE,
- atol = 1e-6, n.outtimes = 100,
+ atol = 1e-8, rtol = 1e-10, n.outtimes = 100,
trace_parms = FALSE,
...)
{
@@ -130,7 +130,7 @@ mkinfit <- function(mkinmod, observed,
parms <- backtransform_odeparms(odeparms, mod_vars)
# Solve the system with current transformed parameter values
- out <- mkinpredict(mkinmod, parms, odeini, outtimes, solution_type = solution_type, ...)
+ out <- mkinpredict(mkinmod, parms, odeini, outtimes, solution_type = solution_type, atol = atol, rtol = rtol, ...)
assign("out_predicted", out, inherits=TRUE)
@@ -146,7 +146,7 @@ mkinfit <- function(mkinmod, observed,
outtimes_plot = seq(min(observed$time), max(observed$time), length.out=100)
out_plot <- mkinpredict(mkinmod, parms, odeini, outtimes_plot,
- solution_type = solution_type, ...)
+ solution_type = solution_type, atol = atol, rtol = rtol, ...)
plot(0, type="n",
xlim = range(observed$time), ylim = range(observed$value, na.rm=TRUE),
@@ -198,6 +198,7 @@ mkinfit <- function(mkinmod, observed,
data$variable <- ordered(data$variable, levels = obs_vars)
fit$data <- data[order(data$variable, data$time), ]
fit$atol <- atol
+ fit$rtol <- rtol
fit$parms.all <- parms.all # Return all backtransformed parameters for summary
fit$odeparms.final <- parms.all[mkinmod$parms] # Return ode parameters for further fitting
fit$date <- date()
diff --git a/R/mkinplot.R b/R/mkinplot.R
index 7641d26..546c506 100644
--- a/R/mkinplot.R
+++ b/R/mkinplot.R
@@ -18,7 +18,7 @@ mkinplot <- function(fit, xlab = "Time", ylab = "Observed", xlim = range(fit$dat
odeparms <- parms.all[odenames]
out <- mkinpredict(fit$mkinmod, odeparms, odeini, outtimes,
- solution_type = solution_type, ...)
+ solution_type = solution_type, atol = fit$atol, rtol = fit$rtol, ...)
# Plot the data and model output
plot(0, type="n",
diff --git a/R/mkinpredict.R b/R/mkinpredict.R
index 493c578..5170dc6 100644
--- a/R/mkinpredict.R
+++ b/R/mkinpredict.R
@@ -18,7 +18,7 @@
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>
-mkinpredict <- function(mkinmod, odeparms, odeini, outtimes, solution_type = "deSolve", map_output = TRUE, atol = 1e-6, ...) {
+mkinpredict <- function(mkinmod, odeparms, odeini, outtimes, solution_type = "deSolve", map_output = TRUE, atol = 1e-8, rtol = 1e-10, ...) {
# Get the names of the state variables in the model
mod_vars <- names(mkinmod$diffs)
@@ -92,6 +92,7 @@ mkinpredict <- function(mkinmod, odeparms, odeini, outtimes, solution_type = "de
func = mkindiff,
parms = odeparms,
atol = atol,
+ rtol = rtol,
...
)
}
diff --git a/man/mkinfit.Rd b/man/mkinfit.Rd
index 5f70dae..181da4b 100644
--- a/man/mkinfit.Rd
+++ b/man/mkinfit.Rd
@@ -17,7 +17,7 @@ mkinfit(mkinmod, observed,
solution_type = "auto",
plot = FALSE, quiet = FALSE, err = NULL, weight = "none",
scaleVar = FALSE,
- atol = 1e-6, n.outtimes,
+ atol = 1e-8, rtol = 1e-10, n.outtimes = 100,
trace_parms, ...)
}
\arguments{
@@ -84,8 +84,12 @@ mkinfit(mkinmod, observed,
to the number of observations.
}
\item{atol}{
- Absolute error tolerance, passed to \code{\link{ode}}. Default is 1e-6 as in
- \code{\link{lsoda}}.
+ Absolute error tolerance, passed to \code{\link{ode}}. Default is 1e-8,
+ lower than in \code{\link{lsoda}}.
+ }
+ \item{rtol}{
+ Absolute error tolerance, passed to \code{\link{ode}}. Default is 1e-10,
+ much lower than in \code{\link{lsoda}}.
}
\item{n.outtimes}{
The length of the dataseries that is produced by the model prediction
diff --git a/man/mkinpredict.Rd b/man/mkinpredict.Rd
index d293144..a8ece47 100644
--- a/man/mkinpredict.Rd
+++ b/man/mkinpredict.Rd
@@ -9,42 +9,47 @@
initial values for the state variables.
}
\usage{
-mkinpredict(mkinmod, odeparms, odeini, outtimes, solution_type = "deSolve", map_output = TRUE, atol = 1e-06, ...)
+ mkinpredict(mkinmod, odeparms, odeini, outtimes, solution_type = "deSolve", map_output = TRUE,
+ atol = 1e-08, rtol = 1e-10, ...)
}
\arguments{
\item{mkinmod}{
A kinetic model as produced by \code{\link{mkinmod}}.
-}
+ }
\item{odeparms}{
A numeric vector specifying the parameters used in the kinetic model, which is generally
defined as a set of ordinary differential equations.
-}
+ }
\item{odeini}{
A numeric vectory containing the initial values of the state variables of the model. Note
that the state variables can differ from the observed variables, for example in the case
of the SFORB model.
-}
+ }
\item{outtimes}{
A numeric vector specifying the time points for which model predictions should be
generated.
-}
+ }
\item{solution_type}{
The method that should be used for producing the predictions. This should
generally be "analytical" if there is only one observed variable, and usually
"deSolve" in the case of several observed variables. The third possibility "eigen"
is faster but produces results that the author believes to be less accurate.
-}
+ }
\item{map_output}{
Boolean to specify if the output should list values for the observed variables (default)
or for all state variables (if set to FALSE).
-}
+ }
\item{atol}{
- Absolute error tolerance, passed to \code{\link{ode}}. Default is 1e-6 as in
- \code{\link{lsoda}}.
-}
+ Absolute error tolerance, passed to \code{\link{ode}}. Default is 1e-8,
+ lower than in \code{\link{lsoda}}.
+ }
+ \item{rtol}{
+ Absolute error tolerance, passed to \code{\link{ode}}. Default is 1e-10,
+ much lower than in \code{\link{lsoda}}.
+ }
\item{\dots}{
- Further arguments passed to the ode solver in case such a solver is used.
-}
+ Further arguments passed to the ode solver in case such a solver is used.
+ }
}
\value{
A matrix in the same format as the output of \code{\link{ode}}.

Contact - Imprint