From d2c1ab854491ff047135fa8377400a68499e72de Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Thu, 17 Jul 2014 12:53:30 +0200 Subject: Handle non-convergence and maximum number of iterations For details see NEWS.md --- man/mkinfit.Rd | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'man') diff --git a/man/mkinfit.Rd b/man/mkinfit.Rd index bd7f73b7..c99e146c 100644 --- a/man/mkinfit.Rd +++ b/man/mkinfit.Rd @@ -21,7 +21,8 @@ mkinfit(mkinmod, observed, fixed_parms = NULL, fixed_initials = names(mkinmod$diffs)[-1], solution_type = "auto", method.ode = "lsoda", - method.modFit = "Marq", + method.modFit = c("Marq", "Port", "SANN", "Nelder-Mead", "BFSG", "CG", "L-BFGS-B"), + maxit.modFit = "auto", control.modFit = list(), transform_rates = TRUE, transform_fractions = TRUE, @@ -102,12 +103,21 @@ mkinfit(mkinmod, observed, recommended as it is less prone to get trapped in local minima and depends less on starting values for parameters. However, it needs more iterations. - When using "Pseudo", "upper" and "lower" need to be specified for the - transformed parameters. + The "Pseudo" algorithm is not included because it needs finite parameter bounds + which are currently not supported. + + The "Newton" algorithm is not included because its number of iterations + can not be controlled by \code{control.modFit} and it does not appear + to provide advantages over the other algorithms. + } + \item{maxit.modFit}{ + Maximum number of iterations in the optimisation. If not "auto", this will + be passed to the method called by \code{\link{modFit}}, overriding + what may be specified in the next argument \code{control.modFit}. } \item{control.modFit}{ Additional arguments passed to the optimisation method used by - \code{\link{modFit}}. + \code{\link{modFit}}. } \item{transform_rates}{ Boolean specifying if kinetic rate constants should be transformed in the -- cgit v1.2.3 From a1567638a3ba9f4d62fa199525097a94ddfd7912 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Mon, 21 Jul 2014 08:20:44 +0200 Subject: Bugfix, model shorthand, state.ini[[1]] from observed data - The bug occurred when using transform_rates=FALSE for FOMC, DFOP or HS - Make it possible to use mkinfit("SFO", ...) - Take initial mean value at time zero for the variable with the highest value in the observed data - Update of vignette/FOCUS_L - Improve the Makefile to build single vignettes --- DESCRIPTION | 2 +- GNUmakefile | 15 ++- NEWS.md | 6 + R/mkinfit.R | 27 +++- R/transform_odeparms.R | 22 +++- README.md | 5 + man/mkinfit.Rd | 22 +++- man/transform_odeparms.Rd | 2 +- vignettes/FOCUS_L.Rmd | 81 ++++++------ vignettes/FOCUS_L.html | 328 +++++++++++++++++++++++----------------------- vignettes/mkin.pdf | Bin 160326 -> 160326 bytes 11 files changed, 279 insertions(+), 231 deletions(-) (limited to 'man') diff --git a/DESCRIPTION b/DESCRIPTION index fb32b807..bad72501 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -3,7 +3,7 @@ Type: Package Title: Routines for fitting kinetic models with one or more state variables to chemical degradation data Version: 0.9-32 -Date: 2014-07-17 +Date: 2014-07-21 Authors@R: c(person("Johannes", "Ranke", role = c("aut", "cre", "cph"), email = "jranke@uni-bremen.de"), person("Katrin", "Lindenberger", role = "ctb"), diff --git a/GNUmakefile b/GNUmakefile index b8cc5d82..aebc20dd 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -70,10 +70,17 @@ test: install-no-vignettes cd tests;\ "$(RBIN)/Rscript" doRUnit.R -.PHONY: vignettes -vignettes: - "$(RBIN)/Rscript" -e "tools::buildVignettes(dir = '.')" - +vignettes/mkin.pdf: vignettes/mkin.Rnw + "$(RBIN)/Rscript" -e "tools::buildVignette(file = 'vignettes/mkin.Rnw', dir = 'vignettes')" + +vignettes/FOCUS_L.html: vignettes/FOCUS_L.Rmd + "$(RBIN)/Rscript" -e "tools::buildVignette(file = 'vignettes/FOCUS_L.Rmd', dir = 'vignettes')" + +vignettes/FOCUS_Z.pdf: vignettes/FOCUS_Z.Rnw + "$(RBIN)/Rscript" -e "tools::buildVignette(file = 'vignettes/FOCUS_Z.Rnw', dir = 'vignettes')" + +vignettes: vignettes/mkin.pdf vignettes/FOCUS_L.html vignettes/FOCUS_Z.pdf + sd: "$(RBIN)/Rscript" -e "library(staticdocs); build_site()" diff --git a/NEWS.md b/NEWS.md index 031ae954..c10a25b0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,10 @@ ## NEW FEATURES +- The default for the initial value for the first state value is now taken from the mean of the observations at time zero, if available. + +- The kinetic model can alternatively be specified with a shorthand name for parent only degradation models, e.g. `SFO`, or `DFOP`. + - Optimisation method, number of model evaluations and time elapsed during optimisation are given in the summary of mkinfit objects. - The maximum number of iterations in the optimisation algorithm can be specified using the argument `maxit.modFit` to the mkinfit function. @@ -10,6 +14,8 @@ ## BUG FIXES +- `transform_rates=FALSE` in `mkinfit` now also works for FOMC and HS models. + - Initial values for formation fractions were not set in all cases. - No warning was given when the fit did not converge when a method other than the default Levenberg-Marquardt method `Marq` was used. diff --git a/R/mkinfit.R b/R/mkinfit.R index a8fbfc78..39d084cb 100644 --- a/R/mkinfit.R +++ b/R/mkinfit.R @@ -23,7 +23,7 @@ if(getRversion() >= '2.15.1') utils::globalVariables(c("name", "value")) mkinfit <- function(mkinmod, observed, parms.ini = "auto", - state.ini = c(100, rep(0, length(mkinmod$diffs) - 1)), + state.ini = "auto", fixed_parms = NULL, fixed_initials = names(mkinmod$diffs)[-1], solution_type = "auto", @@ -41,6 +41,21 @@ mkinfit <- function(mkinmod, observed, trace_parms = FALSE, ...) { + # Check mkinmod and generate a model for the variable whithe the highest value + # if a suitable string is given + parent_models_available = c("SFO", "FOMC", "DFOP", "HS", "SFORB") + presumed_parent_name = observed[which.max(observed$value), "name"] + if (class(mkinmod) != "mkinmod") { + if (mkinmod[[1]] %in% parent_models_available) { + speclist <- list(list(type = mkinmod, sink = TRUE)) + names(speclist) <- presumed_parent_name + mkinmod <- mkinmod(speclist = speclist) + } else { + stop("Argument mkinmod must be of class mkinmod or a string containing one of\n ", + paste(parent_models_available, collapse = ", ")) + } + } + # Check optimisation method and set maximum number of iterations if specified method.modFit = match.arg(method.modFit) if (maxit.modFit != "auto") { @@ -55,7 +70,7 @@ mkinfit <- function(mkinmod, observed, mod_vars <- names(mkinmod$diffs) # Get the names of observed variables - obs_vars = names(mkinmod$spec) + obs_vars <- names(mkinmod$spec) # Subset observed data with names of observed data in the model observed <- subset(observed, name %in% obs_vars) @@ -137,6 +152,12 @@ mkinfit <- function(mkinmod, observed, } } + # Set default for state.ini if appropriate + if (state.ini[1] == "auto") { + state.ini = c(mean(subset(observed, time == 0 & name == presumed_parent_name)$value), + rep(0, length(mkinmod$diffs) - 1)) + } + # Name the inital state variable values if they are not named yet if(is.null(names(state.ini))) names(state.ini) <- mod_vars @@ -279,7 +300,7 @@ mkinfit <- function(mkinmod, observed, if (!transform_rates) { index_k <- grep("^k_", names(lower)) lower[index_k] <- 0 - other_rate_parms <- intersect(c("alpha", "beta", "k1", "k2"), names(lower)) + other_rate_parms <- intersect(c("alpha", "beta", "k1", "k2", "tb"), names(lower)) lower[other_rate_parms] <- 0 } diff --git a/R/transform_odeparms.R b/R/transform_odeparms.R index 912a5c0a..f518ae32 100644 --- a/R/transform_odeparms.R +++ b/R/transform_odeparms.R @@ -69,7 +69,11 @@ transform_odeparms <- function(parms, mkinmod, # and HS parameter tb if transformation of rates is requested for (pname in c("alpha", "beta", "k1", "k2", "tb")) { if (!is.na(parms[pname])) { - transparms[paste0("log_", pname)] <- ifelse(transform_rates, log(parms[pname]), parms[pname]) + if (transform_rates) { + transparms[paste0("log_", pname)] <- log(parms[pname]) + } else { + transparms[pname] <- parms[pname] + } } } if (!is.na(parms["g"])) { @@ -130,12 +134,16 @@ backtransform_odeparms <- function(transparms, mkinmod, # Transform parameters also for FOMC, DFOP and HS models for (pname in c("alpha", "beta", "k1", "k2", "tb")) { - pname_trans = paste0("log_", pname) - if (!is.na(transparms[pname_trans])) { - parms[pname] <- ifelse(transform_rates, - exp(transparms[pname_trans]), - transparms[pname]) - } + if (transform_rates) { + pname_trans = paste0("log_", pname) + if (!is.na(transparms[pname_trans])) { + parms[pname] <- exp(transparms[pname_trans]) + } + } else { + if (!is.na(transparms[pname])) { + parms[pname] <- transparms[pname] + } + } } if (!is.na(transparms["g_ilr"])) { g_ilr <- transparms["g_ilr"] diff --git a/README.md b/README.md index e171180f..48c667bf 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,11 @@ A very simple usage example would be plot(SFO.fit, show_residuals = TRUE) summary(SFO.fit) +If you have parent only degradation data, you can use a shorthand notation +like `SFO` or `FOMC` for the model without the need to use `mkinmod` + + FOMC.fit <- mkinfit("FOMC", example_data) + A fairly complex usage example using a built-in dataset: data <- mkin_wide_to_long(schaefer07_complex_case, time = "time") diff --git a/man/mkinfit.Rd b/man/mkinfit.Rd index c99e146c..581d63f4 100644 --- a/man/mkinfit.Rd +++ b/man/mkinfit.Rd @@ -17,7 +17,7 @@ \usage{ mkinfit(mkinmod, observed, parms.ini = "auto", - state.ini = c(100, rep(0, length(mkinmod$diffs) - 1)), + state.ini = "auto", fixed_parms = NULL, fixed_initials = names(mkinmod$diffs)[-1], solution_type = "auto", method.ode = "lsoda", @@ -35,7 +35,11 @@ mkinfit(mkinmod, observed, } \arguments{ \item{mkinmod}{ - A list of class \code{\link{mkinmod}}, containing the kinetic model to be fitted to the data. + A list of class \code{\link{mkinmod}}, containing the kinetic model to be + fitted to the data, or one of the shorthand names ("SFO", "FOMC", "DFOP", + "HS", "SFORB"). If a shorthand name is given, a parent only degradation + model is generated for the observation with the highest value in + \code{observed}. } \item{observed}{ The observed data. It has to be in the long format as described in @@ -65,7 +69,8 @@ mkinfit(mkinmod, observed, case the observed variables are represented by more than one model variable, the names will differ from the names of the observed variables (see \code{map} component of \code{\link{mkinmod}}). The default is to set - the initial value of the first model variable to 100 and all others to 0. + the initial value of the first model variable to the mean of the time zero + values for the variable with the maximum observed value, and all others to 0. } \item{fixed_parms}{ The names of parameters that should not be optimised but rather kept at the @@ -124,8 +129,9 @@ mkinfit(mkinmod, observed, model specification used in the fitting for better compliance with the assumption of normal distribution of the estimator. If TRUE, also alpha and beta parameters of the FOMC model are log-transformed, as well - as k1 and k2 rate constants for the DFOP and HS models. - If TRUE, zero is used as a lower bound for the rates in the optimisation. + as k1 and k2 rate constants for the DFOP and HS models and the break point + tb of the HS model. + If FALSE, zero is used as a lower bound for the rates in the optimisation. } \item{transform_fractions}{ Boolean specifying if formation fractions constants should be transformed in the @@ -204,9 +210,13 @@ mkinfit(mkinmod, observed, other GUI derivative of mkin, sponsored by Syngenta. } \author{ - Johannes Ranke + Johannes Ranke } \examples{ +# Use shorthand notation for parent only degradation +fit <- mkinfit("FOMC", FOCUS_2006_C) +summary(fit) + # One parent compound, one metabolite, both single first order. SFO_SFO <- mkinmod( parent = list(type = "SFO", to = "m1", sink = TRUE), diff --git a/man/transform_odeparms.Rd b/man/transform_odeparms.Rd index ea0b5024..ba93af7d 100644 --- a/man/transform_odeparms.Rd +++ b/man/transform_odeparms.Rd @@ -41,7 +41,7 @@ backtransform_odeparms(transparms, mkinmod, assumption of normal distribution of the estimator. If TRUE, also alpha and beta parameters of the FOMC model are log-transformed, as well as k1 and k2 rate constants for the DFOP and HS models and the break point tb - of the HS model + of the HS model. } \item{transform_fractions}{ Boolean specifying if formation fractions constants should be transformed in the diff --git a/vignettes/FOCUS_L.Rmd b/vignettes/FOCUS_L.Rmd index 04d5f831..cd7711f6 100644 --- a/vignettes/FOCUS_L.Rmd +++ b/vignettes/FOCUS_L.Rmd @@ -13,7 +13,7 @@ opts_chunk$set(tidy = FALSE, cache = TRUE) ## Laboratory Data L1 The following code defines example dataset L1 from the FOCUS kinetics -report, p. 284 +report, p. 284: ```{r} library("mkin") @@ -25,27 +25,18 @@ FOCUS_2006_L1 = data.frame( FOCUS_2006_L1_mkin <- mkin_wide_to_long(FOCUS_2006_L1) ``` -The next step is to set up the models used for the kinetic analysis. Note that -the model definitions contain the names of the observed variables in the data. -In this case, there is only one variable called `parent`. +Here we use the assumptions of simple first order (SFO), the case of declining +rate constant over time (FOMC) and the case of two different phases of the +kinetics (DFOP). For a more detailed discussion of the models, please see the +FOCUS kinetics report. -```{r} -SFO <- mkinmod(parent = list(type = "SFO")) -FOMC <- mkinmod(parent = list(type = "FOMC")) -DFOP <- mkinmod(parent = list(type = "DFOP")) -``` - -The three models cover the first assumption of simple first order (SFO), -the case of declining rate constant over time (FOMC) and the case of two -different phases of the kinetics (DFOP). For a more detailed discussion -of the models, please see the FOCUS kinetics report. - -The following two lines fit the model and produce the summary report -of the model fit. This covers the numerical analysis given in the -FOCUS report. +Since mkin version 0.9-32 (July 2014), we can use shorthand notation like `SFO` +for parent only degradation models. The following two lines fit the model and +produce the summary report of the model fit. This covers the numerical analysis +given in the FOCUS report. ```{r} -m.L1.SFO <- mkinfit(SFO, FOCUS_2006_L1_mkin, quiet=TRUE) +m.L1.SFO <- mkinfit("SFO", FOCUS_2006_L1_mkin, quiet=TRUE) summary(m.L1.SFO) ``` @@ -64,32 +55,30 @@ For comparison, the FOMC model is fitted as well, and the chi^2 error level is checked. ```{r} -m.L1.FOMC <- mkinfit(FOMC, FOCUS_2006_L1_mkin, quiet=TRUE) +m.L1.FOMC <- mkinfit("FOMC", FOCUS_2006_L1_mkin, quiet=TRUE) summary(m.L1.FOMC, data = FALSE) ``` Due to the higher number of parameters, and the lower number of degrees of freedom of the fit, the chi^2 error level is actually higher for the FOMC -model (3.6%) than for the SFO model (3.4%). Additionally, the covariance -matrix can not be obtained, indicating overparameterisation of the model. -As a consequence, no standard errors for transformed parameters nor -confidence intervals for backtransformed parameters are available. +model (3.6%) than for the SFO model (3.4%). Additionally, the parameters +`log_alpha` and `log_beta` internally fitted in the model have p-values for the two +sided t-test of 0.18 and 0.125, and their correlation is 1.000, indicating that +the model is overparameterised. The chi^2 error levels reported in Appendix 3 and Appendix 7 to the FOCUS kinetics report are rounded to integer percentages and partly deviate by one percentage point from the results calculated by mkin. The reason for this is not known. However, mkin gives the same chi^2 error levels -as the kinfit package. - -Furthermore, the calculation routines of the kinfit package have been extensively -compared to the results obtained by the KinGUI software, as documented in the -kinfit package vignette. KinGUI is a widely used standard package in this field. -Therefore, the reason for the difference was not investigated further. +as the kinfit package. Furthermore, the calculation routines of the kinfit +package have been extensively compared to the results obtained by the KinGUI +software, as documented in the kinfit package vignette. KinGUI is a widely used +standard package in this field. ## Laboratory Data L2 The following code defines example dataset L2 from the FOCUS kinetics -report, p. 287 +report, p. 287: ```{r} FOCUS_2006_L2 = data.frame( @@ -100,10 +89,10 @@ FOCUS_2006_L2 = data.frame( FOCUS_2006_L2_mkin <- mkin_wide_to_long(FOCUS_2006_L2) ``` -Again, the SFO model is fitted and a summary is obtained. +Again, the SFO model is fitted and a summary is obtained: ```{r} -m.L2.SFO <- mkinfit(SFO, FOCUS_2006_L2_mkin, quiet=TRUE) +m.L2.SFO <- mkinfit("SFO", FOCUS_2006_L2_mkin, quiet=TRUE) summary(m.L2.SFO) ``` @@ -130,7 +119,7 @@ For comparison, the FOMC model is fitted as well, and the chi^2 error level is checked. ```{r fig.height = 8} -m.L2.FOMC <- mkinfit(FOMC, FOCUS_2006_L2_mkin, quiet = TRUE) +m.L2.FOMC <- mkinfit("FOMC", FOCUS_2006_L2_mkin, quiet = TRUE) par(mfrow = c(2, 1)) plot(m.L2.FOMC) mkinresplot(m.L2.FOMC) @@ -144,7 +133,7 @@ experimental error has to be assumed in order to explain the data. Fitting the four parameter DFOP model further reduces the chi^2 error level. ```{r fig.height = 5} -m.L2.DFOP <- mkinfit(DFOP, FOCUS_2006_L2_mkin, quiet = TRUE) +m.L2.DFOP <- mkinfit("DFOP", FOCUS_2006_L2_mkin, quiet = TRUE) plot(m.L2.DFOP) ``` @@ -153,7 +142,7 @@ to a reasonable solution. Therefore the fit is repeated with different starting parameters. ```{r fig.height = 5} -m.L2.DFOP <- mkinfit(DFOP, FOCUS_2006_L2_mkin, +m.L2.DFOP <- mkinfit("DFOP", FOCUS_2006_L2_mkin, parms.ini = c(k1 = 1, k2 = 0.01, g = 0.8), quiet=TRUE) plot(m.L2.DFOP) @@ -180,7 +169,7 @@ FOCUS_2006_L3_mkin <- mkin_wide_to_long(FOCUS_2006_L3) SFO model, summary and plot: ```{r fig.height = 5} -m.L3.SFO <- mkinfit(SFO, FOCUS_2006_L3_mkin, quiet = TRUE) +m.L3.SFO <- mkinfit("SFO", FOCUS_2006_L3_mkin, quiet = TRUE) plot(m.L3.SFO) summary(m.L3.SFO) ``` @@ -191,7 +180,7 @@ does not fit very well. The FOMC model performs better: ```{r fig.height = 5} -m.L3.FOMC <- mkinfit(FOMC, FOCUS_2006_L3_mkin, quiet = TRUE) +m.L3.FOMC <- mkinfit("FOMC", FOCUS_2006_L3_mkin, quiet = TRUE) plot(m.L3.FOMC) summary(m.L3.FOMC, data = FALSE) ``` @@ -202,7 +191,7 @@ Fitting the four parameter DFOP model further reduces the chi^2 error level considerably: ```{r fig.height = 5} -m.L3.DFOP <- mkinfit(DFOP, FOCUS_2006_L3_mkin, quiet = TRUE) +m.L3.DFOP <- mkinfit("DFOP", FOCUS_2006_L3_mkin, quiet = TRUE) plot(m.L3.DFOP) summary(m.L3.DFOP, data = FALSE) ``` @@ -212,10 +201,15 @@ and the correlation matrix suggest that the parameter estimates are reliable, an the DFOP model can be used as the best-fit model based on the chi^2 error level criterion for laboratory data L3. +This is also an example where the standard t-test for the parameter `g_ilr` is +misleading, as it tests for a significant difference from zero. In this case, +zero appears to be the correct value for this parameter, and the confidence +interval for the backtransformed parameter `g` is quite narrow. + ## Laboratory Data L4 The following code defines example dataset L4 from the FOCUS kinetics -report, p. 293 +report, p. 293: ```{r} FOCUS_2006_L4 = data.frame( @@ -227,7 +221,7 @@ FOCUS_2006_L4_mkin <- mkin_wide_to_long(FOCUS_2006_L4) SFO model, summary and plot: ```{r fig.height = 5} -m.L4.SFO <- mkinfit(SFO, FOCUS_2006_L4_mkin, quiet = TRUE) +m.L4.SFO <- mkinfit("SFO", FOCUS_2006_L4_mkin, quiet = TRUE) plot(m.L4.SFO) summary(m.L4.SFO, data = FALSE) ``` @@ -235,14 +229,13 @@ summary(m.L4.SFO, data = FALSE) The chi^2 error level of 3.3% as well as the plot suggest that the model fits very well. -The FOMC model for comparison +The FOMC model for comparison: ```{r fig.height = 5} -m.L4.FOMC <- mkinfit(FOMC, FOCUS_2006_L4_mkin, quiet = TRUE) +m.L4.FOMC <- mkinfit("FOMC", FOCUS_2006_L4_mkin, quiet = TRUE) plot(m.L4.FOMC) summary(m.L4.FOMC, data = FALSE) ``` The error level at which the chi^2 test passes is slightly lower for the FOMC model. However, the difference appears negligible. - diff --git a/vignettes/FOCUS_L.html b/vignettes/FOCUS_L.html index 85fadbfe..614fcf32 100644 --- a/vignettes/FOCUS_L.html +++ b/vignettes/FOCUS_L.html @@ -190,7 +190,7 @@ hr {

Laboratory Data L1

The following code defines example dataset L1 from the FOCUS kinetics -report, p. 284

+report, p. 284:

library("mkin")
 
@@ -207,51 +207,43 @@ report, p. 284

FOCUS_2006_L1_mkin <- mkin_wide_to_long(FOCUS_2006_L1) -

The next step is to set up the models used for the kinetic analysis. Note that -the model definitions contain the names of the observed variables in the data. -In this case, there is only one variable called parent.

+

Here we use the assumptions of simple first order (SFO), the case of declining +rate constant over time (FOMC) and the case of two different phases of the +kinetics (DFOP). For a more detailed discussion of the models, please see the +FOCUS kinetics report.

-
SFO <- mkinmod(parent = list(type = "SFO"))
-FOMC <- mkinmod(parent = list(type = "FOMC"))
-DFOP <- mkinmod(parent = list(type = "DFOP"))
-
- -

The three models cover the first assumption of simple first order (SFO), -the case of declining rate constant over time (FOMC) and the case of two -different phases of the kinetics (DFOP). For a more detailed discussion -of the models, please see the FOCUS kinetics report.

+

Since mkin version 0.9-32 (July 2014), we can use shorthand notation like SFO +for parent only degradation models. The following two lines fit the model and +produce the summary report of the model fit. This covers the numerical analysis +given in the FOCUS report.

-

The following two lines fit the model and produce the summary report -of the model fit. This covers the numerical analysis given in the -FOCUS report.

- -
m.L1.SFO <- mkinfit(SFO, FOCUS_2006_L1_mkin, quiet=TRUE)
+
m.L1.SFO <- mkinfit("SFO", FOCUS_2006_L1_mkin, quiet=TRUE)
 summary(m.L1.SFO)
 
## mkin version:    0.9.32 
 ## R version:       3.1.1 
-## Date of fit:     Thu Jul 17 12:37:41 2014 
-## Date of summary: Thu Jul 17 12:37:41 2014 
+## Date of fit:     Mon Jul 21 09:14:29 2014 
+## Date of summary: Mon Jul 21 09:14:29 2014 
 ## 
 ## Equations:
 ## [1] d_parent = - k_parent_sink * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Marq using 14 model solutions performed in 0.087 s
+## Fitted with method Marq using 14 model solutions performed in 0.081 s
 ## 
 ## Weighting: none
 ## 
 ## Starting values for parameters to be optimised:
 ##               value   type
-## parent_0      100.0  state
-## k_parent_sink   0.1 deparm
+## parent_0      89.85  state
+## k_parent_sink  0.10 deparm
 ## 
 ## Starting values for the transformed parameters actually optimised:
-##                     value lower upper
-## parent_0          100.000  -Inf   Inf
-## log_k_parent_sink  -2.303  -Inf   Inf
+##                    value lower upper
+## parent_0          89.850  -Inf   Inf
+## log_k_parent_sink -2.303  -Inf   Inf
 ## 
 ## Fixed parameter values:
 ## None
@@ -259,7 +251,7 @@ summary(m.L1.SFO)
 ## Optimised, transformed parameters:
 ##                   Estimate Std. Error Lower Upper t value Pr(>|t|)
 ## parent_0             92.50     1.3700 89.60 95.40    67.6 4.34e-21
-## log_k_parent_sink    -2.35     0.0406 -2.43 -2.26   -57.9 5.15e-20
+## log_k_parent_sink    -2.35     0.0406 -2.43 -2.26   -57.9 5.16e-20
 ##                     Pr(>t)
 ## parent_0          2.17e-21
 ## log_k_parent_sink 2.58e-20
@@ -316,67 +308,70 @@ summary(m.L1.SFO)
 
plot(m.L1.SFO)
 
-

plot of chunk unnamed-chunk-5

+

plot of chunk unnamed-chunk-4

The residual plot can be easily obtained by

mkinresplot(m.L1.SFO, ylab = "Observed", xlab = "Time")
 
-

plot of chunk unnamed-chunk-6

+

plot of chunk unnamed-chunk-5

For comparison, the FOMC model is fitted as well, and the chi2 error level is checked.

-
m.L1.FOMC <- mkinfit(FOMC, FOCUS_2006_L1_mkin, quiet=TRUE)
+
m.L1.FOMC <- mkinfit("FOMC", FOCUS_2006_L1_mkin, quiet=TRUE)
 summary(m.L1.FOMC, data = FALSE)
 
## mkin version:    0.9.32 
 ## R version:       3.1.1 
-## Date of fit:     Thu Jul 17 12:37:42 2014 
-## Date of summary: Thu Jul 17 12:37:42 2014 
+## Date of fit:     Mon Jul 21 09:14:30 2014 
+## Date of summary: Mon Jul 21 09:14:30 2014 
 ## 
 ## Equations:
 ## [1] d_parent = - (alpha/beta) * ((time/beta) + 1)^-1 * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Marq using 45 model solutions performed in 0.266 s
+## Fitted with method Marq using 53 model solutions performed in 0.32 s
 ## 
 ## Weighting: none
 ## 
 ## Starting values for parameters to be optimised:
 ##          value   type
-## parent_0   100  state
-## alpha        1 deparm
-## beta        10 deparm
+## parent_0 89.85  state
+## alpha     1.00 deparm
+## beta     10.00 deparm
 ## 
 ## Starting values for the transformed parameters actually optimised:
-##             value lower upper
-## parent_0  100.000  -Inf   Inf
-## log_alpha   0.000  -Inf   Inf
-## log_beta    2.303  -Inf   Inf
+##            value lower upper
+## parent_0  89.850  -Inf   Inf
+## log_alpha  0.000  -Inf   Inf
+## log_beta   2.303  -Inf   Inf
 ## 
 ## Fixed parameter values:
 ## None
 ## 
 ## Optimised, transformed parameters:
-##           Estimate Std. Error Lower Upper t value Pr(>|t|) Pr(>t)
-## parent_0      92.5         NA    NA    NA      NA       NA     NA
-## log_alpha     25.6         NA    NA    NA      NA       NA     NA
-## log_beta      28.0         NA    NA    NA      NA       NA     NA
+##           Estimate Std. Error Lower Upper t value Pr(>|t|)   Pr(>t)
+## parent_0      92.5       1.45 89.40  95.6   63.60 1.17e-19 5.85e-20
+## log_alpha     14.9      10.60 -7.75  37.5    1.40 1.82e-01 9.08e-02
+## log_beta      17.2      10.60 -5.38  39.8    1.62 1.25e-01 6.26e-02
 ## 
 ## Parameter correlation:
-## Could not estimate covariance matrix; singular system:
+##           parent_0 log_alpha log_beta
+## parent_0     1.000      0.24    0.238
+## log_alpha    0.240      1.00    1.000
+## log_beta     0.238      1.00    1.000
 ## 
 ## Residual standard error: 3.05 on 15 degrees of freedom
 ## 
 ## Backtransformed parameters:
-##          Estimate Lower Upper
-## parent_0 9.25e+01    NA    NA
-## alpha    1.35e+11    NA    NA
-## beta     1.41e+12    NA    NA
+##          Estimate    Lower    Upper
+## parent_0 9.25e+01 8.94e+01 9.56e+01
+## alpha    2.85e+06 4.32e-04 1.88e+16
+## beta     2.98e+07 4.59e-03 1.93e+17
 ## 
 ## Chi2 error levels in percent:
 ##          err.min n.optim df
@@ -390,26 +385,24 @@ summary(m.L1.FOMC, data = FALSE)
 
 

Due to the higher number of parameters, and the lower number of degrees of freedom of the fit, the chi2 error level is actually higher for the FOMC -model (3.6%) than for the SFO model (3.4%). Additionally, the covariance -matrix can not be obtained, indicating overparameterisation of the model. -As a consequence, no standard errors for transformed parameters nor -confidence intervals for backtransformed parameters are available.

+model (3.6%) than for the SFO model (3.4%). Additionally, the parameters +log_alpha and log_beta internally fitted in the model have p-values for the two +sided t-test of 0.18 and 0.125, and their correlation is 1.000, indicating that +the model is overparameterised.

The chi2 error levels reported in Appendix 3 and Appendix 7 to the FOCUS kinetics report are rounded to integer percentages and partly deviate by one percentage point from the results calculated by mkin. The reason for this is not known. However, mkin gives the same chi2 error levels -as the kinfit package.

- -

Furthermore, the calculation routines of the kinfit package have been extensively -compared to the results obtained by the KinGUI software, as documented in the -kinfit package vignette. KinGUI is a widely used standard package in this field. -Therefore, the reason for the difference was not investigated further.

+as the kinfit package. Furthermore, the calculation routines of the kinfit +package have been extensively compared to the results obtained by the KinGUI +software, as documented in the kinfit package vignette. KinGUI is a widely used +standard package in this field.

Laboratory Data L2

The following code defines example dataset L2 from the FOCUS kinetics -report, p. 287

+report, p. 287:

FOCUS_2006_L2 = data.frame(
   t = rep(c(0, 1, 3, 7, 14, 28), each = 2),
@@ -419,35 +412,35 @@ report, p. 287

FOCUS_2006_L2_mkin <- mkin_wide_to_long(FOCUS_2006_L2)
-

Again, the SFO model is fitted and a summary is obtained.

+

Again, the SFO model is fitted and a summary is obtained:

-
m.L2.SFO <- mkinfit(SFO, FOCUS_2006_L2_mkin, quiet=TRUE)
+
m.L2.SFO <- mkinfit("SFO", FOCUS_2006_L2_mkin, quiet=TRUE)
 summary(m.L2.SFO)
 
## mkin version:    0.9.32 
 ## R version:       3.1.1 
-## Date of fit:     Thu Jul 17 12:37:42 2014 
-## Date of summary: Thu Jul 17 12:37:42 2014 
+## Date of fit:     Mon Jul 21 09:14:30 2014 
+## Date of summary: Mon Jul 21 09:14:30 2014 
 ## 
 ## Equations:
 ## [1] d_parent = - k_parent_sink * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Marq using 32 model solutions performed in 0.357 s
+## Fitted with method Marq using 29 model solutions performed in 0.155 s
 ## 
 ## Weighting: none
 ## 
 ## Starting values for parameters to be optimised:
 ##               value   type
-## parent_0      100.0  state
-## k_parent_sink   0.1 deparm
+## parent_0      93.95  state
+## k_parent_sink  0.10 deparm
 ## 
 ## Starting values for the transformed parameters actually optimised:
-##                     value lower upper
-## parent_0          100.000  -Inf   Inf
-## log_k_parent_sink  -2.303  -Inf   Inf
+##                    value lower upper
+## parent_0          93.950  -Inf   Inf
+## log_k_parent_sink -2.303  -Inf   Inf
 ## 
 ## Fixed parameter values:
 ## None
@@ -487,8 +480,8 @@ summary(m.L2.SFO)
 ## 
 ## Data:
 ##  time variable observed predicted residual
-##     0   parent     96.1  9.15e+01    4.634
-##     0   parent     91.8  9.15e+01    0.334
+##     0   parent     96.1  9.15e+01    4.635
+##     0   parent     91.8  9.15e+01    0.335
 ##     1   parent     41.4  4.71e+01   -5.740
 ##     1   parent     38.7  4.71e+01   -8.440
 ##     3   parent     19.3  1.25e+01    6.779
@@ -509,7 +502,7 @@ plot(m.L2.SFO)
 mkinresplot(m.L2.SFO)
 
-

plot of chunk unnamed-chunk-10

+

plot of chunk unnamed-chunk-9

In the FOCUS kinetics report, it is stated that there is no apparent systematic error observed from the residual plot up to the measured DT90 (approximately at @@ -524,42 +517,42 @@ models generally only implement SFO kinetics.

For comparison, the FOMC model is fitted as well, and the chi2 error level is checked.

-
m.L2.FOMC <- mkinfit(FOMC, FOCUS_2006_L2_mkin, quiet = TRUE)
+
m.L2.FOMC <- mkinfit("FOMC", FOCUS_2006_L2_mkin, quiet = TRUE)
 par(mfrow = c(2, 1))
 plot(m.L2.FOMC)
 mkinresplot(m.L2.FOMC)
 
-

plot of chunk unnamed-chunk-11

+

plot of chunk unnamed-chunk-10

summary(m.L2.FOMC, data = FALSE)
 
## mkin version:    0.9.32 
 ## R version:       3.1.1 
-## Date of fit:     Thu Jul 17 12:37:43 2014 
-## Date of summary: Thu Jul 17 12:37:43 2014 
+## Date of fit:     Mon Jul 21 09:14:31 2014 
+## Date of summary: Mon Jul 21 09:14:31 2014 
 ## 
 ## Equations:
 ## [1] d_parent = - (alpha/beta) * ((time/beta) + 1)^-1 * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Marq using 39 model solutions performed in 0.235 s
+## Fitted with method Marq using 35 model solutions performed in 0.199 s
 ## 
 ## Weighting: none
 ## 
 ## Starting values for parameters to be optimised:
 ##          value   type
-## parent_0   100  state
-## alpha        1 deparm
-## beta        10 deparm
+## parent_0 93.95  state
+## alpha     1.00 deparm
+## beta     10.00 deparm
 ## 
 ## Starting values for the transformed parameters actually optimised:
-##             value lower upper
-## parent_0  100.000  -Inf   Inf
-## log_alpha   0.000  -Inf   Inf
-## log_beta    2.303  -Inf   Inf
+##            value lower upper
+## parent_0  93.950  -Inf   Inf
+## log_alpha  0.000  -Inf   Inf
+## log_beta   2.303  -Inf   Inf
 ## 
 ## Fixed parameter values:
 ## None
@@ -600,62 +593,62 @@ experimental error has to be assumed in order to explain the data.

Fitting the four parameter DFOP model further reduces the chi2 error level.

-
m.L2.DFOP <- mkinfit(DFOP, FOCUS_2006_L2_mkin, quiet = TRUE)
+
m.L2.DFOP <- mkinfit("DFOP", FOCUS_2006_L2_mkin, quiet = TRUE)
 plot(m.L2.DFOP)
 
-

plot of chunk unnamed-chunk-12

+

plot of chunk unnamed-chunk-11

Here, the default starting parameters for the DFOP model obviously do not lead to a reasonable solution. Therefore the fit is repeated with different starting parameters.

-
m.L2.DFOP <- mkinfit(DFOP, FOCUS_2006_L2_mkin, 
+
m.L2.DFOP <- mkinfit("DFOP", FOCUS_2006_L2_mkin, 
   parms.ini = c(k1 = 1, k2 = 0.01, g = 0.8),
   quiet=TRUE)
 plot(m.L2.DFOP)
 
-

plot of chunk unnamed-chunk-13

+

plot of chunk unnamed-chunk-12

summary(m.L2.DFOP, data = FALSE)
 
## mkin version:    0.9.32 
 ## R version:       3.1.1 
-## Date of fit:     Thu Jul 17 12:37:44 2014 
-## Date of summary: Thu Jul 17 12:37:44 2014 
+## Date of fit:     Mon Jul 21 09:14:31 2014 
+## Date of summary: Mon Jul 21 09:14:31 2014 
 ## 
 ## Equations:
 ## [1] d_parent = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) * exp(-k2 * time)) / (g * exp(-k1 * time) + (1 - g) * exp(-k2 * time))) * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Marq using 54 model solutions performed in 0.423 s
+## Fitted with method Marq using 43 model solutions performed in 0.241 s
 ## 
 ## Weighting: none
 ## 
 ## Starting values for parameters to be optimised:
 ##          value   type
-## parent_0 1e+02  state
-## k1       1e+00 deparm
-## k2       1e-02 deparm
-## g        8e-01 deparm
+## parent_0 93.95  state
+## k1        1.00 deparm
+## k2        0.01 deparm
+## g         0.80 deparm
 ## 
 ## Starting values for the transformed parameters actually optimised:
-##             value lower upper
-## parent_0 100.0000  -Inf   Inf
-## log_k1     0.0000  -Inf   Inf
-## log_k2    -4.6052  -Inf   Inf
-## g_ilr      0.9803  -Inf   Inf
+##            value lower upper
+## parent_0 93.9500  -Inf   Inf
+## log_k1    0.0000  -Inf   Inf
+## log_k2   -4.6052  -Inf   Inf
+## g_ilr     0.9803  -Inf   Inf
 ## 
 ## Fixed parameter values:
 ## None
 ## 
 ## Optimised, transformed parameters:
 ##          Estimate Std. Error Lower Upper t value Pr(>|t|) Pr(>t)
-## parent_0   93.900         NA    NA    NA      NA       NA     NA
-## log_k1      4.960         NA    NA    NA      NA       NA     NA
+## parent_0   94.000         NA    NA    NA      NA       NA     NA
+## log_k1      6.160         NA    NA    NA      NA       NA     NA
 ## log_k2     -1.090         NA    NA    NA      NA       NA     NA
 ## g_ilr      -0.282         NA    NA    NA      NA       NA     NA
 ## 
@@ -666,8 +659,8 @@ plot(m.L2.DFOP)
 ## 
 ## Backtransformed parameters:
 ##          Estimate Lower Upper
-## parent_0   93.900    NA    NA
-## k1        142.000    NA    NA
+## parent_0   94.000    NA    NA
+## k1        476.000    NA    NA
 ## k2          0.337    NA    NA
 ## g           0.402    NA    NA
 ## 
@@ -678,7 +671,7 @@ plot(m.L2.DFOP)
 ## 
 ## Estimated disappearance times:
 ##        DT50 DT90 DT50_k1 DT50_k2
-## parent   NA   NA 0.00487    2.06
+## parent   NA   NA 0.00146    2.06
 

Here, the DFOP model is clearly the best-fit model for dataset L2 based on the @@ -699,38 +692,38 @@ FOCUS_2006_L3_mkin <- mkin_wide_to_long(FOCUS_2006_L3)

SFO model, summary and plot:

-
m.L3.SFO <- mkinfit(SFO, FOCUS_2006_L3_mkin, quiet = TRUE)
+
m.L3.SFO <- mkinfit("SFO", FOCUS_2006_L3_mkin, quiet = TRUE)
 plot(m.L3.SFO)
 
-

plot of chunk unnamed-chunk-15

+

plot of chunk unnamed-chunk-14

summary(m.L3.SFO)
 
## mkin version:    0.9.32 
 ## R version:       3.1.1 
-## Date of fit:     Thu Jul 17 12:37:45 2014 
-## Date of summary: Thu Jul 17 12:37:45 2014 
+## Date of fit:     Mon Jul 21 09:14:32 2014 
+## Date of summary: Mon Jul 21 09:14:32 2014 
 ## 
 ## Equations:
 ## [1] d_parent = - k_parent_sink * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Marq using 44 model solutions performed in 0.241 s
+## Fitted with method Marq using 44 model solutions performed in 0.242 s
 ## 
 ## Weighting: none
 ## 
 ## Starting values for parameters to be optimised:
 ##               value   type
-## parent_0      100.0  state
+## parent_0       97.8  state
 ## k_parent_sink   0.1 deparm
 ## 
 ## Starting values for the transformed parameters actually optimised:
-##                     value lower upper
-## parent_0          100.000  -Inf   Inf
-## log_k_parent_sink  -2.303  -Inf   Inf
+##                    value lower upper
+## parent_0          97.800  -Inf   Inf
+## log_k_parent_sink -2.303  -Inf   Inf
 ## 
 ## Fixed parameter values:
 ## None
@@ -770,7 +763,7 @@ plot(m.L3.SFO)
 ## 
 ## Data:
 ##  time variable observed predicted residual
-##     0   parent     97.8     74.87  22.9273
+##     0   parent     97.8     74.87  22.9274
 ##     3   parent     60.0     69.41  -9.4065
 ##     7   parent     51.0     62.73 -11.7340
 ##    14   parent     43.0     52.56  -9.5634
@@ -785,40 +778,40 @@ does not fit very well. 

The FOMC model performs better:

-
m.L3.FOMC <- mkinfit(FOMC, FOCUS_2006_L3_mkin, quiet = TRUE)
+
m.L3.FOMC <- mkinfit("FOMC", FOCUS_2006_L3_mkin, quiet = TRUE)
 plot(m.L3.FOMC)
 
-

plot of chunk unnamed-chunk-16

+

plot of chunk unnamed-chunk-15

summary(m.L3.FOMC, data = FALSE)
 
## mkin version:    0.9.32 
 ## R version:       3.1.1 
-## Date of fit:     Thu Jul 17 12:37:45 2014 
-## Date of summary: Thu Jul 17 12:37:45 2014 
+## Date of fit:     Mon Jul 21 09:14:32 2014 
+## Date of summary: Mon Jul 21 09:14:32 2014 
 ## 
 ## Equations:
 ## [1] d_parent = - (alpha/beta) * ((time/beta) + 1)^-1 * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Marq using 26 model solutions performed in 0.208 s
+## Fitted with method Marq using 26 model solutions performed in 0.143 s
 ## 
 ## Weighting: none
 ## 
 ## Starting values for parameters to be optimised:
 ##          value   type
-## parent_0   100  state
-## alpha        1 deparm
-## beta        10 deparm
+## parent_0  97.8  state
+## alpha      1.0 deparm
+## beta      10.0 deparm
 ## 
 ## Starting values for the transformed parameters actually optimised:
-##             value lower upper
-## parent_0  100.000  -Inf   Inf
-## log_alpha   0.000  -Inf   Inf
-## log_beta    2.303  -Inf   Inf
+##            value lower upper
+## parent_0  97.800  -Inf   Inf
+## log_alpha  0.000  -Inf   Inf
+## log_beta   2.303  -Inf   Inf
 ## 
 ## Fixed parameter values:
 ## None
@@ -858,42 +851,42 @@ plot(m.L3.FOMC)
 

Fitting the four parameter DFOP model further reduces the chi2 error level considerably:

-
m.L3.DFOP <- mkinfit(DFOP, FOCUS_2006_L3_mkin, quiet = TRUE)
+
m.L3.DFOP <- mkinfit("DFOP", FOCUS_2006_L3_mkin, quiet = TRUE)
 plot(m.L3.DFOP)
 
-

plot of chunk unnamed-chunk-17

+

plot of chunk unnamed-chunk-16

summary(m.L3.DFOP, data = FALSE)
 
## mkin version:    0.9.32 
 ## R version:       3.1.1 
-## Date of fit:     Thu Jul 17 12:37:46 2014 
-## Date of summary: Thu Jul 17 12:37:46 2014 
+## Date of fit:     Mon Jul 21 09:14:32 2014 
+## Date of summary: Mon Jul 21 09:14:32 2014 
 ## 
 ## Equations:
 ## [1] d_parent = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) * exp(-k2 * time)) / (g * exp(-k1 * time) + (1 - g) * exp(-k2 * time))) * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Marq using 37 model solutions performed in 0.338 s
+## Fitted with method Marq using 37 model solutions performed in 0.21 s
 ## 
 ## Weighting: none
 ## 
 ## Starting values for parameters to be optimised:
 ##          value   type
-## parent_0 1e+02  state
-## k1       1e-01 deparm
-## k2       1e-02 deparm
-## g        5e-01 deparm
+## parent_0 97.80  state
+## k1        0.10 deparm
+## k2        0.01 deparm
+## g         0.50 deparm
 ## 
 ## Starting values for the transformed parameters actually optimised:
-##            value lower upper
-## parent_0 100.000  -Inf   Inf
-## log_k1    -2.303  -Inf   Inf
-## log_k2    -4.605  -Inf   Inf
-## g_ilr      0.000  -Inf   Inf
+##           value lower upper
+## parent_0 97.800  -Inf   Inf
+## log_k1   -2.303  -Inf   Inf
+## log_k2   -4.605  -Inf   Inf
+## g_ilr     0.000  -Inf   Inf
 ## 
 ## Fixed parameter values:
 ## None
@@ -936,10 +929,15 @@ and the correlation matrix suggest that the parameter estimates are reliable, an
 the DFOP model can be used as the best-fit model based on the chi2 error
 level criterion for laboratory data L3.

+

This is also an example where the standard t-test for the parameter g_ilr is +misleading, as it tests for a significant difference from zero. In this case, +zero appears to be the correct value for this parameter, and the confidence +interval for the backtransformed parameter g is quite narrow.

+

Laboratory Data L4

The following code defines example dataset L4 from the FOCUS kinetics -report, p. 293

+report, p. 293:

FOCUS_2006_L4 = data.frame(
   t = c(0, 3, 7, 14, 30, 60, 91, 120),
@@ -949,38 +947,38 @@ FOCUS_2006_L4_mkin <- mkin_wide_to_long(FOCUS_2006_L4)
 
 

SFO model, summary and plot:

-
m.L4.SFO <- mkinfit(SFO, FOCUS_2006_L4_mkin, quiet = TRUE)
+
m.L4.SFO <- mkinfit("SFO", FOCUS_2006_L4_mkin, quiet = TRUE)
 plot(m.L4.SFO)
 
-

plot of chunk unnamed-chunk-19

+

plot of chunk unnamed-chunk-18

summary(m.L4.SFO, data = FALSE)
 
## mkin version:    0.9.32 
 ## R version:       3.1.1 
-## Date of fit:     Thu Jul 17 12:37:46 2014 
-## Date of summary: Thu Jul 17 12:37:46 2014 
+## Date of fit:     Mon Jul 21 09:14:33 2014 
+## Date of summary: Mon Jul 21 09:14:33 2014 
 ## 
 ## Equations:
 ## [1] d_parent = - k_parent_sink * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Marq using 20 model solutions performed in 0.127 s
+## Fitted with method Marq using 20 model solutions performed in 0.109 s
 ## 
 ## Weighting: none
 ## 
 ## Starting values for parameters to be optimised:
 ##               value   type
-## parent_0      100.0  state
+## parent_0       96.6  state
 ## k_parent_sink   0.1 deparm
 ## 
 ## Starting values for the transformed parameters actually optimised:
-##                     value lower upper
-## parent_0          100.000  -Inf   Inf
-## log_k_parent_sink  -2.303  -Inf   Inf
+##                    value lower upper
+## parent_0          96.600  -Inf   Inf
+## log_k_parent_sink -2.303  -Inf   Inf
 ## 
 ## Fixed parameter values:
 ## None
@@ -1022,42 +1020,42 @@ plot(m.L4.SFO)
 

The chi2 error level of 3.3% as well as the plot suggest that the model fits very well.

-

The FOMC model for comparison

+

The FOMC model for comparison:

-
m.L4.FOMC <- mkinfit(FOMC, FOCUS_2006_L4_mkin, quiet = TRUE)
+
m.L4.FOMC <- mkinfit("FOMC", FOCUS_2006_L4_mkin, quiet = TRUE)
 plot(m.L4.FOMC)
 
-

plot of chunk unnamed-chunk-20

+

plot of chunk unnamed-chunk-19

summary(m.L4.FOMC, data = FALSE)
 
## mkin version:    0.9.32 
 ## R version:       3.1.1 
-## Date of fit:     Thu Jul 17 12:37:46 2014 
-## Date of summary: Thu Jul 17 12:37:46 2014 
+## Date of fit:     Mon Jul 21 09:14:33 2014 
+## Date of summary: Mon Jul 21 09:14:33 2014 
 ## 
 ## Equations:
 ## [1] d_parent = - (alpha/beta) * ((time/beta) + 1)^-1 * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Marq using 53 model solutions performed in 0.355 s
+## Fitted with method Marq using 48 model solutions performed in 0.26 s
 ## 
 ## Weighting: none
 ## 
 ## Starting values for parameters to be optimised:
 ##          value   type
-## parent_0   100  state
-## alpha        1 deparm
-## beta        10 deparm
+## parent_0  96.6  state
+## alpha      1.0 deparm
+## beta      10.0 deparm
 ## 
 ## Starting values for the transformed parameters actually optimised:
-##             value lower upper
-## parent_0  100.000  -Inf   Inf
-## log_alpha   0.000  -Inf   Inf
-## log_beta    2.303  -Inf   Inf
+##            value lower upper
+## parent_0  96.600  -Inf   Inf
+## log_alpha  0.000  -Inf   Inf
+## log_beta   2.303  -Inf   Inf
 ## 
 ## Fixed parameter values:
 ## None
diff --git a/vignettes/mkin.pdf b/vignettes/mkin.pdf
index 9cf1b3e5..b69ddddc 100644
Binary files a/vignettes/mkin.pdf and b/vignettes/mkin.pdf differ
-- 
cgit v1.2.3


From 9b947f0358d3a1b1fc922bfd0187ca444ce5811d Mon Sep 17 00:00:00 2001
From: Johannes Ranke 
Date: Thu, 24 Jul 2014 14:42:59 +0200
Subject: Bump version, better default for state.ini

---
 DESCRIPTION    |  2 +-
 NEWS.md        |  6 ++++++
 R/mkinfit.R    | 10 ++++++++--
 man/mkinfit.Rd |  1 +
 4 files changed, 16 insertions(+), 3 deletions(-)

(limited to 'man')

diff --git a/DESCRIPTION b/DESCRIPTION
index 2da7f1c1..bf0fa09a 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -2,7 +2,7 @@ Package: mkin
 Type: Package
 Title: Routines for fitting kinetic models with one or more state
   variables to chemical degradation data
-Version: 0.9-32
+Version: 0.9-33
 Date: 2014-07-24
 Authors@R: c(person("Johannes", "Ranke", role = c("aut", "cre", "cph"), 
                     email = "jranke@uni-bremen.de"),
diff --git a/NEWS.md b/NEWS.md
index 02c7c661..4c45a0d1 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,3 +1,9 @@
+# CHANGES in mkin VERSION 0.9-33
+
+## NEW FEATURES
+
+- The initial value (state.ini) for the observed variable with the highest observed residue is set to 100 in case it has no time zero observation and `state.ini = "auto"`
+
 # CHANGES in mkin VERSION 0.9-32
 
 ## NEW FEATURES
diff --git a/R/mkinfit.R b/R/mkinfit.R
index 39d084cb..c98c7586 100644
--- a/R/mkinfit.R
+++ b/R/mkinfit.R
@@ -154,8 +154,14 @@ mkinfit <- function(mkinmod, observed,
 
   # Set default for state.ini if appropriate
   if (state.ini[1] == "auto") {
-    state.ini = c(mean(subset(observed, time == 0 & name == presumed_parent_name)$value), 
-                  rep(0, length(mkinmod$diffs) - 1))
+    presumed_parent_time_0 = subset(observed, 
+                                    time == 0 & name == presumed_parent_name)$value
+    presumed_parent_time_0_mean = mean(presumed_parent_time_0, na.rm = TRUE)
+    if (is.na(presumed_parent_time_0_mean)) {
+      state.ini = c(100, rep(0, length(mkinmod$diffs) - 1))
+    } else {
+      state.ini = c(presumed_parent_time_0_mean, rep(0, length(mkinmod$diffs) - 1))
+    }
   }
 
   # Name the inital state variable values if they are not named yet
diff --git a/man/mkinfit.Rd b/man/mkinfit.Rd
index 581d63f4..4e331e2a 100644
--- a/man/mkinfit.Rd
+++ b/man/mkinfit.Rd
@@ -71,6 +71,7 @@ mkinfit(mkinmod, observed,
     (see \code{map} component of \code{\link{mkinmod}}). The default is to set
     the initial value of the first model variable to the mean of the time zero
     values for the variable with the maximum observed value, and all others to 0.
+    If this variable has no time zero observations, its initial value is set to 100.
   }
   \item{fixed_parms}{
     The names of parameters that should not be optimised but rather kept at the
-- 
cgit v1.2.3


From 7416e25376726d24be67c8802cb56cb18acaebf8 Mon Sep 17 00:00:00 2001
From: Johannes Ranke 
Date: Thu, 24 Jul 2014 14:52:27 +0200
Subject: Semantic correction in help file

---
 man/mkinfit.Rd | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'man')

diff --git a/man/mkinfit.Rd b/man/mkinfit.Rd
index 4e331e2a..e1c9b497 100644
--- a/man/mkinfit.Rd
+++ b/man/mkinfit.Rd
@@ -38,7 +38,7 @@ mkinfit(mkinmod, observed,
     A list of class \code{\link{mkinmod}}, containing the kinetic model to be
     fitted to the data, or one of the shorthand names ("SFO", "FOMC", "DFOP",
     "HS", "SFORB"). If a shorthand name is given, a parent only degradation
-    model is generated for the observation with the highest value in
+    model is generated for the observed variable with the highest value in
     \code{observed}.
   }
   \item{observed}{
-- 
cgit v1.2.3


From f9e3f7964623530983f8c0665df06602d6283ff7 Mon Sep 17 00:00:00 2001
From: Johannes Ranke 
Date: Thu, 24 Jul 2014 14:54:39 +0200
Subject: Improve formulation

---
 man/mkinfit.Rd | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'man')

diff --git a/man/mkinfit.Rd b/man/mkinfit.Rd
index e1c9b497..8c36e77e 100644
--- a/man/mkinfit.Rd
+++ b/man/mkinfit.Rd
@@ -38,7 +38,7 @@ mkinfit(mkinmod, observed,
     A list of class \code{\link{mkinmod}}, containing the kinetic model to be
     fitted to the data, or one of the shorthand names ("SFO", "FOMC", "DFOP",
     "HS", "SFORB"). If a shorthand name is given, a parent only degradation
-    model is generated for the observed variable with the highest value in
+    model is generated for the variable with the highest value in
     \code{observed}.
   }
   \item{observed}{
-- 
cgit v1.2.3


From f30472ecd2afea6bd2153b8ad2bb2f663f3a2742 Mon Sep 17 00:00:00 2001
From: Johannes Ranke 
Date: Mon, 25 Aug 2014 10:39:40 +0200
Subject: Bug fix and unit tests for mkinerrmin

See NEWS.md for details
---
 NEWS.md                           |   7 +++
 R/mkinerrmin.R                    |   9 +--
 TODO                              |   5 --
 inst/unitTests/runit.mkinerrmin.R |  62 +++++++++++++++++++++
 inst/unitTests/runit.mkinfit.R    |  38 +------------
 man/mkinerrmin.Rd                 |  10 ++++
 tests/doRUnit.R                   |   1 -
 vignettes/FOCUS_L.html            | 112 +++++++++++++++++++++-----------------
 vignettes/FOCUS_Z.pdf             | Bin 220196 -> 220177 bytes
 9 files changed, 146 insertions(+), 98 deletions(-)
 create mode 100644 inst/unitTests/runit.mkinerrmin.R

(limited to 'man')

diff --git a/NEWS.md b/NEWS.md
index d05c2095..1ed94c97 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -4,12 +4,19 @@
 
 - The initial value (state.ini) for the observed variable with the highest observed residue is set to 100 in case it has no time zero observation and `state.ini = "auto"`
 
+- A basic unit test for `mkinerrmin()` was written
+
 ## BUG FIXES
 
 - `mkinfit()`: The internally fitted parameter for `g` was named `g_ilr` even when `transform_fractions=FALSE`
 
 - `mkinfit()`: The initial value (state.ini) for the parent compound was not set when the parent was not the (only) variable with the highest value in the observed data.
 
+- `mkinerrmin()`: When checking for degrees of freedom for metabolites, check
+  if their time zero value is fixed instead of checking if the observed value
+  is zero. This ensures correct calculation of degrees of freedom also in cases
+  where the metabolite residue at time zero is greater zero.
+
 ## MINOR CHANGES
 
 - The formatting of differential equations in the summary was improved by wrapping overly long lines
diff --git a/R/mkinerrmin.R b/R/mkinerrmin.R
index 09724730..2697d0a0 100644
--- a/R/mkinerrmin.R
+++ b/R/mkinerrmin.R
@@ -36,10 +36,11 @@ mkinerrmin <- function(fit, alpha = 0.05)
     suffixes = c("_mean", "_pred"))
   errdata <- errdata[order(errdata$time, errdata$name), ]
 
-  # Any value that is set to exactly zero is not really an observed value
-  # Remove those at time 0 - those are caused by the FOCUS recommendation
-  # to set metabolites occurring at time 0 to 0
-  errdata <- subset(errdata, !(time == 0 & value_mean == 0))
+  # Remove values at time zero for variables whose value for state.ini is fixed,
+  # as these will not have any effect in the optimization and should therefore not 
+  # be counted as degrees of freedom.
+  fixed_initials = gsub("_0$", "", rownames(subset(fit$fixed, type = "state")))
+  errdata <- subset(errdata, !(time == 0 & name %in% fixed_initials))
 
   n.optim.overall <- length(parms.optim)
 
diff --git a/TODO b/TODO
index 92a91069..f979d13a 100644
--- a/TODO
+++ b/TODO
@@ -2,11 +2,6 @@ TODO for version 1.0
 - Think about what a user would expect from version 1.0
 - Complete the main package vignette named mkin to include a method description
 - Improve order of parameters in output
-- Write unit tests for mkinerrmin
-- When checking for degrees of freedom for metabolites, check if their time
-  zero value (state.ini) is fixed instead of checking if the observed value is
-  zero (usually in regulatory kinetics it is set to zero anyway, but in the
-  case of known impurities this may not be the case).
 
 Nice to have:
 - Get starting values for formation fractions from data
diff --git a/inst/unitTests/runit.mkinerrmin.R b/inst/unitTests/runit.mkinerrmin.R
new file mode 100644
index 00000000..56a33ff9
--- /dev/null
+++ b/inst/unitTests/runit.mkinerrmin.R
@@ -0,0 +1,62 @@
+# Test SFO_SFO model with FOCUS_2006_D against Schaefer 2007 paper, tolerance = 1% # {{{
+# and check chi2 error values against values obtained with mkin 0.33
+test.FOCUS_2006_D_SFO_SFO <- function()
+{
+  SFO_SFO.1 <- mkinmod(parent = list(type = "SFO", to = "m1"),
+         m1 = list(type = "SFO"), use_of_ff = "min")
+  SFO_SFO.2 <- mkinmod(parent = list(type = "SFO", to = "m1"),
+         m1 = list(type = "SFO"), use_of_ff = "max")
+
+  fit.1.e <- mkinfit(SFO_SFO.1, FOCUS_2006_D)
+  fit.1.d <- mkinfit(SFO_SFO.1, solution_type = "deSolve", FOCUS_2006_D)
+  fit.2.e <- mkinfit(SFO_SFO.2, FOCUS_2006_D)
+  fit.2.d <- mkinfit(SFO_SFO.2, solution_type = "deSolve", FOCUS_2006_D)
+
+  FOCUS_2006_D_results_schaefer07_means <- c(
+    parent_0 = 99.65, DT50_parent = 7.04, DT50_m1 = 131.34)
+
+  r.1.e <- c(fit.1.e$bparms.optim[[1]], endpoints(fit.1.e)$distimes[[1]])
+  r.1.d <- c(fit.1.d$bparms.optim[[1]], endpoints(fit.1.d)$distimes[[1]])
+  r.2.e <- c(fit.2.e$bparms.optim[[1]], endpoints(fit.2.e)$distimes[[1]])
+  r.2.d <- c(fit.2.d$bparms.optim[[1]], endpoints(fit.2.d)$distimes[[1]])
+
+  dev.1.e <- 100 * (r.1.e - FOCUS_2006_D_results_schaefer07_means)/r.1.e 
+  checkIdentical(as.numeric(abs(dev.1.e)) < 1, rep(TRUE, 3))
+  dev.1.d <- 100 * (r.1.d - FOCUS_2006_D_results_schaefer07_means)/r.1.d 
+  checkIdentical(as.numeric(abs(dev.1.d)) < 1, rep(TRUE, 3))
+  dev.2.e <- 100 * (r.2.e - FOCUS_2006_D_results_schaefer07_means)/r.2.e 
+  checkIdentical(as.numeric(abs(dev.2.e)) < 1, rep(TRUE, 3))
+  dev.2.d <- 100 * (r.2.d - FOCUS_2006_D_results_schaefer07_means)/r.2.d 
+  checkIdentical(as.numeric(abs(dev.2.d)) < 1, rep(TRUE, 3))
+
+  round(mkinerrmin(fit.2.e), 4)
+  round(mkinerrmin(fit.2.d), 4)
+
+  errmin.FOCUS_2006_D_rounded = data.frame(
+    err.min = c(0.0640, 0.0646, 0.0469),
+    n.optim = c(4, 2, 2),
+    df = c(15, 7, 8), 
+    row.names = c("All data", "parent", "m1"))
+  checkEqualsNumeric(round(mkinerrmin(fit.2.e), 4),
+                     errmin.FOCUS_2006_D_rounded)
+} # }}}
+
+# Test SFO_SFO model with FOCUS_2006_E against values obtained with mkin 0.33 {{{
+test.FOCUS_2006_E_SFO_SFO <- function()
+{
+  SFO_SFO.2 <- mkinmod(parent = list(type = "SFO", to = "m1"),
+         m1 = list(type = "SFO"), use_of_ff = "max")
+
+  fit.2.e <- mkinfit(SFO_SFO.2, FOCUS_2006_E)
+
+  round(mkinerrmin(fit.2.e), 4)
+  errmin.FOCUS_2006_E_rounded = data.frame(
+    err.min = c(0.1544, 0.1659, 0.1095),
+    n.optim = c(4, 2, 2),
+    df = c(13, 7, 6),
+    row.names = c("All data", "parent", "m1"))
+  checkEqualsNumeric(round(mkinerrmin(fit.2.e), 4),
+                     errmin.FOCUS_2006_E_rounded)
+} # }}}
+
+
diff --git a/inst/unitTests/runit.mkinfit.R b/inst/unitTests/runit.mkinfit.R
index fdbc86e0..8eefb995 100644
--- a/inst/unitTests/runit.mkinfit.R
+++ b/inst/unitTests/runit.mkinfit.R
@@ -1,6 +1,4 @@
-# $Id: runit.mkinfit.R 68 2010-09-09 22:40:04Z jranke $
-
-# Copyright (C) 2010-2013 Johannes Ranke
+# Copyright (C) 2010-2014 Johannes Ranke
 # Contact: jranke@uni-bremen.de
 
 # This file is part of the R package mkin
@@ -189,40 +187,6 @@ test.FOCUS_2006_SFORB <- function()
   checkIdentical(dev.B.SFORB.2 < 1, rep(TRUE, length(dev.B.SFORB.2)))
 } # }}}
 
-# Test SFO_SFO model with FOCUS_2006_D against Schaefer 2007 paper, tolerance = 1% # {{{
-test.FOCUS_2006_D_SFO_SFO <- function()
-{
-  SFO_SFO.1 <- mkinmod(parent = list(type = "SFO", to = "m1"),
-         m1 = list(type = "SFO"), use_of_ff = "min")
-  SFO_SFO.2 <- mkinmod(parent = list(type = "SFO", to = "m1"),
-         m1 = list(type = "SFO"), use_of_ff = "max")
-
-  fit.1.e <- mkinfit(SFO_SFO.1, FOCUS_2006_D)
-  fit.1.d <- mkinfit(SFO_SFO.1, solution_type = "deSolve", FOCUS_2006_D)
-  fit.2.e <- mkinfit(SFO_SFO.2, FOCUS_2006_D)
-  SFO <- mkinmod(parent = list(type = "SFO"))
-  f.SFO <- mkinfit(SFO, FOCUS_2006_D)
-  fit.2.d <- mkinfit(SFO_SFO.2, solution_type = "deSolve", FOCUS_2006_D)
-  fit.2.e <- mkinfit(SFO_SFO.2, FOCUS_2006_D)
-
-  FOCUS_2006_D_results_schaefer07_means <- c(
-    parent_0 = 99.65, DT50_parent = 7.04, DT50_m1 = 131.34)
-
-  r.1.e <- c(fit.1.e$bparms.optim[[1]], endpoints(fit.1.e)$distimes[[1]])
-  r.1.d <- c(fit.1.d$bparms.optim[[1]], endpoints(fit.1.d)$distimes[[1]])
-  r.2.e <- c(fit.2.e$bparms.optim[[1]], endpoints(fit.2.e)$distimes[[1]])
-  r.2.d <- c(fit.2.d$bparms.optim[[1]], endpoints(fit.2.d)$distimes[[1]])
-
-  dev.1.e <- 100 * (r.1.e - FOCUS_2006_D_results_schaefer07_means)/r.1.e 
-  checkIdentical(as.numeric(abs(dev.1.e)) < 1, rep(TRUE, 3))
-  dev.1.d <- 100 * (r.1.d - FOCUS_2006_D_results_schaefer07_means)/r.1.d 
-  checkIdentical(as.numeric(abs(dev.1.d)) < 1, rep(TRUE, 3))
-  dev.2.e <- 100 * (r.2.e - FOCUS_2006_D_results_schaefer07_means)/r.2.e 
-  checkIdentical(as.numeric(abs(dev.2.e)) < 1, rep(TRUE, 3))
-  dev.2.d <- 100 * (r.2.d - FOCUS_2006_D_results_schaefer07_means)/r.2.d 
-  checkIdentical(as.numeric(abs(dev.2.d)) < 1, rep(TRUE, 3))
-} # }}}
-
 # Test eigenvalue based fit to Schaefer 2007 data against solution from conference paper {{{
 test.mkinfit.schaefer07_complex_example <- function()
 {
diff --git a/man/mkinerrmin.Rd b/man/mkinerrmin.Rd
index c43d87a1..78ab414e 100644
--- a/man/mkinerrmin.Rd
+++ b/man/mkinerrmin.Rd
@@ -34,6 +34,16 @@ mkinerrmin(fit, alpha = 0.05)
 \details{
     This function is used internally by \code{\link{summary.mkinfit}}.
 }
+\examples{
+SFO_SFO = mkinmod(parent = list(type = "SFO", to = "m1"),
+                  m1 = list(type = "SFO"),
+                  use_of_ff = "max")
+
+fit_FOCUS_D = mkinfit(SFO_SFO, FOCUS_2006_D, quiet = TRUE)
+round(mkinerrmin(fit_FOCUS_D), 4)
+fit_FOCUS_E = mkinfit(SFO_SFO, FOCUS_2006_E, quiet = TRUE)
+round(mkinerrmin(fit_FOCUS_E), 4)
+}
 \references{ 
   FOCUS (2006) \dQuote{Guidance Document on Estimating Persistence and
   Degradation Kinetics from Environmental Fate Studies on Pesticides in EU
diff --git a/tests/doRUnit.R b/tests/doRUnit.R
index f0f82812..9faee940 100644
--- a/tests/doRUnit.R
+++ b/tests/doRUnit.R
@@ -1,4 +1,3 @@
-# $Id: doRUnit.R 96 2011-04-29 11:10:40Z jranke $
 # Adapted from a version around 2.9 of the rcdk package by Rajarshi Guha
 if(require("RUnit", quietly=TRUE)) {
  
diff --git a/vignettes/FOCUS_L.html b/vignettes/FOCUS_L.html
index ab7ccaee..2dd186de 100644
--- a/vignettes/FOCUS_L.html
+++ b/vignettes/FOCUS_L.html
@@ -193,7 +193,13 @@ hr {
 report, p. 284:

library("mkin")
-FOCUS_2006_L1 = data.frame(
+
+ +
## Loading required package: minpack.lm
+## Loading required package: rootSolve
+
+ +
FOCUS_2006_L1 = data.frame(
   t = rep(c(0, 1, 2, 3, 5, 7, 14, 21, 30), each = 2),
   parent = c(88.3, 91.4, 85.6, 84.5, 78.9, 77.6, 
              72.0, 71.9, 50.3, 59.4, 47.0, 45.1,
@@ -215,17 +221,17 @@ given in the FOCUS report. 

summary(m.L1.SFO)
-
## mkin version:    0.9.32 
+
## mkin version:    0.9.33 
 ## R version:       3.1.1 
-## Date of fit:     Thu Jul 24 10:32:09 2014 
-## Date of summary: Thu Jul 24 10:32:09 2014 
+## Date of fit:     Mon Aug 25 10:34:14 2014 
+## Date of summary: Mon Aug 25 10:34:14 2014 
 ## 
 ## Equations:
-## [1] d_parent = - k_parent_sink * parent
+## d_parent = - k_parent_sink * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Marq using 14 model solutions performed in 0.081 s
+## Fitted with method Marq using 14 model solutions performed in 0.083 s
 ## 
 ## Weighting: none
 ## 
@@ -318,17 +324,17 @@ is checked.

summary(m.L1.FOMC, data = FALSE)
-
## mkin version:    0.9.32 
+
## mkin version:    0.9.33 
 ## R version:       3.1.1 
-## Date of fit:     Thu Jul 24 10:32:10 2014 
-## Date of summary: Thu Jul 24 10:32:11 2014 
+## Date of fit:     Mon Aug 25 10:34:17 2014 
+## Date of summary: Mon Aug 25 10:34:17 2014 
 ## 
 ## Equations:
-## [1] d_parent = - (alpha/beta) * ((time/beta) + 1)^-1 * parent
+## d_parent = - (alpha/beta) * ((time/beta) + 1)^-1 * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Marq using 53 model solutions performed in 0.321 s
+## Fitted with method Marq using 53 model solutions performed in 0.3 s
 ## 
 ## Weighting: none
 ## 
@@ -412,17 +418,17 @@ FOCUS_2006_L2_mkin <- mkin_wide_to_long(FOCUS_2006_L2)
 summary(m.L2.SFO)
 
-
## mkin version:    0.9.32 
+
## mkin version:    0.9.33 
 ## R version:       3.1.1 
-## Date of fit:     Thu Jul 24 10:32:11 2014 
-## Date of summary: Thu Jul 24 10:32:11 2014 
+## Date of fit:     Mon Aug 25 10:34:17 2014 
+## Date of summary: Mon Aug 25 10:34:17 2014 
 ## 
 ## Equations:
-## [1] d_parent = - k_parent_sink * parent
+## d_parent = - k_parent_sink * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Marq using 29 model solutions performed in 0.196 s
+## Fitted with method Marq using 29 model solutions performed in 0.184 s
 ## 
 ## Weighting: none
 ## 
@@ -522,17 +528,17 @@ mkinresplot(m.L2.FOMC)
 
summary(m.L2.FOMC, data = FALSE)
 
-
## mkin version:    0.9.32 
+
## mkin version:    0.9.33 
 ## R version:       3.1.1 
-## Date of fit:     Thu Jul 24 10:32:11 2014 
-## Date of summary: Thu Jul 24 10:32:11 2014 
+## Date of fit:     Mon Aug 25 10:34:17 2014 
+## Date of summary: Mon Aug 25 10:34:17 2014 
 ## 
 ## Equations:
-## [1] d_parent = - (alpha/beta) * ((time/beta) + 1)^-1 * parent
+## d_parent = - (alpha/beta) * ((time/beta) + 1)^-1 * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Marq using 35 model solutions performed in 0.223 s
+## Fitted with method Marq using 35 model solutions performed in 0.2 s
 ## 
 ## Weighting: none
 ## 
@@ -608,17 +614,19 @@ plot(m.L2.DFOP)
 
summary(m.L2.DFOP, data = FALSE)
 
-
## mkin version:    0.9.32 
+
## mkin version:    0.9.33 
 ## R version:       3.1.1 
-## Date of fit:     Thu Jul 24 10:32:12 2014 
-## Date of summary: Thu Jul 24 10:32:12 2014 
+## Date of fit:     Mon Aug 25 10:34:18 2014 
+## Date of summary: Mon Aug 25 10:34:18 2014 
 ## 
 ## Equations:
-## [1] d_parent = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) * exp(-k2 * time)) / (g * exp(-k1 * time) + (1 - g) * exp(-k2 * time))) * parent
+## d_parent = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) * exp(-k2 * 
+##            time)) / (g * exp(-k1 * time) + (1 - g) * exp(-k2 * 
+##            time))) * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Marq using 43 model solutions performed in 0.271 s
+## Fitted with method Marq using 43 model solutions performed in 0.26 s
 ## 
 ## Weighting: none
 ## 
@@ -695,17 +703,17 @@ plot(m.L3.SFO)
 
summary(m.L3.SFO)
 
-
## mkin version:    0.9.32 
+
## mkin version:    0.9.33 
 ## R version:       3.1.1 
-## Date of fit:     Thu Jul 24 10:32:14 2014 
-## Date of summary: Thu Jul 24 10:32:14 2014 
+## Date of fit:     Mon Aug 25 10:34:18 2014 
+## Date of summary: Mon Aug 25 10:34:18 2014 
 ## 
 ## Equations:
-## [1] d_parent = - k_parent_sink * parent
+## d_parent = - k_parent_sink * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Marq using 44 model solutions performed in 0.251 s
+## Fitted with method Marq using 44 model solutions performed in 0.252 s
 ## 
 ## Weighting: none
 ## 
@@ -781,17 +789,17 @@ plot(m.L3.FOMC)
 
summary(m.L3.FOMC, data = FALSE)
 
-
## mkin version:    0.9.32 
+
## mkin version:    0.9.33 
 ## R version:       3.1.1 
-## Date of fit:     Thu Jul 24 10:32:14 2014 
-## Date of summary: Thu Jul 24 10:32:14 2014 
+## Date of fit:     Mon Aug 25 10:34:19 2014 
+## Date of summary: Mon Aug 25 10:34:19 2014 
 ## 
 ## Equations:
-## [1] d_parent = - (alpha/beta) * ((time/beta) + 1)^-1 * parent
+## d_parent = - (alpha/beta) * ((time/beta) + 1)^-1 * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Marq using 26 model solutions performed in 0.154 s
+## Fitted with method Marq using 26 model solutions performed in 0.148 s
 ## 
 ## Weighting: none
 ## 
@@ -854,17 +862,19 @@ plot(m.L3.DFOP)
 
summary(m.L3.DFOP, data = FALSE)
 
-
## mkin version:    0.9.32 
+
## mkin version:    0.9.33 
 ## R version:       3.1.1 
-## Date of fit:     Thu Jul 24 10:32:14 2014 
-## Date of summary: Thu Jul 24 10:32:14 2014 
+## Date of fit:     Mon Aug 25 10:34:19 2014 
+## Date of summary: Mon Aug 25 10:34:19 2014 
 ## 
 ## Equations:
-## [1] d_parent = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) * exp(-k2 * time)) / (g * exp(-k1 * time) + (1 - g) * exp(-k2 * time))) * parent
+## d_parent = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) * exp(-k2 * 
+##            time)) / (g * exp(-k1 * time) + (1 - g) * exp(-k2 * 
+##            time))) * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Marq using 37 model solutions performed in 0.228 s
+## Fitted with method Marq using 37 model solutions performed in 0.236 s
 ## 
 ## Weighting: none
 ## 
@@ -950,17 +960,17 @@ plot(m.L4.SFO)
 
summary(m.L4.SFO, data = FALSE)
 
-
## mkin version:    0.9.32 
+
## mkin version:    0.9.33 
 ## R version:       3.1.1 
-## Date of fit:     Thu Jul 24 10:32:15 2014 
-## Date of summary: Thu Jul 24 10:32:15 2014 
+## Date of fit:     Mon Aug 25 10:34:19 2014 
+## Date of summary: Mon Aug 25 10:34:19 2014 
 ## 
 ## Equations:
-## [1] d_parent = - k_parent_sink * parent
+## d_parent = - k_parent_sink * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Marq using 20 model solutions performed in 0.141 s
+## Fitted with method Marq using 20 model solutions performed in 0.123 s
 ## 
 ## Weighting: none
 ## 
@@ -1025,17 +1035,17 @@ plot(m.L4.FOMC)
 
summary(m.L4.FOMC, data = FALSE)
 
-
## mkin version:    0.9.32 
+
## mkin version:    0.9.33 
 ## R version:       3.1.1 
-## Date of fit:     Thu Jul 24 10:32:15 2014 
-## Date of summary: Thu Jul 24 10:32:15 2014 
+## Date of fit:     Mon Aug 25 10:34:20 2014 
+## Date of summary: Mon Aug 25 10:34:20 2014 
 ## 
 ## Equations:
-## [1] d_parent = - (alpha/beta) * ((time/beta) + 1)^-1 * parent
+## d_parent = - (alpha/beta) * ((time/beta) + 1)^-1 * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Marq using 48 model solutions performed in 0.296 s
+## Fitted with method Marq using 48 model solutions performed in 0.281 s
 ## 
 ## Weighting: none
 ## 
diff --git a/vignettes/FOCUS_Z.pdf b/vignettes/FOCUS_Z.pdf
index 210ce099..ca6d2506 100644
Binary files a/vignettes/FOCUS_Z.pdf and b/vignettes/FOCUS_Z.pdf differ
-- 
cgit v1.2.3


From ceabddf8bf8bd43f1b57edf112a0fe11c76f5251 Mon Sep 17 00:00:00 2001
From: Johannes Ranke 
Date: Tue, 14 Oct 2014 20:30:15 +0200
Subject: Add a comment about transforming fractions

---
 man/mkinfit.Rd | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

(limited to 'man')

diff --git a/man/mkinfit.Rd b/man/mkinfit.Rd
index 8c36e77e..21af9a05 100644
--- a/man/mkinfit.Rd
+++ b/man/mkinfit.Rd
@@ -9,6 +9,12 @@
   deviation between the kinetic model and the observed data. This model cost is
   then minimised using the Levenberg-Marquardt algorithm \code{\link{nls.lm}}, 
   using the specified initial or fixed parameters and starting values.
+  Per default, parameters in the kinetic models are internally transformed in order 
+  to better satisfy the assumption of a normal distribution of their estimators.
+  If fitting with transformed fractions leads to a suboptimal fit, doing a
+  first run without transforming fractions may help. A final
+  run using the optimised parameters from the previous run as starting values
+  can then be performed with transformed fractions.
   In each step of the optimsation, the kinetic model is solved using the
   function \code{\link{mkinpredict}}. The variance of the residuals for each
   observed variable can optionally be iteratively reweighted until convergence
@@ -138,10 +144,10 @@ mkinfit(mkinmod, observed,
     Boolean specifying if formation fractions constants should be transformed in the
     model specification used in the fitting for better compliance with the
     assumption of normal distribution of the estimator. The default (TRUE) is 
-    to do transformations. The g parameter of the DFOP and HS models are also 
-    transformed, as they can also be seen as compositional data. The
-    transformation used for these transformations is the \code{\link{ilr}}
-    transformation.
+    to do transformations. If TRUE, the g parameter of the DFOP and HS
+    models are also transformed, as they can also be seen as compositional
+    data. The transformation used for these transformations is the
+    \code{\link{ilr}} transformation.
   }
   \item{plot}{
     Should the observed values and the numerical solutions be plotted at each
-- 
cgit v1.2.3


From 65d31e345f9e61e9d05584b24df6a01c6c6ed18d Mon Sep 17 00:00:00 2001
From: Johannes Ranke 
Date: Wed, 15 Oct 2014 01:13:48 +0200
Subject: Switch to using the Port algorithm per default

---
 DESCRIPTION            |   8 +--
 NEWS.md                |   4 ++
 R/mkinfit.R            |   2 +-
 README.md              |   3 +-
 man/mkinfit.Rd         |  24 ++++-----
 vignettes/FOCUS_L.html | 135 ++++++++++++++++++++++++++-----------------------
 vignettes/FOCUS_Z.pdf  | Bin 220198 -> 220189 bytes
 7 files changed, 95 insertions(+), 81 deletions(-)

(limited to 'man')

diff --git a/DESCRIPTION b/DESCRIPTION
index a984391c..d36c35cc 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -3,7 +3,7 @@ Type: Package
 Title: Routines for Fitting Kinetic Models with One or More State
   Variables to Chemical Degradation Data
 Version: 0.9-34
-Date: 2014-10-14
+Date: 2014-10-15
 Authors@R: c(person("Johannes", "Ranke", role = c("aut", "cre", "cph"), 
                     email = "jranke@uni-bremen.de"),
              person("Katrin", "Lindenberger", role = "ctb"),
@@ -12,9 +12,9 @@ Authors@R: c(person("Johannes", "Ranke", role = c("aut", "cre", "cph"),
 Description: Calculation routines based on the FOCUS Kinetics Report (2006).
   Includes a function for conveniently defining differential equation models,
   model solution based on eigenvalues if possible or using numerical solvers
-  and a choice of the optimisation methods made available by the FME package
-  (default is a Levenberg-Marquardt variant).  Please note that no warranty is
-  implied for correctness of results or fitness for a particular purpose.
+  and a choice of the optimisation methods made available by the FME package.
+  Please note that no warranty is implied for correctness of results or fitness
+  for a particular purpose.
 Depends: minpack.lm, rootSolve
 Imports: FME, deSolve
 Suggests: knitr, RUnit
diff --git a/NEWS.md b/NEWS.md
index 4478be6b..60974b14 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,5 +1,9 @@
 # CHANGES in mkin VERSION 0.9-34
 
+## NEW FEATURES
+
+- Switch to using the Port algorithm (using a model/trust region approach) per default. While needing more iterations than the Levenberg-Marquardt algorithm previously used per default, it is less sensitive to starting parameters.
+
 ## MINOR CHANGES
 
 - The formatting of differential equations in the summary was further improved
diff --git a/R/mkinfit.R b/R/mkinfit.R
index a966cea6..6494ea1e 100644
--- a/R/mkinfit.R
+++ b/R/mkinfit.R
@@ -28,7 +28,7 @@ mkinfit <- function(mkinmod, observed,
   fixed_initials = names(mkinmod$diffs)[-1],
   solution_type = "auto",
   method.ode = "lsoda",
-  method.modFit = c("Marq", "Port", "SANN", "Nelder-Mead", "BFSG", "CG", "L-BFGS-B"),
+  method.modFit = c("Port", "Marq", "SANN", "Nelder-Mead", "BFSG", "CG", "L-BFGS-B"),
   maxit.modFit = "auto",
   control.modFit = list(),
   transform_rates = TRUE,
diff --git a/README.md b/README.md
index dfb735f0..fba6f851 100644
--- a/README.md
+++ b/README.md
@@ -93,8 +93,7 @@ documentation or the package vignettes referenced from the
 * Model optimisation with 
   [`mkinfit`](http://kinfit.r-forge.r-project.org/mkin_static/mkinfit.html)
   internally using the `modFit` function from the `FME` package,
-  which uses the least-squares Levenberg-Marquardt algorithm from
-  `minpack.lm` per default.
+  but using the Port routine `nlminb` per default.
 * By default, kinetic rate constants and kinetic formation fractions are
   transformed internally using
   [`transform_odeparms`](http://kinfit.r-forge.r-project.org/mkin_static/transform_odeparms.html)
diff --git a/man/mkinfit.Rd b/man/mkinfit.Rd
index 21af9a05..c40dff83 100644
--- a/man/mkinfit.Rd
+++ b/man/mkinfit.Rd
@@ -7,14 +7,10 @@
   This function uses the Flexible Modelling Environment package
   \code{\link{FME}} to create a function calculating the model cost, i.e. the 
   deviation between the kinetic model and the observed data. This model cost is
-  then minimised using the Levenberg-Marquardt algorithm \code{\link{nls.lm}}, 
+  then minimised using the Port algorithm \code{\link{nlminb}}, 
   using the specified initial or fixed parameters and starting values.
   Per default, parameters in the kinetic models are internally transformed in order 
   to better satisfy the assumption of a normal distribution of their estimators.
-  If fitting with transformed fractions leads to a suboptimal fit, doing a
-  first run without transforming fractions may help. A final
-  run using the optimised parameters from the previous run as starting values
-  can then be performed with transformed fractions.
   In each step of the optimsation, the kinetic model is solved using the
   function \code{\link{mkinpredict}}. The variance of the residuals for each
   observed variable can optionally be iteratively reweighted until convergence
@@ -27,7 +23,7 @@ mkinfit(mkinmod, observed,
   fixed_parms = NULL, fixed_initials = names(mkinmod$diffs)[-1], 
   solution_type = "auto",
   method.ode = "lsoda",
-  method.modFit = c("Marq", "Port", "SANN", "Nelder-Mead", "BFSG", "CG", "L-BFGS-B"),
+  method.modFit = c("Port", "Marq", "SANN", "Nelder-Mead", "BFSG", "CG", "L-BFGS-B"),
   maxit.modFit = "auto",
   control.modFit = list(),
   transform_rates = TRUE,
@@ -107,13 +103,17 @@ mkinfit(mkinmod, observed,
     "lsoda" is performant, but sometimes fails to converge.
   }
   \item{method.modFit}{
-    The optimisation method passed to \code{\link{modFit}}.  The default "Marq"
-    is the Levenberg Marquardt algorithm \code{\link{nls.lm}} from the package
-    \code{minpack.lm} and usually needs the least number of iterations.
+    The optimisation method passed to \code{\link{modFit}}.  
 
-    For more complex problems where local minima occur, the "Port" algorithm is
-    recommended as it is less prone to get trapped in local minima and depends
-    less on starting values for parameters.  However, it needs more iterations.
+    In order to optimally deal with problems where local minima occur, the
+    "Port" algorithm is now used per default as it is less prone to get trapped
+    in local minima and depends less on starting values for parameters than
+    the Levenberg Marquardt variant selected by "Marq".  However, "Port" needs
+    more iterations.
+
+    The former default "Marq" is the Levenberg Marquardt algorithm
+    \code{\link{nls.lm}} from the package \code{minpack.lm} and usually needs
+    the least number of iterations.
 
     The "Pseudo" algorithm is not included because it needs finite parameter bounds
     which are currently not supported.
diff --git a/vignettes/FOCUS_L.html b/vignettes/FOCUS_L.html
index 60c5132a..82bbd2c7 100644
--- a/vignettes/FOCUS_L.html
+++ b/vignettes/FOCUS_L.html
@@ -244,15 +244,15 @@ summary(m.L1.SFO)
 
 
## mkin version:    0.9.34 
 ## R version:       3.1.1 
-## Date of fit:     Tue Oct 14 22:03:33 2014 
-## Date of summary: Tue Oct 14 22:03:33 2014 
+## Date of fit:     Wed Oct 15 00:58:15 2014 
+## Date of summary: Wed Oct 15 00:58:15 2014 
 ## 
 ## Equations:
 ## d_parent = - k_parent_sink * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Marq using 14 model solutions performed in 0.081 s
+## Fitted with method Port using 37 model solutions performed in 0.203 s
 ## 
 ## Weighting: none
 ## 
@@ -272,7 +272,7 @@ summary(m.L1.SFO)
 ## Optimised, transformed parameters:
 ##                   Estimate Std. Error Lower Upper t value Pr(>|t|)
 ## parent_0             92.50     1.3700 89.60 95.40    67.6 4.34e-21
-## log_k_parent_sink    -2.35     0.0406 -2.43 -2.26   -57.9 5.16e-20
+## log_k_parent_sink    -2.35     0.0406 -2.43 -2.26   -57.9 5.15e-20
 ##                     Pr(>t)
 ## parent_0          2.17e-21
 ## log_k_parent_sink 2.58e-20
@@ -341,20 +341,31 @@ The residual plot can be easily obtained by

is checked.

m.L1.FOMC <- mkinfit("FOMC", FOCUS_2006_L1_mkin, quiet=TRUE)
-summary(m.L1.FOMC, data = FALSE)
+
+ +
## Warning: Optimisation by method Port did not converge.
+## Convergence code is 1
+
+ +
summary(m.L1.FOMC, data = FALSE)
 
## mkin version:    0.9.34 
 ## R version:       3.1.1 
-## Date of fit:     Tue Oct 14 22:03:34 2014 
-## Date of summary: Tue Oct 14 22:03:34 2014 
+## Date of fit:     Wed Oct 15 00:58:16 2014 
+## Date of summary: Wed Oct 15 00:58:16 2014 
+## 
+## 
+## Warning: Optimisation by method Port did not converge.
+## Convergence code is 1 
+## 
 ## 
 ## Equations:
 ## d_parent = - (alpha/beta) * ((time/beta) + 1)^-1 * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Marq using 53 model solutions performed in 0.289 s
+## Fitted with method Port using 188 model solutions performed in 1.011 s
 ## 
 ## Weighting: none
 ## 
@@ -375,23 +386,23 @@ summary(m.L1.FOMC, data = FALSE)
 ## 
 ## Optimised, transformed parameters:
 ##           Estimate Std. Error Lower Upper t value Pr(>|t|)   Pr(>t)
-## parent_0      92.5       1.45 89.40  95.6   63.60 1.17e-19 5.85e-20
-## log_alpha     14.9      10.60 -7.75  37.5    1.40 1.82e-01 9.08e-02
-## log_beta      17.2      10.60 -5.38  39.8    1.62 1.25e-01 6.26e-02
+## parent_0      92.5       1.42  89.4  95.5   65.00 8.32e-20 4.16e-20
+## log_alpha     15.4      15.10 -16.7  47.6    1.02 3.22e-01 1.61e-01
+## log_beta      17.8      15.10 -14.4  49.9    1.18 2.57e-01 1.28e-01
 ## 
 ## Parameter correlation:
 ##           parent_0 log_alpha log_beta
-## parent_0     1.000      0.24    0.238
-## log_alpha    0.240      1.00    1.000
-## log_beta     0.238      1.00    1.000
+## parent_0     1.000     0.113    0.111
+## log_alpha    0.113     1.000    1.000
+## log_beta     0.111     1.000    1.000
 ## 
 ## Residual standard error: 3.05 on 15 degrees of freedom
 ## 
 ## Backtransformed parameters:
 ##          Estimate    Lower    Upper
-## parent_0 9.25e+01 8.94e+01 9.56e+01
-## alpha    2.85e+06 4.32e-04 1.88e+16
-## beta     2.98e+07 4.59e-03 1.93e+17
+## parent_0 9.25e+01 8.94e+01 9.55e+01
+## alpha    5.04e+06 5.51e-08 4.62e+20
+## beta     5.28e+07 5.73e-07 4.86e+21
 ## 
 ## Chi2 error levels in percent:
 ##          err.min n.optim df
@@ -440,15 +451,15 @@ summary(m.L2.SFO)
 
 
## mkin version:    0.9.34 
 ## R version:       3.1.1 
-## Date of fit:     Tue Oct 14 22:03:35 2014 
-## Date of summary: Tue Oct 14 22:03:35 2014 
+## Date of fit:     Wed Oct 15 00:58:17 2014 
+## Date of summary: Wed Oct 15 00:58:17 2014 
 ## 
 ## Equations:
 ## d_parent = - k_parent_sink * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Marq using 29 model solutions performed in 0.154 s
+## Fitted with method Port using 41 model solutions performed in 0.22 s
 ## 
 ## Weighting: none
 ## 
@@ -500,10 +511,10 @@ summary(m.L2.SFO)
 ## 
 ## Data:
 ##  time variable observed predicted residual
-##     0   parent     96.1  9.15e+01    4.635
-##     0   parent     91.8  9.15e+01    0.335
-##     1   parent     41.4  4.71e+01   -5.740
-##     1   parent     38.7  4.71e+01   -8.440
+##     0   parent     96.1  9.15e+01    4.634
+##     0   parent     91.8  9.15e+01    0.334
+##     1   parent     41.4  4.71e+01   -5.739
+##     1   parent     38.7  4.71e+01   -8.439
 ##     3   parent     19.3  1.25e+01    6.779
 ##     3   parent     22.3  1.25e+01    9.779
 ##     7   parent      4.6  8.83e-01    3.717
@@ -522,7 +533,7 @@ plot(m.L2.SFO)
 mkinresplot(m.L2.SFO)
 
-

plot of chunk unnamed-chunk-9

+

plot of chunk unnamed-chunk-9

In the FOCUS kinetics report, it is stated that there is no apparent systematic error observed from the residual plot up to the measured DT90 (approximately at @@ -543,22 +554,22 @@ plot(m.L2.FOMC) mkinresplot(m.L2.FOMC)

-

plot of chunk unnamed-chunk-10

+

plot of chunk unnamed-chunk-10

summary(m.L2.FOMC, data = FALSE)
 
## mkin version:    0.9.34 
 ## R version:       3.1.1 
-## Date of fit:     Tue Oct 14 22:03:36 2014 
-## Date of summary: Tue Oct 14 22:03:36 2014 
+## Date of fit:     Wed Oct 15 00:58:17 2014 
+## Date of summary: Wed Oct 15 00:58:17 2014 
 ## 
 ## Equations:
 ## d_parent = - (alpha/beta) * ((time/beta) + 1)^-1 * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Marq using 35 model solutions performed in 0.192 s
+## Fitted with method Port using 81 model solutions performed in 0.438 s
 ## 
 ## Weighting: none
 ## 
@@ -617,7 +628,7 @@ experimental error has to be assumed in order to explain the data.

plot(m.L2.DFOP)
-

plot of chunk unnamed-chunk-11

+

plot of chunk unnamed-chunk-11

Here, the default starting parameters for the DFOP model obviously do not lead to a reasonable solution. Therefore the fit is repeated with different starting @@ -629,15 +640,15 @@ parameters.

plot(m.L2.DFOP)
-

plot of chunk unnamed-chunk-12

+

plot of chunk unnamed-chunk-12

summary(m.L2.DFOP, data = FALSE)
 
## mkin version:    0.9.34 
 ## R version:       3.1.1 
-## Date of fit:     Tue Oct 14 22:03:36 2014 
-## Date of summary: Tue Oct 14 22:03:36 2014 
+## Date of fit:     Wed Oct 15 00:58:21 2014 
+## Date of summary: Wed Oct 15 00:58:21 2014 
 ## 
 ## Equations:
 ## d_parent = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) * exp(-k2 *
@@ -646,7 +657,7 @@ plot(m.L2.DFOP)
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Marq using 43 model solutions performed in 0.24 s
+## Fitted with method Port using 336 model solutions performed in 1.844 s
 ## 
 ## Weighting: none
 ## 
@@ -669,8 +680,8 @@ plot(m.L2.DFOP)
 ## 
 ## Optimised, transformed parameters:
 ##          Estimate Std. Error Lower Upper t value Pr(>|t|) Pr(>t)
-## parent_0   94.000         NA    NA    NA      NA       NA     NA
-## log_k1      6.160         NA    NA    NA      NA       NA     NA
+## parent_0   93.900         NA    NA    NA      NA       NA     NA
+## log_k1      3.120         NA    NA    NA      NA       NA     NA
 ## log_k2     -1.090         NA    NA    NA      NA       NA     NA
 ## g_ilr      -0.282         NA    NA    NA      NA       NA     NA
 ## 
@@ -681,8 +692,8 @@ plot(m.L2.DFOP)
 ## 
 ## Backtransformed parameters:
 ##          Estimate Lower Upper
-## parent_0   94.000    NA    NA
-## k1        476.000    NA    NA
+## parent_0   93.900    NA    NA
+## k1         22.700    NA    NA
 ## k2          0.337    NA    NA
 ## g           0.402    NA    NA
 ## 
@@ -693,7 +704,7 @@ plot(m.L2.DFOP)
 ## 
 ## Estimated disappearance times:
 ##        DT50 DT90 DT50_k1 DT50_k2
-## parent   NA   NA 0.00146    2.06
+## parent   NA   NA  0.0306    2.06
 

Here, the DFOP model is clearly the best-fit model for dataset L2 based on the @@ -718,22 +729,22 @@ FOCUS_2006_L3_mkin <- mkin_wide_to_long(FOCUS_2006_L3) plot(m.L3.SFO)

-

plot of chunk unnamed-chunk-14

+

plot of chunk unnamed-chunk-14

summary(m.L3.SFO)
 
## mkin version:    0.9.34 
 ## R version:       3.1.1 
-## Date of fit:     Tue Oct 14 22:03:37 2014 
-## Date of summary: Tue Oct 14 22:03:37 2014 
+## Date of fit:     Wed Oct 15 00:58:22 2014 
+## Date of summary: Wed Oct 15 00:58:22 2014 
 ## 
 ## Equations:
 ## d_parent = - k_parent_sink * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Marq using 44 model solutions performed in 0.237 s
+## Fitted with method Port using 43 model solutions performed in 0.232 s
 ## 
 ## Weighting: none
 ## 
@@ -785,14 +796,14 @@ plot(m.L3.SFO)
 ## 
 ## Data:
 ##  time variable observed predicted residual
-##     0   parent     97.8     74.87  22.9274
-##     3   parent     60.0     69.41  -9.4065
+##     0   parent     97.8     74.87  22.9281
+##     3   parent     60.0     69.41  -9.4061
 ##     7   parent     51.0     62.73 -11.7340
-##    14   parent     43.0     52.56  -9.5634
-##    30   parent     35.0     35.08  -0.0828
-##    60   parent     22.0     16.44   5.5614
-##    91   parent     15.0      7.51   7.4896
-##   120   parent     12.0      3.61   8.3908
+##    14   parent     43.0     52.56  -9.5638
+##    30   parent     35.0     35.08  -0.0839
+##    60   parent     22.0     16.44   5.5602
+##    91   parent     15.0      7.51   7.4887
+##   120   parent     12.0      3.61   8.3903
 

The chi2 error level of 21% as well as the plot suggest that the model @@ -811,15 +822,15 @@ plot(m.L3.FOMC)

## mkin version:    0.9.34 
 ## R version:       3.1.1 
-## Date of fit:     Tue Oct 14 22:03:37 2014 
-## Date of summary: Tue Oct 14 22:03:37 2014 
+## Date of fit:     Wed Oct 15 00:58:22 2014 
+## Date of summary: Wed Oct 15 00:58:22 2014 
 ## 
 ## Equations:
 ## d_parent = - (alpha/beta) * ((time/beta) + 1)^-1 * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Marq using 26 model solutions performed in 0.139 s
+## Fitted with method Port using 83 model solutions performed in 0.442 s
 ## 
 ## Weighting: none
 ## 
@@ -884,8 +895,8 @@ plot(m.L3.DFOP)
 
 
## mkin version:    0.9.34 
 ## R version:       3.1.1 
-## Date of fit:     Tue Oct 14 22:03:37 2014 
-## Date of summary: Tue Oct 14 22:03:37 2014 
+## Date of fit:     Wed Oct 15 00:58:23 2014 
+## Date of summary: Wed Oct 15 00:58:23 2014 
 ## 
 ## Equations:
 ## d_parent = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) * exp(-k2 *
@@ -894,7 +905,7 @@ plot(m.L3.DFOP)
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Marq using 37 model solutions performed in 0.207 s
+## Fitted with method Port using 137 model solutions performed in 0.778 s
 ## 
 ## Weighting: none
 ## 
@@ -982,15 +993,15 @@ plot(m.L4.SFO)
 
 
## mkin version:    0.9.34 
 ## R version:       3.1.1 
-## Date of fit:     Tue Oct 14 22:03:38 2014 
-## Date of summary: Tue Oct 14 22:03:38 2014 
+## Date of fit:     Wed Oct 15 00:58:24 2014 
+## Date of summary: Wed Oct 15 00:58:24 2014 
 ## 
 ## Equations:
 ## d_parent = - k_parent_sink * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Marq using 20 model solutions performed in 0.106 s
+## Fitted with method Port using 46 model solutions performed in 0.246 s
 ## 
 ## Weighting: none
 ## 
@@ -1057,15 +1068,15 @@ plot(m.L4.FOMC)
 
 
## mkin version:    0.9.34 
 ## R version:       3.1.1 
-## Date of fit:     Tue Oct 14 22:03:38 2014 
-## Date of summary: Tue Oct 14 22:03:38 2014 
+## Date of fit:     Wed Oct 15 00:58:24 2014 
+## Date of summary: Wed Oct 15 00:58:24 2014 
 ## 
 ## Equations:
 ## d_parent = - (alpha/beta) * ((time/beta) + 1)^-1 * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Marq using 48 model solutions performed in 0.26 s
+## Fitted with method Port using 66 model solutions performed in 0.359 s
 ## 
 ## Weighting: none
 ## 
diff --git a/vignettes/FOCUS_Z.pdf b/vignettes/FOCUS_Z.pdf
index b5898b7c..0013cd5e 100644
Binary files a/vignettes/FOCUS_Z.pdf and b/vignettes/FOCUS_Z.pdf differ
-- 
cgit v1.2.3


From 79fdb787e2e79a70e27cf8a3191aa6a0ac2ac2e3 Mon Sep 17 00:00:00 2001
From: Johannes Ranke 
Date: Wed, 29 Oct 2014 13:25:08 +0100
Subject: Correct name of the DFOP model according to FOCUS kinetics

---
 man/DFOP.solution.Rd | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'man')

diff --git a/man/DFOP.solution.Rd b/man/DFOP.solution.Rd
index d30cf7f3..2d8b1735 100644
--- a/man/DFOP.solution.Rd
+++ b/man/DFOP.solution.Rd
@@ -2,7 +2,7 @@
 \Rdversion{1.1}
 \alias{DFOP.solution}
 \title{
-Dual First-Order in Parallel kinetics
+Double First-Order in Parallel kinetics
 }
 \description{
   Function describing decline from a defined starting value using the sum
-- 
cgit v1.2.3