From c9e245f88fc8c6b7776353e3b2fc2dd7451bd97b Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Mon, 20 Jul 2015 09:22:03 +0200 Subject: Avoid error message for SFORB in endpoints, updates --- .Rbuildignore | 1 + DESCRIPTION | 2 +- GNUmakefile | 4 +++ NAMESPACE | 3 +- R/endpoints.R | 21 ++++++++---- build.log | 7 +--- check.log | 20 ++--------- test.log | 1 - vignettes/FOCUS_D.html | 12 +++---- vignettes/FOCUS_L.html | 88 ++++++++++++++++++++++++------------------------- vignettes/FOCUS_Z.pdf | Bin 219834 -> 226064 bytes vignettes/mkin.pdf | Bin 160260 -> 160258 bytes 12 files changed, 76 insertions(+), 83 deletions(-) diff --git a/.Rbuildignore b/.Rbuildignore index 2e8532cf..6784306f 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -17,6 +17,7 @@ vignettes/*.synctex.gz ^vignettes/FOCUS_Z.tex$ ^vignettes/*_cache$ ^vignettes/*_files$ +^vignettes/figure ^Rplots.pdf$ test.log check.log diff --git a/DESCRIPTION b/DESCRIPTION index 85846fa0..ef57096a 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-40 -Date: 2015-06-30 +Date: 2015-07-20 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 7cd9ed21..1766bc11 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -91,6 +91,10 @@ sd: install @echo "\n library(staticdocs); build_site(site_path = '$(SDDIR)')\n" $(RBIN)/R +sd2: install + rm -rf $(SDDIR)/* + xvfb-run $(RBIN)/R -e "library(staticdocs); build_site(site_path = '$(SDDIR)')" + r-forge: sd cd $(SDDIR) && svn add --force . git archive master > $(HOME)/mkin.tar;\ diff --git a/NAMESPACE b/NAMESPACE index d232331a..cac85362 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -10,9 +10,10 @@ import( stats, graphics, FME, - deSolve, minpack.lm, rootSolve, inline, parallel ) +importFrom(deSolve, ode) +importFrom(methods, signature) diff --git a/R/endpoints.R b/R/endpoints.R index a930acb7..95966cf7 100644 --- a/R/endpoints.R +++ b/R/endpoints.R @@ -84,8 +84,11 @@ endpoints <- function(fit) { DT50_k2 = log(2)/k2 DT90_k1 = log(10)/k1 DT90_k2 = log(10)/k2 - DT50 <- try(exp(optimize(f, c(log(DT50_k1), log(DT50_k2)), x=50)$minimum)) - DT90 <- try(exp(optimize(f, c(log(DT90_k1), log(DT90_k2)), x=90)$minimum)) + + DT50 <- try(exp(optimize(f, c(log(DT50_k1), log(DT50_k2)), x=50)$minimum), + silent = TRUE) + DT90 <- try(exp(optimize(f, c(log(DT90_k1), log(DT90_k2)), x=90)$minimum), + silent = TRUE) if (inherits(DT50, "try-error")) DT50 = NA if (inherits(DT90, "try-error")) DT90 = NA @@ -127,18 +130,22 @@ endpoints <- function(fit) { DT90_b1 = log(10)/b1 DT90_b2 = log(10)/b2 - SFORB_fraction = function(t) { ((k_12 + k_21 - b1)/(b2 - b1)) * exp(-b1 * t) + ((k_12 + k_21 - b2)/(b1 - b2)) * exp(-b2 * t) } + f_50 <- function(log_t) (SFORB_fraction(exp(log_t)) - 0.5)^2 - DT50 <- try(exp(optimize(f_50, c(log(DT50_b1), log(DT50_b2)))$minimum)) + log_DT50 <- try(optimize(f_50, c(log(DT50_b1), log(DT50_b2)))$minimum, + silent = TRUE) f_90 <- function(log_t) (SFORB_fraction(exp(log_t)) - 0.1)^2 - DT90 <- try(exp(optimize(f_90, c(log(DT90_b1), log(DT90_b2)))$minimum)) + log_DT90 <- try(optimize(f_90, c(log(DT90_b1), log(DT90_b2)))$minimum, + silent = TRUE) - if (inherits(DT50, "try-error")) DT50 = NA - if (inherits(DT90, "try-error")) DT90 = NA + DT50 = if (inherits(log_DT50, "try-error")) NA + else exp(log_DT50) + DT90 = if (inherits(log_DT90, "try-error")) NA + else exp(log_DT90) for (k_out_name in k_out_names) { diff --git a/build.log b/build.log index 9968573e..c3b0aa75 100644 --- a/build.log +++ b/build.log @@ -2,9 +2,4 @@ * preparing ‘mkin’: * checking DESCRIPTION meta-information ... OK * installing the package to build vignettes -* creating vignettes ... OK -* checking for LF line-endings in source and make files -* checking for empty or unneeded directories -* looking to see if a ‘data/datalist’ file should be added -* building ‘mkin_0.9-40.tar.gz’ - +* creating vignettes ... \ No newline at end of file diff --git a/check.log b/check.log index 385ee730..6b81cb80 100644 --- a/check.log +++ b/check.log @@ -7,10 +7,8 @@ * checking extension type ... Package * this is package ‘mkin’ version ‘0.9-40’ * package encoding: UTF-8 -* checking CRAN incoming feasibility ... NOTE +* checking CRAN incoming feasibility ... Note_to_CRAN_maintainers Maintainer: ‘Johannes Ranke ’ - -Days since last update: 4 * checking package namespace information ... OK * checking package dependencies ... OK * checking if this is a source package ... OK @@ -56,10 +54,7 @@ Days since last update: 4 * checking data for ASCII and uncompressed saves ... OK * checking sizes of PDF files under ‘inst/doc’ ... OK * checking installed files from ‘inst/doc’ ... OK -* checking files in ‘vignettes’ ... NOTE -The following files look like leftovers/mistakes: - ‘FOCUS_Z.bbl’, ‘FOCUS_Z.blg’ -Please remove them from your package. +* checking files in ‘vignettes’ ... OK * checking examples ... OK * checking for unstated dependencies in ‘tests’ ... OK * checking tests ... SKIPPED @@ -71,13 +66,4 @@ Please remove them from your package. ‘FOCUS_Z.Rnw’ using ‘UTF-8’ ... OK ‘mkin.Rnw’ using ‘UTF-8’ ... OK OK -* checking re-building of vignette outputs ... OK -* checking PDF version of manual ... OK -* DONE - -Status: 2 NOTEs -See - ‘/home/jranke/git/mkin/mkin.Rcheck/00check.log’ -for details. - - +* checking re-building of vignette outputs ... \ No newline at end of file diff --git a/test.log b/test.log index dfabfdcd..1449fdb5 100644 --- a/test.log +++ b/test.log @@ -11,4 +11,3 @@ Fitting of parent only models : ..................... Complex test case from Schaefer et al. (2007) Piacenza paper : .. Results for synthetic data established in expertise for UBA (Ranke 2014) : .... -Way to go! diff --git a/vignettes/FOCUS_D.html b/vignettes/FOCUS_D.html index b8264c22..f5b8f22a 100644 --- a/vignettes/FOCUS_D.html +++ b/vignettes/FOCUS_D.html @@ -10,7 +10,7 @@ - + Example evaluation of FOCUS Example Dataset D @@ -64,7 +64,7 @@ img { @@ -135,10 +135,10 @@ print(FOCUS_2006_D)

A comprehensive report of the results is obtained using the summary method for mkinfit objects.

summary(fit)
-
## mkin version:    0.9.39 
+
## mkin version:    0.9.40 
 ## R version:       3.2.1 
-## Date of fit:     Fri Jun 26 16:35:59 2015 
-## Date of summary: Fri Jun 26 16:35:59 2015 
+## Date of fit:     Sat Jul 18 16:50:58 2015 
+## Date of summary: Sat Jul 18 16:50:59 2015 
 ## 
 ## Equations:
 ## d_parent = - k_parent_sink * parent - k_parent_m1 * parent
@@ -146,7 +146,7 @@ print(FOCUS_2006_D)
## ## Model predictions using solution type deSolve ## -## Fitted with method Port using 153 model solutions performed in 0.71 s +## Fitted with method Port using 153 model solutions performed in 0.604 s ## ## Weighting: none ## diff --git a/vignettes/FOCUS_L.html b/vignettes/FOCUS_L.html index d1a10e6a..963dff0c 100644 --- a/vignettes/FOCUS_L.html +++ b/vignettes/FOCUS_L.html @@ -10,7 +10,7 @@ - + Example evaluation of FOCUS Laboratory Data L1 to L3 @@ -65,7 +65,7 @@ img {
@@ -91,17 +91,17 @@ FOCUS_2006_L1_mkin <- mkin_wide_to_long(FOCUS_2006_L1)

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.

m.L1.SFO <- mkinfit("SFO", FOCUS_2006_L1_mkin, quiet=TRUE)
 summary(m.L1.SFO)
-
## mkin version:    0.9.39 
+
## mkin version:    0.9.40 
 ## R version:       3.2.1 
-## Date of fit:     Fri Jun 26 16:36:00 2015 
-## Date of summary: Fri Jun 26 16:36:00 2015 
+## Date of fit:     Sat Jul 18 16:50:59 2015 
+## Date of summary: Sat Jul 18 16:50:59 2015 
 ## 
 ## Equations:
 ## d_parent = - k_parent_sink * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Port using 37 model solutions performed in 0.095 s
+## Fitted with method Port using 37 model solutions performed in 0.083 s
 ## 
 ## Weighting: none
 ## 
@@ -181,10 +181,10 @@ summary(m.L1.SFO)
## Warning in mkinfit("FOMC", FOCUS_2006_L1_mkin, quiet = TRUE): Optimisation by method Port did not converge.
 ## Convergence code is 1
summary(m.L1.FOMC, data = FALSE)
-
## mkin version:    0.9.39 
+
## mkin version:    0.9.40 
 ## R version:       3.2.1 
-## Date of fit:     Fri Jun 26 16:36:00 2015 
-## Date of summary: Fri Jun 26 16:36:00 2015 
+## Date of fit:     Sat Jul 18 16:51:00 2015 
+## Date of summary: Sat Jul 18 16:51:00 2015 
 ## 
 ## 
 ## Warning: Optimisation by method Port did not converge.
@@ -196,7 +196,7 @@ summary(m.L1.SFO)
## ## Model predictions using solution type analytical ## -## Fitted with method Port using 188 model solutions performed in 0.48 s +## Fitted with method Port using 188 model solutions performed in 0.414 s ## ## Weighting: none ## @@ -261,17 +261,17 @@ FOCUS_2006_L2_mkin <- mkin_wide_to_long(FOCUS_2006_L2)

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

m.L2.SFO <- mkinfit("SFO", FOCUS_2006_L2_mkin, quiet=TRUE)
 summary(m.L2.SFO)
-
## mkin version:    0.9.39 
+
## mkin version:    0.9.40 
 ## R version:       3.2.1 
-## Date of fit:     Fri Jun 26 16:36:01 2015 
-## Date of summary: Fri Jun 26 16:36:01 2015 
+## Date of fit:     Sat Jul 18 16:51:00 2015 
+## Date of summary: Sat Jul 18 16:51:00 2015 
 ## 
 ## Equations:
 ## d_parent = - k_parent_sink * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Port using 41 model solutions performed in 0.103 s
+## Fitted with method Port using 41 model solutions performed in 0.089 s
 ## 
 ## Weighting: none
 ## 
@@ -349,17 +349,17 @@ plot(m.L2.FOMC)
 mkinresplot(m.L2.FOMC)

summary(m.L2.FOMC, data = FALSE)
-
## mkin version:    0.9.39 
+
## mkin version:    0.9.40 
 ## R version:       3.2.1 
-## Date of fit:     Fri Jun 26 16:36:01 2015 
-## Date of summary: Fri Jun 26 16:36:01 2015 
+## Date of fit:     Sat Jul 18 16:51:01 2015 
+## Date of summary: Sat Jul 18 16:51:01 2015 
 ## 
 ## Equations:
 ## d_parent = - (alpha/beta) * 1/((time/beta) + 1) * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Port using 81 model solutions performed in 0.212 s
+## Fitted with method Port using 81 model solutions performed in 0.177 s
 ## 
 ## Weighting: none
 ## 
@@ -421,10 +421,10 @@ plot(m.L2.DFOP)
plot(m.L2.DFOP)

summary(m.L2.DFOP, data = FALSE)
-
## mkin version:    0.9.39 
+
## mkin version:    0.9.40 
 ## R version:       3.2.1 
-## Date of fit:     Fri Jun 26 16:36:03 2015 
-## Date of summary: Fri Jun 26 16:36:03 2015 
+## Date of fit:     Sat Jul 18 16:51:03 2015 
+## Date of summary: Sat Jul 18 16:51:03 2015 
 ## 
 ## Equations:
 ## d_parent = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) * exp(-k2 *
@@ -433,7 +433,7 @@ plot(m.L2.DFOP)
## ## Model predictions using solution type analytical ## -## Fitted with method Port using 336 model solutions performed in 0.862 s +## Fitted with method Port using 336 model solutions performed in 0.791 s ## ## Weighting: none ## @@ -482,8 +482,8 @@ plot(m.L2.DFOP)
## parent 2.53 4 2 ## ## Estimated disappearance times: -## DT50 DT90 DT50_k1 DT50_k2 -## parent NA NA 0.03058 2.058
+## DT50 DT90 DT50_k1 DT50_k2 +## parent 0.5335 5.311 0.03058 2.058

Here, the DFOP model is clearly the best-fit model for dataset L2 based on the chi^2 error level criterion. However, the failure to calculate the covariance matrix indicates that the parameter estimates correlate excessively. Therefore, the FOMC model may be preferred for this dataset.

@@ -498,17 +498,17 @@ FOCUS_2006_L3_mkin <- mkin_wide_to_long(FOCUS_2006_L3) plot(m.L3.SFO)

summary(m.L3.SFO)
-
## mkin version:    0.9.39 
+
## mkin version:    0.9.40 
 ## R version:       3.2.1 
-## Date of fit:     Fri Jun 26 16:36:04 2015 
-## Date of summary: Fri Jun 26 16:36:04 2015 
+## Date of fit:     Sat Jul 18 16:51:03 2015 
+## Date of summary: Sat Jul 18 16:51:03 2015 
 ## 
 ## Equations:
 ## d_parent = - k_parent_sink * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Port using 43 model solutions performed in 0.103 s
+## Fitted with method Port using 43 model solutions performed in 0.093 s
 ## 
 ## Weighting: none
 ## 
@@ -574,17 +574,17 @@ plot(m.L3.SFO)
plot(m.L3.FOMC)

summary(m.L3.FOMC, data = FALSE)
-
## mkin version:    0.9.39 
+
## mkin version:    0.9.40 
 ## R version:       3.2.1 
-## Date of fit:     Fri Jun 26 16:36:04 2015 
-## Date of summary: Fri Jun 26 16:36:04 2015 
+## Date of fit:     Sat Jul 18 16:51:03 2015 
+## Date of summary: Sat Jul 18 16:51:03 2015 
 ## 
 ## Equations:
 ## d_parent = - (alpha/beta) * 1/((time/beta) + 1) * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Port using 83 model solutions performed in 0.205 s
+## Fitted with method Port using 83 model solutions performed in 0.173 s
 ## 
 ## Weighting: none
 ## 
@@ -640,10 +640,10 @@ plot(m.L3.FOMC)
plot(m.L3.DFOP)

summary(m.L3.DFOP, data = FALSE)
-
## mkin version:    0.9.39 
+
## mkin version:    0.9.40 
 ## R version:       3.2.1 
-## Date of fit:     Fri Jun 26 16:36:05 2015 
-## Date of summary: Fri Jun 26 16:36:05 2015 
+## Date of fit:     Sat Jul 18 16:51:04 2015 
+## Date of summary: Sat Jul 18 16:51:04 2015 
 ## 
 ## Equations:
 ## d_parent = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) * exp(-k2 *
@@ -652,7 +652,7 @@ plot(m.L3.DFOP)
## ## Model predictions using solution type analytical ## -## Fitted with method Port using 137 model solutions performed in 0.361 s +## Fitted with method Port using 137 model solutions performed in 0.303 s ## ## Weighting: none ## @@ -722,17 +722,17 @@ FOCUS_2006_L4_mkin <- mkin_wide_to_long(FOCUS_2006_L4)
plot(m.L4.SFO)

summary(m.L4.SFO, data = FALSE)
-
## mkin version:    0.9.39 
+
## mkin version:    0.9.40 
 ## R version:       3.2.1 
-## Date of fit:     Fri Jun 26 16:36:05 2015 
-## Date of summary: Fri Jun 26 16:36:05 2015 
+## Date of fit:     Sat Jul 18 16:51:04 2015 
+## Date of summary: Sat Jul 18 16:51:04 2015 
 ## 
 ## Equations:
 ## d_parent = - k_parent_sink * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Port using 46 model solutions performed in 0.11 s
+## Fitted with method Port using 46 model solutions performed in 0.104 s
 ## 
 ## Weighting: none
 ## 
@@ -787,17 +787,17 @@ plot(m.L4.SFO)
plot(m.L4.FOMC)

summary(m.L4.FOMC, data = FALSE)
-
## mkin version:    0.9.39 
+
## mkin version:    0.9.40 
 ## R version:       3.2.1 
-## Date of fit:     Fri Jun 26 16:36:05 2015 
-## Date of summary: Fri Jun 26 16:36:05 2015 
+## Date of fit:     Sat Jul 18 16:51:04 2015 
+## Date of summary: Sat Jul 18 16:51:04 2015 
 ## 
 ## Equations:
 ## d_parent = - (alpha/beta) * 1/((time/beta) + 1) * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Port using 66 model solutions performed in 0.174 s
+## Fitted with method Port using 66 model solutions performed in 0.148 s
 ## 
 ## Weighting: none
 ## 
diff --git a/vignettes/FOCUS_Z.pdf b/vignettes/FOCUS_Z.pdf
index 3fb4f69c..3745234a 100644
Binary files a/vignettes/FOCUS_Z.pdf and b/vignettes/FOCUS_Z.pdf differ
diff --git a/vignettes/mkin.pdf b/vignettes/mkin.pdf
index 4eb5dada..d5183527 100644
Binary files a/vignettes/mkin.pdf and b/vignettes/mkin.pdf differ
-- 
cgit v1.2.1