From 43af185533b11327368148a44e9295ea3eb3abb1 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Thu, 23 Nov 2023 06:17:28 +0100 Subject: Bump version, fix test from last commit, check and test --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'DESCRIPTION') diff --git a/DESCRIPTION b/DESCRIPTION index 88f4f33c..8a97fe34 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: mkin Type: Package Title: Kinetic Evaluation of Chemical Degradation Data -Version: 1.2.6 -Date: 2023-10-13 +Version: 1.2.7 +Date: 2023-11-23 Authors@R: c( person("Johannes", "Ranke", role = c("aut", "cre", "cph"), email = "johannes.ranke@jrwb.de", -- cgit v1.2.3 From a08726719217135455e571e00e4eb165712d6221 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Sat, 25 Nov 2023 07:57:14 +0100 Subject: Bump the date to trigger build on Travis They refilled my credits, thanks for that! --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'DESCRIPTION') diff --git a/DESCRIPTION b/DESCRIPTION index 8a97fe34..ae0fdc2c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,7 +2,7 @@ Package: mkin Type: Package Title: Kinetic Evaluation of Chemical Degradation Data Version: 1.2.7 -Date: 2023-11-23 +Date: 2023-11-25 Authors@R: c( person("Johannes", "Ranke", role = c("aut", "cre", "cph"), email = "johannes.ranke@jrwb.de", -- cgit v1.2.3 From b07f9fcb7468ac1b5fab0924328fba36ae943be5 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Sun, 26 Nov 2023 20:38:30 +0100 Subject: Deal with 'saem' fits failing when updating an 'mhmkin' object --- DESCRIPTION | 4 ++-- NEWS.md | 4 ++++ R/mhmkin.R | 28 +++++++++++++++++++++------- R/status.R | 18 +++++++++++------- log/build.log | 2 +- log/check.log | 6 +++--- log/test.log | 24 ++++++++++++------------ man/check_failed.Rd | 14 ++++++++++++++ 8 files changed, 68 insertions(+), 32 deletions(-) create mode 100644 man/check_failed.Rd (limited to 'DESCRIPTION') diff --git a/DESCRIPTION b/DESCRIPTION index ae0fdc2c..0d924faf 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: mkin Type: Package Title: Kinetic Evaluation of Chemical Degradation Data -Version: 1.2.7 -Date: 2023-11-25 +Version: 1.2.8 +Date: 2023-11-26 Authors@R: c( person("Johannes", "Ranke", role = c("aut", "cre", "cph"), email = "johannes.ranke@jrwb.de", diff --git a/NEWS.md b/NEWS.md index 100f8b6c..f7c38915 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# mkin 1.2.8 + +- 'R/{mhmkin,status}.R': Deal with 'saem' fits that fail when updating an 'mhmkin' object + # mkin 1.2.7 - 'R/illparms.R': Fix a bug that prevented an ill-defined random effect to be found if there was only one random effect in the model. Also add a test for this. diff --git a/R/mhmkin.R b/R/mhmkin.R index 6265a59e..14a7ac29 100644 --- a/R/mhmkin.R +++ b/R/mhmkin.R @@ -219,11 +219,22 @@ print.mhmkin <- function(x, ...) { print(status(x)) } +#' Check if fit within an mhmkin object failed +#' @param x The object to be checked +check_failed <- function(x) { + if (inherits(x, "try-error")) { + return(TRUE) + } else { + if (inherits(x$so, "try-error")) { + return(TRUE) + } else { + return(FALSE) + } + } +} + #' @export AIC.mhmkin <- function(object, ..., k = 2) { - if (inherits(object[[1]], "saem.mmkin")) { - check_failed <- function(x) if (inherits(x$so, "try-error")) TRUE else FALSE - } res <- sapply(object, function(x) { if (check_failed(x)) return(NA) else return(AIC(x$so, k = k)) @@ -235,9 +246,6 @@ AIC.mhmkin <- function(object, ..., k = 2) { #' @export BIC.mhmkin <- function(object, ...) { - if (inherits(object[[1]], "saem.mmkin")) { - check_failed <- function(x) if (inherits(x$so, "try-error")) TRUE else FALSE - } res <- sapply(object, function(x) { if (check_failed(x)) return(NA) else return(BIC(x$so)) @@ -280,7 +288,13 @@ anova.mhmkin <- function(object, ..., if (identical(model.names, "auto")) { model.names <- outer(rownames(object), colnames(object), paste) } - rlang::inject(anova(!!!(object), method = method, test = test, + failed_index <- which(sapply(object, check_failed), arr.ind = TRUE) + if (length(failed_index > 0)) { + rlang::inject(anova(!!!(object[-failed_index]), method = method, test = test, + model.names = model.names[-failed_index])) + } else { + rlang::inject(anova(!!!(object), method = method, test = test, model.names = model.names)) + } } diff --git a/R/status.R b/R/status.R index 8bcd3a16..f9d79e7d 100644 --- a/R/status.R +++ b/R/status.R @@ -74,15 +74,19 @@ print.status.mmkin <- function(x, ...) { status.mhmkin <- function(object, ...) { if (inherits(object[[1]], "saem.mmkin")) { test_func <- function(fit) { - if (inherits(fit$so, "try-error")) { - return("E") + if (inherits(fit, "try-error")) { + return("E") } else { - if (!is.null(fit$FIM_failed)) { - return_values <- c("fixed effects" = "Fth", - "random effects and error model parameters" = "FO") - return(paste(return_values[fit$FIM_failed], collapse = ", ")) + if (inherits(fit$so, "try-error")) { + return("E") } else { - return("OK") + if (!is.null(fit$FIM_failed)) { + return_values <- c("fixed effects" = "Fth", + "random effects and error model parameters" = "FO") + return(paste(return_values[fit$FIM_failed], collapse = ", ")) + } else { + return("OK") + } } } } diff --git a/log/build.log b/log/build.log index b4269860..c2001830 100644 --- a/log/build.log +++ b/log/build.log @@ -7,5 +7,5 @@ * checking for empty or unneeded directories Removed empty directory ‘mkin/inst/rmarkdown/templates/hierarchical_kinetics_parent’ Removed empty directory ‘mkin/vignettes/web_only’ -* building ‘mkin_1.2.7.tar.gz’ +* building ‘mkin_1.2.8.tar.gz’ diff --git a/log/check.log b/log/check.log index 26fdc5a0..5e777a87 100644 --- a/log/check.log +++ b/log/check.log @@ -9,9 +9,9 @@ * using options ‘--no-tests --as-cran’ * checking for file ‘mkin/DESCRIPTION’ ... OK * checking extension type ... Package -* this is package ‘mkin’ version ‘1.2.7’ +* this is package ‘mkin’ version ‘1.2.8’ * package encoding: UTF-8 -* checking CRAN incoming feasibility ... [2s/15s] Note_to_CRAN_maintainers +* checking CRAN incoming feasibility ... [2s/14s] Note_to_CRAN_maintainers Maintainer: ‘Johannes Ranke ’ * checking package namespace information ... OK * checking package dependencies ... OK @@ -62,7 +62,7 @@ Maintainer: ‘Johannes Ranke ’ * checking sizes of PDF files under ‘inst/doc’ ... OK * checking installed files from ‘inst/doc’ ... OK * checking files in ‘vignettes’ ... OK -* checking examples ... [10s/10s] OK +* checking examples ... OK * checking for unstated dependencies in ‘tests’ ... OK * checking tests ... SKIPPED * checking for unstated dependencies in vignettes ... OK diff --git a/log/test.log b/log/test.log index a6ac83ed..9dc63675 100644 --- a/log/test.log +++ b/log/test.log @@ -4,39 +4,39 @@ ✔ | 5 | Analytical solutions for coupled models [1.5s] ✔ | 5 | Calculation of Akaike weights ✔ | 3 | Export dataset for reading into CAKE -✔ | 6 | Use of precompiled symbols in mkinpredict [3.3s] +✔ | 6 | Use of precompiled symbols in mkinpredict [3.2s] ✔ | 12 | Confidence intervals and p-values -✔ | 1 12 | Dimethenamid data from 2018 [13.1s] +✔ | 1 12 | Dimethenamid data from 2018 [13.8s] ✔ | 14 | Error model fitting [2.5s] ✔ | 5 | Time step normalisation ✔ | 4 | Calculation of FOCUS chi2 error levels ✔ | 14 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ✔ | 4 | Test fitting the decline of metabolites from their maximum ✔ | 1 | Fitting the logistic model -✔ | 10 | Batch fitting and diagnosing hierarchical kinetic models [20.4s] -✔ | 2 16 | Nonlinear mixed-effects models [149.9s] +✔ | 10 | Batch fitting and diagnosing hierarchical kinetic models [19.8s] +✔ | 2 16 | Nonlinear mixed-effects models [149.6s] ✔ | 3 | Test dataset classes mkinds and mkindsg ✔ | 10 | Special cases of mkinfit calls ✔ | 3 | mkinfit features ✔ | 8 | mkinmod model generation and printing ✔ | 3 | Model predictions with mkinpredict -✔ | 12 | Multistart method for saem.mmkin models [23.0s] -✔ | 16 | Evaluations according to 2015 NAFTA guidance [1.5s] -✔ | 9 | Nonlinear mixed-effects models with nlme [3.6s] -✔ | 15 | Plotting [4.8s] +✔ | 12 | Multistart method for saem.mmkin models [23.6s] +✔ | 16 | Evaluations according to 2015 NAFTA guidance [1.6s] +✔ | 9 | Nonlinear mixed-effects models with nlme [4.0s] +✔ | 15 | Plotting [4.7s] ✔ | 4 | Residuals extracted from mkinfit models -✔ | 1 38 | saemix parent models [35.2s] +✔ | 1 38 | saemix parent models [36.4s] ✔ | 2 | Complex test case from Schaefer et al. (2007) Piacenza paper ✔ | 11 | Processing of residue series -✔ | 10 | Fitting the SFORB model [1.6s] +✔ | 10 | Fitting the SFORB model [1.8s] ✔ | 1 | Summaries of old mkinfit objects ✔ | 5 | Summary ✔ | 4 | Results for synthetic data established in expertise for UBA (Ranke 2014) -✔ | 9 | Hypothesis tests [2.8s] +✔ | 9 | Hypothesis tests [3.1s] ✔ | 4 | Calculation of maximum time weighted average concentrations (TWAs) ══ Results ═════════════════════════════════════════════════════════════════════ -Duration: 268.2 s +Duration: 270.7 s ── Skipped tests (4) ─────────────────────────────────────────────────────────── • Fitting this ODE model with saemix takes about 5 minutes on my new system diff --git a/man/check_failed.Rd b/man/check_failed.Rd new file mode 100644 index 00000000..85029024 --- /dev/null +++ b/man/check_failed.Rd @@ -0,0 +1,14 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/mhmkin.R +\name{check_failed} +\alias{check_failed} +\title{Check if fit within an mhmkin object failed} +\usage{ +check_failed(x) +} +\arguments{ +\item{x}{The object to be checked} +} +\description{ +Check if fit within an mhmkin object failed +} -- cgit v1.2.3 From e18c8da322ddb11105b7fdf93e9dd538673fb946 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Sat, 27 Apr 2024 19:22:10 +0200 Subject: Fix bug in R/create_deg_func.R Closes #13 --- DESCRIPTION | 6 ++--- NAMESPACE | 1 + NEWS.md | 4 ++++ R/create_deg_func.R | 38 +++++++++++++++++++++--------- log/build.log | 2 +- log/check.log | 14 +++++------ log/test.log | 29 ++++++++++++----------- tests/testthat/print_dfop_saem_1.txt | 2 +- tests/testthat/summary_hfit_sfo_tc.txt | 4 ++-- tests/testthat/summary_saem_dfop_sfo_s.txt | 2 +- tests/testthat/test_water-sediment.R | 17 +++++++++++++ vignettes/mkin.html | 2 +- 12 files changed, 80 insertions(+), 41 deletions(-) create mode 100644 tests/testthat/test_water-sediment.R (limited to 'DESCRIPTION') diff --git a/DESCRIPTION b/DESCRIPTION index 0d924faf..6aa012b5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: mkin Type: Package Title: Kinetic Evaluation of Chemical Degradation Data -Version: 1.2.8 -Date: 2023-11-26 +Version: 1.2.9 +Date: 2024-04-27 Authors@R: c( person("Johannes", "Ranke", role = c("aut", "cre", "cph"), email = "johannes.ranke@jrwb.de", @@ -36,4 +36,4 @@ VignetteBuilder: knitr BugReports: https://github.com/jranke/mkin/issues/ URL: https://pkgdown.jrwb.de/mkin/ Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.1 diff --git a/NAMESPACE b/NAMESPACE index bcea2b1b..5b9a1c85 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -158,6 +158,7 @@ importFrom(lmtest,lrtest) importFrom(methods,is) importFrom(methods,signature) importFrom(nlme,intervals) +importFrom(nlme,nlme) importFrom(parallel,detectCores) importFrom(parallel,mclapply) importFrom(parallel,parLapply) diff --git a/NEWS.md b/NEWS.md index f7c38915..d6139aae 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# mkin 1.2.9 + +- 'R/create_deg_func.R: Make sure that no reversible reactions are specified in the case of two observed variables, as this is not supported + # mkin 1.2.8 - 'R/{mhmkin,status}.R': Deal with 'saem' fits that fail when updating an 'mhmkin' object diff --git a/R/create_deg_func.R b/R/create_deg_func.R index 5794c65c..d3e11f78 100644 --- a/R/create_deg_func.R +++ b/R/create_deg_func.R @@ -61,16 +61,21 @@ create_deg_func <- function(spec, use_of_ff = c("min", "max")) { ), ")") - if (length(obs_vars) >= 2) { - supported <- FALSE # except for the following cases + if (length(obs_vars) >= 2) supported <- FALSE + # Except for the following cases: + + if (length(obs_vars) == 2) { n1 <- obs_vars[1] n2 <- obs_vars[2] n10 <- paste0("odeini['", parent, "']") n20 <- paste0("odeini['", n2, "']") # sfo_sfo - if (all(spec[[1]]$sink == FALSE, length(obs_vars) == 2, - spec[[1]]$type == "SFO", spec[[2]]$type == "SFO")) { + if (all( + spec[[1]]$sink == FALSE, + spec[[1]]$type == "SFO", + spec[[2]]$type == "SFO", + is.null(spec[[2]]$to))) { supported <- TRUE k1 <- k_parent k2 <- paste0("k_", n2, if(min_ff) "_sink" else "") @@ -80,8 +85,12 @@ create_deg_func <- function(spec, use_of_ff = c("min", "max")) { } # sfo_f12_sfo - if (all(use_of_ff == "max", spec[[1]]$sink == TRUE, length(obs_vars) == 2, - spec[[1]]$type == "SFO", spec[[2]]$type == "SFO")) { + if (all( + use_of_ff == "max", + spec[[1]]$sink == TRUE, + spec[[1]]$type == "SFO", + spec[[2]]$type == "SFO", + is.null(spec[[2]]$to))) { supported <- TRUE k1 <- k_parent k2 <- paste0("k_", n2) @@ -92,8 +101,12 @@ create_deg_func <- function(spec, use_of_ff = c("min", "max")) { } # sfo_k120_sfo - if (all(use_of_ff == "min", spec[[1]]$sink == TRUE, length(obs_vars) == 2, - spec[[1]]$type == "SFO", spec[[2]]$type == "SFO")) { + if (all( + use_of_ff == "min", + spec[[1]]$sink == TRUE, + spec[[1]]$type == "SFO", + spec[[2]]$type == "SFO", + is.null(spec[[2]]$to))) { supported <- TRUE k12 <- paste0("k_", n1, "_", n2) k10 <- paste0("k_", n1, "_sink") @@ -104,8 +117,12 @@ create_deg_func <- function(spec, use_of_ff = c("min", "max")) { } # dfop_f12_sfo - if (all(use_of_ff == "max", spec[[1]]$sink == TRUE, length(obs_vars) == 2, - spec[[1]]$type == "DFOP", spec[[2]]$type == "SFO")) { + if (all( + use_of_ff == "max", + spec[[1]]$sink == TRUE, + spec[[1]]$type == "DFOP", + spec[[2]]$type == "SFO", + is.null(spec[[2]]$to))) { supported <- TRUE f12 <- paste0("f_", n1, "_to_", n2) k2 <- paste0("k_", n2) @@ -119,7 +136,6 @@ create_deg_func <- function(spec, use_of_ff = c("min", "max")) { } - if (supported) { deg_func <- function(observed, odeini, odeparms) {} diff --git a/log/build.log b/log/build.log index c2001830..de7e4488 100644 --- a/log/build.log +++ b/log/build.log @@ -7,5 +7,5 @@ * checking for empty or unneeded directories Removed empty directory ‘mkin/inst/rmarkdown/templates/hierarchical_kinetics_parent’ Removed empty directory ‘mkin/vignettes/web_only’ -* building ‘mkin_1.2.8.tar.gz’ +* building ‘mkin_1.2.9.tar.gz’ diff --git a/log/check.log b/log/check.log index 5e777a87..58615282 100644 --- a/log/check.log +++ b/log/check.log @@ -1,6 +1,6 @@ * using log directory ‘/home/jranke/git/mkin/mkin.Rcheck’ -* using R version 4.3.2 (2023-10-31) -* using platform: x86_64-pc-linux-gnu (64-bit) +* using R version 4.4.0 (2024-04-24) +* using platform: x86_64-pc-linux-gnu * R was compiled by gcc (Debian 12.2.0-14) 12.2.0 GNU Fortran (Debian 12.2.0-14) 12.2.0 @@ -9,9 +9,9 @@ * using options ‘--no-tests --as-cran’ * checking for file ‘mkin/DESCRIPTION’ ... OK * checking extension type ... Package -* this is package ‘mkin’ version ‘1.2.8’ +* this is package ‘mkin’ version ‘1.2.9’ * package encoding: UTF-8 -* checking CRAN incoming feasibility ... [2s/14s] Note_to_CRAN_maintainers +* checking CRAN incoming feasibility ... Note_to_CRAN_maintainers Maintainer: ‘Johannes Ranke ’ * checking package namespace information ... OK * checking package dependencies ... OK @@ -32,7 +32,7 @@ Maintainer: ‘Johannes Ranke ’ * checking for left-over files ... OK * checking index information ... OK * checking package subdirectories ... OK -* checking R files for non-ASCII characters ... OK +* checking code files for non-ASCII characters ... OK * checking R files for syntax errors ... OK * checking whether the package can be loaded ... OK * checking whether the package can be loaded with stated dependencies ... OK @@ -62,11 +62,11 @@ Maintainer: ‘Johannes Ranke ’ * checking sizes of PDF files under ‘inst/doc’ ... OK * checking installed files from ‘inst/doc’ ... OK * checking files in ‘vignettes’ ... OK -* checking examples ... OK +* checking examples ... [10s/10s] OK * checking for unstated dependencies in ‘tests’ ... OK * checking tests ... SKIPPED * checking for unstated dependencies in vignettes ... OK -* checking package vignettes in ‘inst/doc’ ... OK +* checking package vignettes ... OK * checking re-building of vignette outputs ... OK * checking PDF version of manual ... OK * checking HTML version of manual ... OK diff --git a/log/test.log b/log/test.log index 9dc63675..e92a7409 100644 --- a/log/test.log +++ b/log/test.log @@ -4,39 +4,40 @@ ✔ | 5 | Analytical solutions for coupled models [1.5s] ✔ | 5 | Calculation of Akaike weights ✔ | 3 | Export dataset for reading into CAKE -✔ | 6 | Use of precompiled symbols in mkinpredict [3.2s] +✔ | 6 | Use of precompiled symbols in mkinpredict [3.1s] ✔ | 12 | Confidence intervals and p-values -✔ | 1 12 | Dimethenamid data from 2018 [13.8s] -✔ | 14 | Error model fitting [2.5s] +✔ | 1 12 | Dimethenamid data from 2018 [13.0s] +✔ | 14 | Error model fitting [2.6s] ✔ | 5 | Time step normalisation ✔ | 4 | Calculation of FOCUS chi2 error levels ✔ | 14 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ✔ | 4 | Test fitting the decline of metabolites from their maximum ✔ | 1 | Fitting the logistic model -✔ | 10 | Batch fitting and diagnosing hierarchical kinetic models [19.8s] -✔ | 2 16 | Nonlinear mixed-effects models [149.6s] +✔ | 10 | Batch fitting and diagnosing hierarchical kinetic models [19.7s] +✔ | 2 16 | Nonlinear mixed-effects models [144.7s] ✔ | 3 | Test dataset classes mkinds and mkindsg ✔ | 10 | Special cases of mkinfit calls ✔ | 3 | mkinfit features ✔ | 8 | mkinmod model generation and printing ✔ | 3 | Model predictions with mkinpredict -✔ | 12 | Multistart method for saem.mmkin models [23.6s] -✔ | 16 | Evaluations according to 2015 NAFTA guidance [1.6s] -✔ | 9 | Nonlinear mixed-effects models with nlme [4.0s] -✔ | 15 | Plotting [4.7s] +✔ | 12 | Multistart method for saem.mmkin models [23.3s] +✔ | 16 | Evaluations according to 2015 NAFTA guidance [1.5s] +✔ | 9 | Nonlinear mixed-effects models with nlme [3.7s] +✔ | 15 | Plotting [4.5s] ✔ | 4 | Residuals extracted from mkinfit models -✔ | 1 38 | saemix parent models [36.4s] +✔ | 1 38 | saemix parent models [34.8s] ✔ | 2 | Complex test case from Schaefer et al. (2007) Piacenza paper ✔ | 11 | Processing of residue series -✔ | 10 | Fitting the SFORB model [1.8s] +✔ | 10 | Fitting the SFORB model [1.7s] ✔ | 1 | Summaries of old mkinfit objects ✔ | 5 | Summary ✔ | 4 | Results for synthetic data established in expertise for UBA (Ranke 2014) -✔ | 9 | Hypothesis tests [3.1s] +✔ | 9 | Hypothesis tests [2.9s] ✔ | 4 | Calculation of maximum time weighted average concentrations (TWAs) +✔ | 2 | water-sediment ══ Results ═════════════════════════════════════════════════════════════════════ -Duration: 270.7 s +Duration: 262.3 s ── Skipped tests (4) ─────────────────────────────────────────────────────────── • Fitting this ODE model with saemix takes about 5 minutes on my new system @@ -47,4 +48,4 @@ Duration: 270.7 s • This still takes almost 2.5 minutes although we do not solve ODEs (1): 'test_saemix_parent.R:143:3' -[ FAIL 0 | WARN 0 | SKIP 4 | PASS 283 ] +[ FAIL 0 | WARN 0 | SKIP 4 | PASS 285 ] diff --git a/tests/testthat/print_dfop_saem_1.txt b/tests/testthat/print_dfop_saem_1.txt index f7354320..3a1f1667 100644 --- a/tests/testthat/print_dfop_saem_1.txt +++ b/tests/testthat/print_dfop_saem_1.txt @@ -18,6 +18,6 @@ log_k1 -2.71 -2.94 -2.49 log_k2 -4.14 -4.26 -4.01 g_qlogis -0.36 -0.54 -0.17 a.1 0.93 0.69 1.17 -b.1 0.05 0.04 0.06 +b.1 0.05 0.04 0.05 SD.log_k1 0.37 0.23 0.51 SD.log_k2 0.23 0.14 0.31 diff --git a/tests/testthat/summary_hfit_sfo_tc.txt b/tests/testthat/summary_hfit_sfo_tc.txt index 0618c715..ba7d1362 100644 --- a/tests/testthat/summary_hfit_sfo_tc.txt +++ b/tests/testthat/summary_hfit_sfo_tc.txt @@ -43,7 +43,7 @@ Optimised parameters: est. lower upper parent_0 92.52 89.11 95.9 log_k_parent -1.66 -2.07 -1.3 -a.1 2.03 1.60 2.5 +a.1 2.03 1.61 2.5 b.1 0.09 0.07 0.1 SD.log_k_parent 0.51 0.22 0.8 @@ -57,7 +57,7 @@ SD.log_k_parent 0.5 0.2 0.8 Variance model: est. lower upper -a.1 2.03 1.60 2.5 +a.1 2.03 1.61 2.5 b.1 0.09 0.07 0.1 Backtransformed parameters: diff --git a/tests/testthat/summary_saem_dfop_sfo_s.txt b/tests/testthat/summary_saem_dfop_sfo_s.txt index 6468ff17..a19824ce 100644 --- a/tests/testthat/summary_saem_dfop_sfo_s.txt +++ b/tests/testthat/summary_saem_dfop_sfo_s.txt @@ -86,7 +86,7 @@ SD.g 0.21 0.06 0.4 Variance model: est. lower upper -a.1 0.93 0.79 1.06 +a.1 0.93 0.80 1.06 b.1 0.05 0.05 0.06 Resulting formation fractions: diff --git a/tests/testthat/test_water-sediment.R b/tests/testthat/test_water-sediment.R new file mode 100644 index 00000000..6d5693c9 --- /dev/null +++ b/tests/testthat/test_water-sediment.R @@ -0,0 +1,17 @@ +# Issue #13 on github +water_sed_no_sed_sink <- mkinmod( + use_of_ff = "min", + water = mkinsub("SFO", "sediment"), + sediment = mkinsub("SFO", "water", sink = FALSE)) + +ws_data <- FOCUS_D +levels(ws_data$name) <- c("water", "sediment") + +test_that("An reversible reaction with the sink turned off in the second compartment works", { + # Solution method "analytical" was previously available, but erroneous + expect_error( + ws_fit_no_sed_sink <- mkinfit(water_sed_no_sed_sink, ws_data, quiet = TRUE, solution_type = "analytical"), + "Analytical solution not implemented") + ws_fit_no_sed_sink_default <- mkinfit(water_sed_no_sed_sink, ws_data, quiet = TRUE) + expect_equal(ws_fit_no_sed_sink_default$solution_type, "deSolve") +}) diff --git a/vignettes/mkin.html b/vignettes/mkin.html index 12b8671e..ea057d19 100644 --- a/vignettes/mkin.html +++ b/vignettes/mkin.html @@ -372,7 +372,7 @@ code > span.er { color: #a61717; background-color: #e3d2d2; }

Short introduction to mkin

Johannes Ranke

-

Last change 18 May 2023 (rebuilt 2023-05-19)

+

Last change 18 May 2023 (rebuilt 2024-04-27)

-- cgit v1.2.3 From 272b3863d1463dfaf62c6e06ea22610c0540237f Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Sun, 28 Jul 2024 09:25:18 +0200 Subject: Make sure test work on my desktop, skip more tests on travis --- DESCRIPTION | 2 +- log/test.log | 16 ++++++++-------- tests/testthat/test_mixed.R | 2 ++ 3 files changed, 11 insertions(+), 9 deletions(-) (limited to 'DESCRIPTION') diff --git a/DESCRIPTION b/DESCRIPTION index 6aa012b5..3c1c4f7d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -36,4 +36,4 @@ VignetteBuilder: knitr BugReports: https://github.com/jranke/mkin/issues/ URL: https://pkgdown.jrwb.de/mkin/ Roxygen: list(markdown = TRUE) -RoxygenNote: 7.3.1 +RoxygenNote: 7.3.2 diff --git a/log/test.log b/log/test.log index e92a7409..0bd7338d 100644 --- a/log/test.log +++ b/log/test.log @@ -6,26 +6,26 @@ ✔ | 3 | Export dataset for reading into CAKE ✔ | 6 | Use of precompiled symbols in mkinpredict [3.1s] ✔ | 12 | Confidence intervals and p-values -✔ | 1 12 | Dimethenamid data from 2018 [13.0s] +✔ | 1 12 | Dimethenamid data from 2018 [13.3s] ✔ | 14 | Error model fitting [2.6s] ✔ | 5 | Time step normalisation ✔ | 4 | Calculation of FOCUS chi2 error levels ✔ | 14 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ✔ | 4 | Test fitting the decline of metabolites from their maximum ✔ | 1 | Fitting the logistic model -✔ | 10 | Batch fitting and diagnosing hierarchical kinetic models [19.7s] -✔ | 2 16 | Nonlinear mixed-effects models [144.7s] +✔ | 10 | Batch fitting and diagnosing hierarchical kinetic models [19.1s] +✔ | 2 16 | Nonlinear mixed-effects models [148.9s] ✔ | 3 | Test dataset classes mkinds and mkindsg ✔ | 10 | Special cases of mkinfit calls ✔ | 3 | mkinfit features ✔ | 8 | mkinmod model generation and printing ✔ | 3 | Model predictions with mkinpredict -✔ | 12 | Multistart method for saem.mmkin models [23.3s] +✔ | 12 | Multistart method for saem.mmkin models [23.1s] ✔ | 16 | Evaluations according to 2015 NAFTA guidance [1.5s] -✔ | 9 | Nonlinear mixed-effects models with nlme [3.7s] -✔ | 15 | Plotting [4.5s] +✔ | 9 | Nonlinear mixed-effects models with nlme [3.8s] +✔ | 15 | Plotting [4.6s] ✔ | 4 | Residuals extracted from mkinfit models -✔ | 1 38 | saemix parent models [34.8s] +✔ | 1 38 | saemix parent models [35.5s] ✔ | 2 | Complex test case from Schaefer et al. (2007) Piacenza paper ✔ | 11 | Processing of residue series ✔ | 10 | Fitting the SFORB model [1.7s] @@ -37,7 +37,7 @@ ✔ | 2 | water-sediment ══ Results ═════════════════════════════════════════════════════════════════════ -Duration: 262.3 s +Duration: 267.0 s ── Skipped tests (4) ─────────────────────────────────────────────────────────── • Fitting this ODE model with saemix takes about 5 minutes on my new system diff --git a/tests/testthat/test_mixed.R b/tests/testthat/test_mixed.R index d8ad4417..b9715096 100644 --- a/tests/testthat/test_mixed.R +++ b/tests/testthat/test_mixed.R @@ -89,6 +89,7 @@ test_that("saemix results are reproducible for biphasic fits", { test_that("Reading spreadsheets, finding ill-defined parameters and covariate modelling", { skip_on_cran() + skip_on_travis() data_path <- system.file( "testdata", "lambda-cyhalothrin_soil_efsa_2014.xlsx", @@ -115,6 +116,7 @@ test_that("Reading spreadsheets, finding ill-defined parameters and covariate mo test_that("SFO-SFO saemix specific analytical solution work", { skip_on_cran() + skip_on_travis() SFO_SFO <- mkinmod(DMTA = mkinsub("SFO", "M23"), M23 = mkinsub("SFO"), quiet = TRUE) -- cgit v1.2.3 From 328d1173db2395c1a5705b5f0980e2956db8be1f Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Thu, 13 Feb 2025 12:43:29 +0100 Subject: Update wordlist, bump date and simplify DESCRIPTION Also, the R-Universe URL that the badge points to is updated --- DESCRIPTION | 15 +- R/mkinpredict.R | 4 +- R/nlme.R | 2 +- README.md | 2 +- docs/404.html | 2 +- docs/articles/index.html | 2 +- docs/authors.html | 6 +- docs/index.html | 6 +- docs/news/index.html | 2 +- docs/reference/index.html | 2 +- docs/reference/mkinpredict.html | 158 ++++++++++---------- docs/reference/nlme-1.png | Bin 78105 -> 76554 bytes docs/reference/nlme-2.png | Bin 90402 -> 88313 bytes docs/reference/nlme.html | 137 ++++++++---------- docs/search.json | 2 +- inst/WORDLIST | 310 ++++++++++++++++++++++++++-------------- log/check.log | 15 +- man/mkinpredict.Rd | 4 +- man/nlme.Rd | 2 +- 19 files changed, 374 insertions(+), 297 deletions(-) (limited to 'DESCRIPTION') diff --git a/DESCRIPTION b/DESCRIPTION index 3c1c4f7d..71fa3d99 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,7 +2,7 @@ Package: mkin Type: Package Title: Kinetic Evaluation of Chemical Degradation Data Version: 1.2.9 -Date: 2024-04-27 +Date: 2025-02-13 Authors@R: c( person("Johannes", "Ranke", role = c("aut", "cre", "cph"), email = "johannes.ranke@jrwb.de", @@ -15,14 +15,13 @@ Description: Calculation routines based on the FOCUS Kinetics Report (2006, models, model solution based on eigenvalues if possible or using numerical solvers. If a C compiler (on windows: 'Rtools') is installed, differential equation models are solved using automatically generated C functions. - Heteroscedasticity can be taken into account using variance by variable or - two-component error models as described by Ranke and Meinecke (2018) - . Hierarchical degradation models can - be fitted using nonlinear mixed-effects model packages as a back end as - described by Ranke et al. (2021) . Please + Inhomogeneous errors can be taken into account using variance by variable or + two-component error models . Hierarchical + degradation models can be fitted using nonlinear mixed-effects model packages + as a back end . Please note that no warranty is implied for correctness of results or fitness for a particular purpose. -Depends: R (>= 2.15.1), +Depends: R (>= 4.1.0) Imports: stats, graphics, methods, parallel, deSolve (>= 1.35), R6, inline (>= 0.3.19), numDeriv, lmtest, pkgbuild, nlme (>= 3.1-151), saemix (>= 3.2), rlang, vctrs Suggests: knitr, rbenchmark, tikzDevice, testthat, rmarkdown, covr, vdiffr, @@ -36,4 +35,4 @@ VignetteBuilder: knitr BugReports: https://github.com/jranke/mkin/issues/ URL: https://pkgdown.jrwb.de/mkin/ Roxygen: list(markdown = TRUE) -RoxygenNote: 7.3.2 +RoxygenNote: 7.3.2.9000 diff --git a/R/mkinpredict.R b/R/mkinpredict.R index 60456fb2..4c6d7862 100644 --- a/R/mkinpredict.R +++ b/R/mkinpredict.R @@ -22,7 +22,7 @@ #' variables. The third possibility "eigen" is fast in comparison to uncompiled #' ODE models, but not applicable to some models, e.g. using FOMC for the #' parent compound. -#' @param method.ode The solution method passed via [mkinpredict] to [ode]] in +#' @param method.ode The solution method passed via [mkinpredict] to `deSolve::ode()` in #' case the solution type is "deSolve" and we are not using compiled code. #' When using compiled code, only lsoda is supported. #' @param use_compiled If set to \code{FALSE}, no compiled version of the @@ -36,7 +36,7 @@ #' the observed variables (default) or for all state variables (if set to #' FALSE). Setting this to FALSE has no effect for analytical solutions, #' as these always return mapped output. -#' @param na_stop Should it be an error if [ode] returns NaN values +#' @param na_stop Should it be an error if `deSolve::ode()` returns NaN values #' @param \dots Further arguments passed to the ode solver in case such a #' solver is used. #' @return A matrix with the numeric solution in wide format diff --git a/R/nlme.R b/R/nlme.R index 6b2d06d0..de82d99c 100644 --- a/R/nlme.R +++ b/R/nlme.R @@ -126,7 +126,7 @@ nlme_function <- function(object) { #' @rdname nlme #' @importFrom rlang !!! -#' @return A \code{\link{groupedData}} object +#' @return A `nlme::groupedData` object #' @export nlme_data <- function(object) { if (nrow(object) > 1) stop("Only row objects allowed") diff --git a/README.md b/README.md index 8d7952ee..2d3720ca 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![](https://www.r-pkg.org/badges/version/mkin)](https://cran.r-project.org/package=mkin) -[![mkin status badge](https://jranke.r-universe.dev/badges/mkin)](https://jranke.r-universe.dev/ui/#package:mkin) +[![mkin status badge](https://jranke.r-universe.dev/badges/mkin)](https://jranke.r-universe.dev/#package:mkin) [![Build Status](https://app.travis-ci.com/jranke/mkin.svg?token=Sq9VuYWyRz2FbBLxu6DK&branch=main)](https://app.travis-ci.com/jranke/mkin) diff --git a/docs/404.html b/docs/404.html index 22e29157..f05b97f3 100644 --- a/docs/404.html +++ b/docs/404.html @@ -88,7 +88,7 @@ Content not found. Please use links in the navbar.
diff --git a/docs/articles/index.html b/docs/articles/index.html index 0d62e494..0c3e7449 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -101,7 +101,7 @@ diff --git a/docs/authors.html b/docs/authors.html index 56bae28c..26399e08 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -83,14 +83,14 @@

Citation

Source: DESCRIPTION

-

Ranke J (2024). +

Ranke J (2025). mkin: Kinetic Evaluation of Chemical Degradation Data. R package version 1.2.9, https://pkgdown.jrwb.de/mkin/.

@Manual{,
   title = {mkin: Kinetic Evaluation of Chemical Degradation Data},
   author = {Johannes Ranke},
-  year = {2024},
+  year = {2025},
   note = {R package version 1.2.9},
   url = {https://pkgdown.jrwb.de/mkin/},
 }
@@ -105,7 +105,7 @@ R package version 1.2.9, https://pkgdown diff --git a/docs/index.html b/docs/index.html index 915a3243..8c1a7c59 100644 --- a/docs/index.html +++ b/docs/index.html @@ -9,8 +9,8 @@ - - + + Skip to contents @@ -256,7 +256,7 @@ Von Götz N, Nörtersheuser P, Richter O (1999) Population based analysis of pes diff --git a/docs/news/index.html b/docs/news/index.html index eeb84a76..44de0536 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -656,7 +656,7 @@ diff --git a/docs/reference/index.html b/docs/reference/index.html index 63e1e634..1448bbe6 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -722,7 +722,7 @@ diff --git a/docs/reference/mkinpredict.html b/docs/reference/mkinpredict.html index 860c7cfc..13f42da0 100644 --- a/docs/reference/mkinpredict.html +++ b/docs/reference/mkinpredict.html @@ -1,78 +1,65 @@ -Produce predictions from a kinetic model using specific parameters — mkinpredict • mkinProduce predictions from a kinetic model using specific parameters — mkinpredict • mkin +kinetic parameters and initial values for the state variables."> Skip to contents - -