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 --- vignettes/FOCUS_L.Rmd | 81 ++++++------ vignettes/FOCUS_L.html | 328 ++++++++++++++++++++++++------------------------- vignettes/mkin.pdf | Bin 160326 -> 160326 bytes 3 files changed, 200 insertions(+), 209 deletions(-) (limited to 'vignettes') 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.1