From a1b5d63e031d22b190e9e9fc30753b699ad6b4ea Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Thu, 23 Nov 2023 05:20:17 +0100 Subject: fix: 'R/illparms.R': An ill-defined random effect is now also found if there is only one random effect in the model. Also add a test for this. --- NEWS.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'NEWS.md') diff --git a/NEWS.md b/NEWS.md index 96088a62..100f8b6c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,8 @@ -# mkin 1.2.6 +# 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. + +# mkin 1.2.6 (2023-10-14) - 'inst/rmarkdown/templates/hierarchical_kinetics/skeleton/skeleton.Rmd': Fix an erroneous call to the 'endpoints()' function -- 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 'NEWS.md') 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 'NEWS.md') 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 bad2f70c18cd9f57c0d382914327613bcfc9298f Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Mon, 29 Jul 2024 08:06:08 +0200 Subject: Move coverage to pkgdown docs The coverage report is neither successful on Travis nor in the github workflow set up with the usethis package. Therefore the code coverage report is generated locally and linked into the pkgdown docs. --- .github/workflows/test-coverage.yaml | 61 -- GNUmakefile | 3 +- NEWS.md | 4 +- README.md | 2 - _pkgdown.yml | 3 + docs/404.html | 112 ++-- docs/articles/index.html | 129 ++-- docs/articles/mkin.html | 136 ++-- docs/authors.html | 124 ++-- docs/index.html | 136 ++-- docs/news/index.html | 117 ++-- docs/reference/BIC.mmkin.html | 8 + docs/reference/FOCUS_2006_A.html | 8 + docs/reference/FOCUS_2006_B.html | 8 + docs/reference/FOCUS_2006_C.html | 8 + docs/reference/FOCUS_2006_D.html | 8 + docs/reference/FOCUS_2006_E.html | 8 + docs/reference/FOCUS_2006_F.html | 8 + docs/reference/NAFTA_SOP_Appendix_B.html | 8 + docs/reference/NAFTA_SOP_Appendix_D.html | 8 + docs/reference/Rplot001.png | Bin 13993 -> 1011 bytes docs/reference/[.mhmkin.html | 8 + docs/reference/aw.mixed.mmkin.html | 8 + docs/reference/aw.mkinfit.html | 8 + docs/reference/aw.mmkin.html | 8 + docs/reference/aw.multistart.html | 8 + docs/reference/backtransform_odeparms.html | 8 + docs/reference/best.default.html | 8 + docs/reference/best.html | 8 + docs/reference/check_failed.html | 100 +++ docs/reference/ds_dfop.html | 8 + docs/reference/ds_dfop_sfo.html | 8 + docs/reference/ds_fomc.html | 8 + docs/reference/ds_hs.html | 8 + docs/reference/ds_sfo.html | 8 + docs/reference/f_time_norm_focus.mkindsg.html | 8 + docs/reference/f_time_norm_focus.numeric.html | 8 + docs/reference/hierarchical_kinetics.html | 125 ++-- docs/reference/html_listing.html | 8 + docs/reference/illparms.mhmkin.html | 8 + docs/reference/illparms.mkinfit.html | 8 + docs/reference/illparms.mmkin.html | 8 + docs/reference/illparms.saem.mmkin.html | 8 + docs/reference/index.html | 725 ++++++++++++---------- docs/reference/intervals.html | 8 + docs/reference/invilr.html | 8 + docs/reference/loftest.mkinfit.html | 8 + docs/reference/lrtest.html | 8 + docs/reference/lrtest.mmkin.html | 8 + docs/reference/max_twa_dfop.html | 8 + docs/reference/max_twa_fomc.html | 8 + docs/reference/max_twa_hs.html | 8 + docs/reference/max_twa_sfo.html | 8 + docs/reference/mhmkin.list.html | 8 + docs/reference/mhmkin.mmkin.html | 8 + docs/reference/mixed.mmkin.html | 8 + docs/reference/mkinpredict.mkinfit.html | 8 + docs/reference/mkinpredict.mkinmod.html | 8 + docs/reference/mkinsub.html | 234 +------ docs/reference/multistart.saem.mmkin.html | 8 + docs/reference/nlme_data.html | 8 + docs/reference/parms.mkinfit.html | 8 + docs/reference/parms.mmkin.html | 8 + docs/reference/parms.multistart.html | 8 + docs/reference/parms.saem.mmkin.html | 8 + docs/reference/parplot.multistart.saem.mmkin.html | 8 + docs/reference/plot_err.html | 8 + docs/reference/plot_res.html | 8 + docs/reference/plot_sep.html | 8 + docs/reference/print.illparms.mhmkin.html | 8 + docs/reference/print.illparms.mkinfit.html | 8 + docs/reference/print.illparms.mmkin.html | 8 + docs/reference/print.illparms.saem.mmkin.html | 8 + docs/reference/print.mhmkin.html | 8 + docs/reference/print.mixed.mmkin.html | 8 + docs/reference/print.mkinds.html | 194 +----- docs/reference/print.mkindsg.html | 8 + docs/reference/print.mkinmod.html | 214 +------ docs/reference/print.mmkin.html | 194 +----- docs/reference/print.multistart.html | 8 + docs/reference/print.nafta.html | 8 + docs/reference/print.nlme.mmkin.html | 8 + docs/reference/print.saem.mmkin.html | 8 + docs/reference/print.status.mhmkin.html | 8 + docs/reference/print.status.mmkin.html | 8 + docs/reference/print.summary.mkinfit.html | 8 + docs/reference/print.summary.mmkin.html | 8 + docs/reference/print.summary.nlme.mmkin.html | 8 + docs/reference/print.summary.saem.mmkin.html | 8 + docs/reference/saem.mmkin.html | 8 + docs/reference/saemix_data.html | 8 + docs/reference/saemix_model.html | 8 + docs/reference/schaefer07_complex_results.html | 8 + docs/reference/set_nd_nq_focus.html | 8 + docs/reference/status.mhmkin.html | 8 + docs/reference/status.mmkin.html | 8 + docs/reference/tex_listing.html | 149 +---- docs/reference/update.nlme.mmkin.html | 8 + docs/reference/which.best.default.html | 8 + docs/reference/which.best.html | 8 + docs/search.json | 2 +- docs/sitemap.xml | 469 ++++---------- 102 files changed, 1671 insertions(+), 2202 deletions(-) delete mode 100644 .github/workflows/test-coverage.yaml create mode 100644 docs/reference/BIC.mmkin.html create mode 100644 docs/reference/FOCUS_2006_A.html create mode 100644 docs/reference/FOCUS_2006_B.html create mode 100644 docs/reference/FOCUS_2006_C.html create mode 100644 docs/reference/FOCUS_2006_D.html create mode 100644 docs/reference/FOCUS_2006_E.html create mode 100644 docs/reference/FOCUS_2006_F.html create mode 100644 docs/reference/NAFTA_SOP_Appendix_B.html create mode 100644 docs/reference/NAFTA_SOP_Appendix_D.html create mode 100644 docs/reference/[.mhmkin.html create mode 100644 docs/reference/aw.mixed.mmkin.html create mode 100644 docs/reference/aw.mkinfit.html create mode 100644 docs/reference/aw.mmkin.html create mode 100644 docs/reference/aw.multistart.html create mode 100644 docs/reference/backtransform_odeparms.html create mode 100644 docs/reference/best.default.html create mode 100644 docs/reference/best.html create mode 100644 docs/reference/check_failed.html create mode 100644 docs/reference/ds_dfop.html create mode 100644 docs/reference/ds_dfop_sfo.html create mode 100644 docs/reference/ds_fomc.html create mode 100644 docs/reference/ds_hs.html create mode 100644 docs/reference/ds_sfo.html create mode 100644 docs/reference/f_time_norm_focus.mkindsg.html create mode 100644 docs/reference/f_time_norm_focus.numeric.html create mode 100644 docs/reference/html_listing.html create mode 100644 docs/reference/illparms.mhmkin.html create mode 100644 docs/reference/illparms.mkinfit.html create mode 100644 docs/reference/illparms.mmkin.html create mode 100644 docs/reference/illparms.saem.mmkin.html create mode 100644 docs/reference/intervals.html create mode 100644 docs/reference/invilr.html create mode 100644 docs/reference/loftest.mkinfit.html create mode 100644 docs/reference/lrtest.html create mode 100644 docs/reference/lrtest.mmkin.html create mode 100644 docs/reference/max_twa_dfop.html create mode 100644 docs/reference/max_twa_fomc.html create mode 100644 docs/reference/max_twa_hs.html create mode 100644 docs/reference/max_twa_sfo.html create mode 100644 docs/reference/mhmkin.list.html create mode 100644 docs/reference/mhmkin.mmkin.html create mode 100644 docs/reference/mixed.mmkin.html create mode 100644 docs/reference/mkinpredict.mkinfit.html create mode 100644 docs/reference/mkinpredict.mkinmod.html create mode 100644 docs/reference/multistart.saem.mmkin.html create mode 100644 docs/reference/nlme_data.html create mode 100644 docs/reference/parms.mkinfit.html create mode 100644 docs/reference/parms.mmkin.html create mode 100644 docs/reference/parms.multistart.html create mode 100644 docs/reference/parms.saem.mmkin.html create mode 100644 docs/reference/parplot.multistart.saem.mmkin.html create mode 100644 docs/reference/plot_err.html create mode 100644 docs/reference/plot_res.html create mode 100644 docs/reference/plot_sep.html create mode 100644 docs/reference/print.illparms.mhmkin.html create mode 100644 docs/reference/print.illparms.mkinfit.html create mode 100644 docs/reference/print.illparms.mmkin.html create mode 100644 docs/reference/print.illparms.saem.mmkin.html create mode 100644 docs/reference/print.mhmkin.html create mode 100644 docs/reference/print.mixed.mmkin.html create mode 100644 docs/reference/print.mkindsg.html create mode 100644 docs/reference/print.multistart.html create mode 100644 docs/reference/print.nafta.html create mode 100644 docs/reference/print.nlme.mmkin.html create mode 100644 docs/reference/print.saem.mmkin.html create mode 100644 docs/reference/print.status.mhmkin.html create mode 100644 docs/reference/print.status.mmkin.html create mode 100644 docs/reference/print.summary.mkinfit.html create mode 100644 docs/reference/print.summary.mmkin.html create mode 100644 docs/reference/print.summary.nlme.mmkin.html create mode 100644 docs/reference/print.summary.saem.mmkin.html create mode 100644 docs/reference/saem.mmkin.html create mode 100644 docs/reference/saemix_data.html create mode 100644 docs/reference/saemix_model.html create mode 100644 docs/reference/schaefer07_complex_results.html create mode 100644 docs/reference/set_nd_nq_focus.html create mode 100644 docs/reference/status.mhmkin.html create mode 100644 docs/reference/status.mmkin.html create mode 100644 docs/reference/update.nlme.mmkin.html create mode 100644 docs/reference/which.best.default.html create mode 100644 docs/reference/which.best.html (limited to 'NEWS.md') diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml deleted file mode 100644 index fefc52e2..00000000 --- a/.github/workflows/test-coverage.yaml +++ /dev/null @@ -1,61 +0,0 @@ -# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples -# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help -on: - push: - branches: [main, master] - pull_request: - branches: [main, master] - -name: test-coverage - -permissions: read-all - -jobs: - test-coverage: - runs-on: ubuntu-latest - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - - steps: - - uses: actions/checkout@v4 - - - uses: r-lib/actions/setup-r@v2 - with: - use-public-rspm: true - - - uses: r-lib/actions/setup-r-dependencies@v2 - with: - extra-packages: any::covr, any::xml2 - needs: coverage - - - name: Test coverage - run: | - cov <- covr::package_coverage( - quiet = FALSE, - clean = FALSE, - install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package") - ) - covr::to_cobertura(cov) - shell: Rscript {0} - - - uses: codecov/codecov-action@v4 - with: - fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }} - file: ./cobertura.xml - plugin: noop - disable_search: true - token: ${{ secrets.CODECOV_TOKEN }} - - - name: Show testthat output - if: always() - run: | - ## -------------------------------------------------------------------- - find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true - shell: bash - - - name: Upload test results - if: failure() - uses: actions/upload-artifact@v4 - with: - name: coverage-test-failures - path: ${{ runner.temp }}/package diff --git a/GNUmakefile b/GNUmakefile index 76163ab6..23f994a1 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -125,8 +125,7 @@ pd_all: roxygen git add -A coverage: - mkdir -p docs/dev/coverage - "$(RBIN)/Rscript" -e "covr::report(file = 'coverage/coverage.html')" + "$(RBIN)/Rscript" -e "covr::report(file = 'docs/coverage/coverage.html')" r-forge: git archive main > $(HOME)/git/mkin/mkin.tar;\ diff --git a/NEWS.md b/NEWS.md index d6139aae..69d6b6f7 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,11 +2,11 @@ - '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 +# mkin 1.2.8 (unreleased) - 'R/{mhmkin,status}.R': Deal with 'saem' fits that fail when updating an 'mhmkin' object -# mkin 1.2.7 +# mkin 1.2.7 (unreleased) - '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/README.md b/README.md index dee59ed9..8d7952ee 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,8 @@ [![](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) [![Build Status](https://app.travis-ci.com/jranke/mkin.svg?token=Sq9VuYWyRz2FbBLxu6DK&branch=main)](https://app.travis-ci.com/jranke/mkin) -[![Codecov test coverage](https://codecov.io/gh/jranke/mkin/branch/main/graph/badge.svg)](https://app.codecov.io/gh/jranke/mkin?branch=main) - The [R](https://www.r-project.org) package **mkin** provides calculation routines for the analysis of chemical degradation data, including multicompartment kinetics as needed for modelling the formation and decline of transformation products, or diff --git a/_pkgdown.yml b/_pkgdown.yml index 34220df8..0902ced9 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -67,6 +67,7 @@ reference: - multistart - llhist - parplot + - check_failed - title: Datasets and known results contents: - ds_mixed @@ -178,5 +179,7 @@ navbar: href: articles/twa.html - text: Example evaluation of NAFTA SOP Attachment examples href: articles/web_only/NAFTA_examples.html + - text: Test coverage + href: coverage/coverage.html - text: News href: news/index.html diff --git a/docs/404.html b/docs/404.html index b85f954e..22e29157 100644 --- a/docs/404.html +++ b/docs/404.html @@ -8,87 +8,73 @@ Page not found (404) • mkin - - - - + Skip to contents - -