From 9733b1ae5596228c50b3acdfdd78fe96ab1e0533 Mon Sep 17 00:00:00 2001
From: Johannes Ranke 
m.L1.SFO <- mkinfit("SFO", FOCUS_2006_L1_mkin, quiet = TRUE)
 summary(m.L1.SFO)## mkin version:    0.9.44.9000 
+## mkin version:    0.9.45 
 ## R version:       3.3.2 
-## Date of fit:     Thu Dec  8 08:18:47 2016 
-## Date of summary: Thu Dec  8 08:18:47 2016 
+## Date of fit:     Thu Dec  8 09:23:13 2016 
+## Date of summary: Thu Dec  8 09:23:13 2016 
 ## 
 ## Equations:
 ## d_parent/dt = - k_parent_sink * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Port using 37 model solutions performed in 0.084 s
+## Fitted with method Port using 37 model solutions performed in 0.088 s
 ## 
 ## Weighting: none
 ## 
@@ -167,10 +170,10 @@ FOCUS_2006_L1_mkin <- plot(m.L1.FOMC, show_errmin = TRUE, main = "FOCUS L1 - FOMC")
 
 summary(m.L1.FOMC, data = FALSE)
-## mkin version:    0.9.44.9000 
+## mkin version:    0.9.45 
 ## R version:       3.3.2 
-## Date of fit:     Thu Dec  8 08:18:47 2016 
-## Date of summary: Thu Dec  8 08:18:47 2016 
+## Date of fit:     Thu Dec  8 09:23:14 2016 
+## Date of summary: Thu Dec  8 09:23:14 2016 
 ## 
 ## 
 ## Warning: Optimisation by method Port did not converge.
@@ -182,7 +185,7 @@ FOCUS_2006_L1_mkin <-  main = "FOCUS L2 - FOMC")
 
 summary(m.L2.FOMC, data = FALSE)
-## mkin version:    0.9.44.9000 
+## mkin version:    0.9.45 
 ## R version:       3.3.2 
-## Date of fit:     Thu Dec  8 08:18:48 2016 
-## Date of summary: Thu Dec  8 08:18:48 2016 
+## Date of fit:     Thu Dec  8 09:23:14 2016 
+## Date of summary: Thu Dec  8 09:23:14 2016 
 ## 
 ## Equations:
 ## d_parent/dt = - (alpha/beta) * 1/((time/beta) + 1) * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Port using 81 model solutions performed in 0.201 s
+## Fitted with method Port using 81 model solutions performed in 0.185 s
 ## 
 ## Weighting: none
 ## 
@@ -334,10 +337,10 @@ FOCUS_2006_L2_mkin <- main = "FOCUS L2 - DFOP")
 
 summary(m.L2.DFOP, data = FALSE)
-## mkin version:    0.9.44.9000 
+## mkin version:    0.9.45 
 ## R version:       3.3.2 
-## Date of fit:     Thu Dec  8 08:18:49 2016 
-## Date of summary: Thu Dec  8 08:18:49 2016 
+## Date of fit:     Thu Dec  8 09:23:15 2016 
+## Date of summary: Thu Dec  8 09:23:15 2016 
 ## 
 ## Equations:
 ## d_parent/dt = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) *
@@ -346,7 +349,7 @@ FOCUS_2006_L2_mkin <-  summary(mm.L3[["DFOP", 1]])
-## mkin version:    0.9.44.9000 
+## mkin version:    0.9.45 
 ## R version:       3.3.2 
-## Date of fit:     Thu Dec  8 08:18:50 2016 
-## Date of summary: Thu Dec  8 08:18:51 2016 
+## Date of fit:     Thu Dec  8 09:23:17 2016 
+## Date of summary: Thu Dec  8 09:23:17 2016 
 ## 
 ## Equations:
 ## d_parent/dt = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) *
@@ -435,7 +438,7 @@ mm.L3 <-  
 The \(\chi^2\) error level of 3.3% as well as the plot suggest that the SFO model fits very well. The error level at which the \(\chi^2\) test passes is slightly lower for the FOMC model. However, the difference appears negligible.
 summary(mm.L4[["SFO", 1]], data = FALSE)
-## mkin version:    0.9.44.9000 
+## mkin version:    0.9.45 
 ## R version:       3.3.2 
-## Date of fit:     Thu Dec  8 08:18:51 2016 
-## Date of summary: Thu Dec  8 08:18:51 2016 
+## Date of fit:     Thu Dec  8 09:23:17 2016 
+## Date of summary: Thu Dec  8 09:23:17 2016 
 ## 
 ## Equations:
 ## d_parent/dt = - k_parent_sink * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Port using 46 model solutions performed in 0.118 s
+## Fitted with method Port using 46 model solutions performed in 0.106 s
 ## 
 ## Weighting: none
 ## 
@@ -583,17 +586,17 @@ mm.L4 <- summary(mm.L4[["FOMC", 1]], data = FALSE)
-## mkin version:    0.9.44.9000 
+## mkin version:    0.9.45 
 ## R version:       3.3.2 
-## Date of fit:     Thu Dec  8 08:18:51 2016 
-## Date of summary: Thu Dec  8 08:18:51 2016 
+## Date of fit:     Thu Dec  8 09:23:17 2016 
+## Date of summary: Thu Dec  8 09:23:17 2016 
 ## 
 ## Equations:
 ## d_parent/dt = - (alpha/beta) * 1/((time/beta) + 1) * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Port using 66 model solutions performed in 0.151 s
+## Fitted with method Port using 66 model solutions performed in 0.148 s
 ## 
 ## Weighting: none
 ## 
diff --git a/docs/articles/FOCUS_Z.R b/docs/articles/FOCUS_Z.R
index eacefa90..0d5f0940 100644
--- a/docs/articles/FOCUS_Z.R
+++ b/docs/articles/FOCUS_Z.R
@@ -3,20 +3,96 @@ require(knitr)
 opts_chunk$set(engine='R', tidy = FALSE, cache = TRUE)
 options(width=70)
 
-## ----FOCUS_2006_Z_data, echo=TRUE, eval=TRUE------------------------
-require(mkin)
-LOD = 0.5
-FOCUS_2006_Z = data.frame(
-  t = c(0, 0.04, 0.125, 0.29, 0.54, 1, 2, 3, 4, 7, 10, 14, 21,
-        42, 61, 96, 124),
-  Z0 = c(100, 81.7, 70.4, 51.1, 41.2, 6.6, 4.6, 3.9, 4.6, 4.3, 6.8,
-         2.9, 3.5, 5.3, 4.4, 1.2, 0.7),
-  Z1 = c(0, 18.3, 29.6, 46.3, 55.1, 65.7, 39.1, 36, 15.3, 5.6, 1.1,
-         1.6, 0.6, 0.5 * LOD, NA, NA, NA),
-  Z2 = c(0, NA, 0.5 * LOD, 2.6, 3.8, 15.3, 37.2, 31.7, 35.6, 14.5,
-         0.8, 2.1, 1.9, 0.5 * LOD, NA, NA, NA),
-  Z3 = c(0, NA, NA, NA, NA, 0.5 * LOD, 9.2, 13.1, 22.3, 28.4, 32.5,
-         25.2, 17.2, 4.8, 4.5, 2.8, 4.4))
-
-FOCUS_2006_Z_mkin <- mkin_wide_to_long(FOCUS_2006_Z)
+## ----FOCUS_2006_Z_fits_1, echo=TRUE, fig.height=6-------------------
+Z.2a <- mkinmod(Z0 = mkinsub("SFO", "Z1"),
+                Z1 = mkinsub("SFO"))
+m.Z.2a <- mkinfit(Z.2a, FOCUS_2006_Z_mkin, quiet = TRUE)
+plot_sep(m.Z.2a)
+summary(m.Z.2a, data = FALSE)$bpar
+
+## ----FOCUS_2006_Z_fits_2, echo=TRUE, fig.height=6-------------------
+Z.2a.ff <- mkinmod(Z0 = mkinsub("SFO", "Z1"),
+                   Z1 = mkinsub("SFO"),
+                   use_of_ff = "max")
+
+m.Z.2a.ff <- mkinfit(Z.2a.ff, FOCUS_2006_Z_mkin, quiet = TRUE)
+plot_sep(m.Z.2a.ff)
+summary(m.Z.2a.ff, data = FALSE)$bpar
+
+## ----FOCUS_2006_Z_fits_3, echo=TRUE, fig.height=6-------------------
+Z.3 <- mkinmod(Z0 = mkinsub("SFO", "Z1", sink = FALSE),
+               Z1 = mkinsub("SFO"), use_of_ff = "max")
+m.Z.3 <- mkinfit(Z.3, FOCUS_2006_Z_mkin, quiet = TRUE)
+plot_sep(m.Z.3)
+summary(m.Z.3, data = FALSE)$bpar
+
+## ----FOCUS_2006_Z_fits_5, echo=TRUE, fig.height=7-------------------
+Z.5 <- mkinmod(Z0 = mkinsub("SFO", "Z1", sink = FALSE),
+               Z1 = mkinsub("SFO", "Z2", sink = FALSE),
+               Z2 = mkinsub("SFO"), use_of_ff = "max")
+m.Z.5 <- mkinfit(Z.5, FOCUS_2006_Z_mkin, quiet = TRUE)
+plot_sep(m.Z.5)
+
+## ----FOCUS_2006_Z_fits_6, echo=TRUE, fig.height=8-------------------
+Z.FOCUS <- mkinmod(Z0 = mkinsub("SFO", "Z1", sink = FALSE),
+                   Z1 = mkinsub("SFO", "Z2", sink = FALSE),
+                   Z2 = mkinsub("SFO", "Z3"),
+                   Z3 = mkinsub("SFO"),
+                   use_of_ff = "max")
+m.Z.FOCUS <- mkinfit(Z.FOCUS, FOCUS_2006_Z_mkin,
+                     parms.ini = m.Z.5$bparms.ode,
+                     quiet = TRUE)
+plot_sep(m.Z.FOCUS)
+summary(m.Z.FOCUS, data = FALSE)$bpar
+endpoints(m.Z.FOCUS)
+
+## ----FOCUS_2006_Z_fits_7, echo=TRUE, fig.height=8-------------------
+Z.mkin.1 <- mkinmod(Z0 = mkinsub("SFO", "Z1", sink = FALSE),
+                    Z1 = mkinsub("SFO", "Z2", sink = FALSE),
+                    Z2 = mkinsub("SFO", "Z3"),
+                    Z3 = mkinsub("SFORB"))
+m.Z.mkin.1 <- mkinfit(Z.mkin.1, FOCUS_2006_Z_mkin, quiet = TRUE)
+plot_sep(m.Z.mkin.1)
+summary(m.Z.mkin.1, data = FALSE)$cov.unscaled
+
+## ----FOCUS_2006_Z_fits_9, echo=TRUE, fig.height=8-------------------
+Z.mkin.3 <- mkinmod(Z0 = mkinsub("SFORB", "Z1", sink = FALSE),
+                    Z1 = mkinsub("SFO", "Z2", sink = FALSE),
+                    Z2 = mkinsub("SFO"))
+m.Z.mkin.3 <- mkinfit(Z.mkin.3, FOCUS_2006_Z_mkin, quiet = TRUE)
+plot_sep(m.Z.mkin.3)
+
+## ----FOCUS_2006_Z_fits_10, echo=TRUE, fig.height=8------------------
+Z.mkin.4 <- mkinmod(Z0 = mkinsub("SFORB", "Z1", sink = FALSE),
+                    Z1 = mkinsub("SFO", "Z2", sink = FALSE),
+                    Z2 = mkinsub("SFO", "Z3"),
+                    Z3 = mkinsub("SFO"))
+m.Z.mkin.4 <- mkinfit(Z.mkin.4, FOCUS_2006_Z_mkin,
+                      parms.ini = m.Z.mkin.3$bparms.ode,
+                      quiet = TRUE)
+plot_sep(m.Z.mkin.4)
+
+## ----FOCUS_2006_Z_fits_11, echo=TRUE, fig.height=8------------------
+Z.mkin.5 <- mkinmod(Z0 = mkinsub("SFORB", "Z1", sink = FALSE),
+                    Z1 = mkinsub("SFO", "Z2", sink = FALSE),
+                    Z2 = mkinsub("SFO", "Z3"),
+                    Z3 = mkinsub("SFORB"))
+m.Z.mkin.5 <- mkinfit(Z.mkin.5, FOCUS_2006_Z_mkin,
+                      parms.ini = m.Z.mkin.4$bparms.ode[1:4],
+                      quiet = TRUE)
+plot_sep(m.Z.mkin.5)
+
+## ----FOCUS_2006_Z_fits_11a, echo=TRUE-------------------------------
+m.Z.mkin.5a <- mkinfit(Z.mkin.5, FOCUS_2006_Z_mkin,
+                       parms.ini = c(m.Z.mkin.5$bparms.ode[1:7],
+                                     k_Z3_bound_free = 0),
+                       fixed_parms = "k_Z3_bound_free",
+                       quiet = TRUE)
+plot_sep(m.Z.mkin.5a)
+
+## ----FOCUS_2006_Z_fits_11b, echo=TRUE-------------------------------
+mkinparplot(m.Z.mkin.5a)
+
+## ----FOCUS_2006_Z_fits_11b_endpoints, echo=TRUE---------------------
+endpoints(m.Z.mkin.5a)
 
diff --git a/docs/articles/FOCUS_Z.pdf b/docs/articles/FOCUS_Z.pdf
index d8bfd68c..fd313555 100644
Binary files a/docs/articles/FOCUS_Z.pdf and b/docs/articles/FOCUS_Z.pdf differ
diff --git a/docs/articles/compiled_models.html b/docs/articles/compiled_models.html
index 2850a9ae..660af1d1 100644
--- a/docs/articles/compiled_models.html
+++ b/docs/articles/compiled_models.html
@@ -37,6 +37,9 @@
       Performance benefit by using compiled model definitions in mkin
     
   
+
+  News
+ 
       
 ## Unit: milliseconds
 ##                   expr       min        lq      mean    median        uq
-##  deSolve, not compiled 4973.8901 4975.2320 5000.4065 4976.5739 5013.6648
-##       Eigenvalue based  848.4335  859.7111  886.9766  870.9887  906.2481
-##      deSolve, compiled  702.8916  705.1930  706.2696  707.4944  707.9587
+##  deSolve, not compiled 5006.3815 5014.4629 5112.7115 5022.5443 5165.8765
+##       Eigenvalue based  840.3027  874.3549  892.0593  908.4071  917.9376
+##      deSolve, compiled  706.9909  712.8031  723.4380  718.6154  731.6615
 ##        max neval cld
-##  5050.7556     3   c
-##   941.5075     3  b 
-##   708.4229     3 a
+##  5309.2087     3   b
+##   927.4680     3  a 
+##   744.7077     3  a
 autoplot(mb.1)
 
 We see that using the compiled model is by a factor of 7 faster than using the R version with the default ode solver, and it is even faster than the Eigenvalue based solution implemented in R which does not need iterative solution of the ODEs:
 rownames(smb.1) <- smb.1$expr
 smb.1["median"]/smb.1["deSolve, compiled", "median"]
 ##                         median
-## deSolve, not compiled 7.034082
-## Eigenvalue based      1.231089
+## deSolve, not compiled 6.989197
+## Eigenvalue based      1.264108
 ## deSolve, compiled     1.000000
 
 
@@ -131,20 +134,20 @@ smb.1["median"]/smbsmb.2 <- summary(mb.2)
 print(mb.2)
 ## Unit: seconds
-##                   expr       min        lq      mean    median        uq
-##  deSolve, not compiled 10.819486 10.846433 10.863732 10.873381 10.885855
-##      deSolve, compiled  1.300192  1.301168  1.304769  1.302144  1.307058
+##                   expr       min       lq     mean    median        uq
+##  deSolve, not compiled 11.015990 11.17783 11.24827 11.339674 11.364403
+##      deSolve, compiled  1.285264  1.29794  1.32988  1.310616  1.352189
 ##        max neval cld
-##  10.898330     3   b
-##   1.311972     3  a
+##  11.389132     3   b
+##   1.393762     3  a
 smb.2["median"]/smb.2["deSolve, compiled", "median"]
 ##   median
 ## 1     NA
 ## 2     NA
 autoplot(mb.2)
 
-Here we get a performance benefit of a factor of 8.4 using the version of the differential equation model compiled from C code!
-This vignette was built with mkin 0.9.44.9000 on
+Here we get a performance benefit of a factor of 8.7 using the version of the differential equation model compiled from C code!
+This vignette was built with mkin 0.9.45 on
 ## R version 3.3.2 (2016-10-31)
 ## Platform: x86_64-pc-linux-gnu (64-bit)
 ## Running under: Debian GNU/Linux 8 (jessie)
diff --git a/docs/articles/compiled_models_files/figure-html/benchmark_FOMC_SFO-1.png b/docs/articles/compiled_models_files/figure-html/benchmark_FOMC_SFO-1.png
index c30550c9..53ff97f7 100644
Binary files a/docs/articles/compiled_models_files/figure-html/benchmark_FOMC_SFO-1.png and b/docs/articles/compiled_models_files/figure-html/benchmark_FOMC_SFO-1.png differ
diff --git a/docs/articles/compiled_models_files/figure-html/benchmark_SFO_SFO-1.png b/docs/articles/compiled_models_files/figure-html/benchmark_SFO_SFO-1.png
index 5f95613a..d3a507bd 100644
Binary files a/docs/articles/compiled_models_files/figure-html/benchmark_SFO_SFO-1.png and b/docs/articles/compiled_models_files/figure-html/benchmark_SFO_SFO-1.png differ
diff --git a/docs/articles/figure/FOCUS_2006_Z_fits_1-1.pdf b/docs/articles/figure/FOCUS_2006_Z_fits_1-1.pdf
deleted file mode 100644
index 6f5cbd2a..00000000
Binary files a/docs/articles/figure/FOCUS_2006_Z_fits_1-1.pdf and /dev/null differ
diff --git a/docs/articles/figure/FOCUS_2006_Z_fits_10-1.pdf b/docs/articles/figure/FOCUS_2006_Z_fits_10-1.pdf
deleted file mode 100644
index a2d3e91e..00000000
Binary files a/docs/articles/figure/FOCUS_2006_Z_fits_10-1.pdf and /dev/null differ
diff --git a/docs/articles/figure/FOCUS_2006_Z_fits_11-1.pdf b/docs/articles/figure/FOCUS_2006_Z_fits_11-1.pdf
deleted file mode 100644
index 9a88c84b..00000000
Binary files a/docs/articles/figure/FOCUS_2006_Z_fits_11-1.pdf and /dev/null differ
diff --git a/docs/articles/figure/FOCUS_2006_Z_fits_11a-1.pdf b/docs/articles/figure/FOCUS_2006_Z_fits_11a-1.pdf
deleted file mode 100644
index eda22e28..00000000
Binary files a/docs/articles/figure/FOCUS_2006_Z_fits_11a-1.pdf and /dev/null differ
diff --git a/docs/articles/figure/FOCUS_2006_Z_fits_11b-1.pdf b/docs/articles/figure/FOCUS_2006_Z_fits_11b-1.pdf
deleted file mode 100644
index be61a972..00000000
Binary files a/docs/articles/figure/FOCUS_2006_Z_fits_11b-1.pdf and /dev/null differ
diff --git a/docs/articles/figure/FOCUS_2006_Z_fits_2-1.pdf b/docs/articles/figure/FOCUS_2006_Z_fits_2-1.pdf
deleted file mode 100644
index 25616330..00000000
Binary files a/docs/articles/figure/FOCUS_2006_Z_fits_2-1.pdf and /dev/null differ
diff --git a/docs/articles/figure/FOCUS_2006_Z_fits_3-1.pdf b/docs/articles/figure/FOCUS_2006_Z_fits_3-1.pdf
deleted file mode 100644
index ccb8e23a..00000000
Binary files a/docs/articles/figure/FOCUS_2006_Z_fits_3-1.pdf and /dev/null differ
diff --git a/docs/articles/figure/FOCUS_2006_Z_fits_5-1.pdf b/docs/articles/figure/FOCUS_2006_Z_fits_5-1.pdf
deleted file mode 100644
index 9d0949cd..00000000
Binary files a/docs/articles/figure/FOCUS_2006_Z_fits_5-1.pdf and /dev/null differ
diff --git a/docs/articles/figure/FOCUS_2006_Z_fits_6-1.pdf b/docs/articles/figure/FOCUS_2006_Z_fits_6-1.pdf
deleted file mode 100644
index 020a1ccd..00000000
Binary files a/docs/articles/figure/FOCUS_2006_Z_fits_6-1.pdf and /dev/null differ
diff --git a/docs/articles/figure/FOCUS_2006_Z_fits_7-1.pdf b/docs/articles/figure/FOCUS_2006_Z_fits_7-1.pdf
deleted file mode 100644
index a34809c8..00000000
Binary files a/docs/articles/figure/FOCUS_2006_Z_fits_7-1.pdf and /dev/null differ
diff --git a/docs/articles/figure/FOCUS_2006_Z_fits_9-1.pdf b/docs/articles/figure/FOCUS_2006_Z_fits_9-1.pdf
deleted file mode 100644
index 26c4ff9d..00000000
Binary files a/docs/articles/figure/FOCUS_2006_Z_fits_9-1.pdf and /dev/null differ
diff --git a/docs/articles/index.html b/docs/articles/index.html
index 20792ba1..7344840b 100644
--- a/docs/articles/index.html
+++ b/docs/articles/index.html
@@ -71,6 +71,9 @@
       Performance benefit by using compiled model definitions in mkin
     
   
+
+
+  News
  
       
       
diff --git a/docs/articles/mkin.R b/docs/articles/mkin.R
deleted file mode 100644
index fc39bfda..00000000
--- a/docs/articles/mkin.R
+++ /dev/null
@@ -1,4 +0,0 @@
-## ---- include = FALSE----------------------------------------------------
-require(knitr)
-opts_chunk$set(engine='R', tidy=FALSE)
-
diff --git a/docs/articles/mkin.html b/docs/articles/mkin.html
index c70f8ddf..4159c427 100644
--- a/docs/articles/mkin.html
+++ b/docs/articles/mkin.html
@@ -37,6 +37,9 @@
       Performance benefit by using compiled model definitions in mkin
     
   
+
+  News
+