From b703ee38ffc8877be843cf5a557dd9c32c54f977 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Thu, 21 Jul 2022 17:15:12 +0200 Subject: Summary method for mmkin objects Also, add a method for gathering convergence information and a method for gathering information on ill-defined parameters --- DESCRIPTION | 4 +- NAMESPACE | 9 + NEWS.md | 8 + R/convergence.R | 71 + R/illparms.R | 62 + R/mmkin.R | 51 +- R/summary.mmkin.R | 56 + build.log | 2 +- check.log | 5 +- man/convergence.Rd | 39 + man/illparms.Rd | 46 + man/summary.mkinfit.Rd | 2 +- man/summary.mmkin.Rd | 36 + summary_parent_FOCUS_2006.txt | 20 + test.log | 47 +- .../plot/mixed-model-fit-for-nlme-object.new.svg | 1367 ----------- .../plot/mixed-model-fit-for-nlme-object.svg | 6 +- ...r-saem-object-with-mkin-transformations.new.svg | 2502 -------------------- ...t-for-saem-object-with-mkin-transformations.svg | 2332 +++++++++--------- tests/testthat/summary_parent_FOCUS_2006.txt | 20 + tests/testthat/test_summary.R | 6 + 21 files changed, 1574 insertions(+), 5117 deletions(-) create mode 100644 R/convergence.R create mode 100644 R/illparms.R create mode 100644 R/summary.mmkin.R create mode 100644 man/convergence.Rd create mode 100644 man/illparms.Rd create mode 100644 man/summary.mmkin.Rd create mode 100644 summary_parent_FOCUS_2006.txt delete mode 100644 tests/testthat/_snaps/plot/mixed-model-fit-for-nlme-object.new.svg delete mode 100644 tests/testthat/_snaps/plot/mixed-model-fit-for-saem-object-with-mkin-transformations.new.svg create mode 100644 tests/testthat/summary_parent_FOCUS_2006.txt diff --git a/DESCRIPTION b/DESCRIPTION index 569fd2c7..a28654cc 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: mkin Type: Package Title: Kinetic Evaluation of Chemical Degradation Data -Version: 1.1.1 -Date: 2022-07-08 +Version: 1.1.2 +Date: 2022-07-21 Authors@R: c( person("Johannes", "Ranke", role = c("aut", "cre", "cph"), email = "johannes.ranke@jrwb.de", diff --git a/NAMESPACE b/NAMESPACE index c5a4a389..96cd92e4 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -6,8 +6,11 @@ S3method(BIC,mmkin) S3method(aw,mkinfit) S3method(aw,mmkin) S3method(confint,mkinfit) +S3method(convergence,mmkin) S3method(f_time_norm_focus,mkindsg) S3method(f_time_norm_focus,numeric) +S3method(illparms,mkinfit) +S3method(illparms,mmkin) S3method(intervals,saem.mmkin) S3method(loftest,mkinfit) S3method(logLik,mkinfit) @@ -24,6 +27,8 @@ S3method(plot,mixed.mmkin) S3method(plot,mkinfit) S3method(plot,mmkin) S3method(plot,nafta) +S3method(print,convergence.mmkin) +S3method(print,illparms.mmkin) S3method(print,mixed.mmkin) S3method(print,mkinds) S3method(print,mkindsg) @@ -33,11 +38,13 @@ S3method(print,nafta) S3method(print,nlme.mmkin) S3method(print,saem.mmkin) S3method(print,summary.mkinfit) +S3method(print,summary.mmkin) S3method(print,summary.nlme.mmkin) S3method(print,summary.saem.mmkin) S3method(residuals,mkinfit) S3method(saem,mmkin) S3method(summary,mkinfit) +S3method(summary,mmkin) S3method(summary,nlme.mmkin) S3method(summary,saem.mmkin) S3method(update,mkinfit) @@ -53,10 +60,12 @@ export(SFORB.solution) export(add_err) export(aw) export(backtransform_odeparms) +export(convergence) export(create_deg_func) export(endpoints) export(f_time_norm_focus) export(get_deg_func) +export(illparms) export(ilr) export(intervals) export(invilr) diff --git a/NEWS.md b/NEWS.md index 2aba0881..6b961e60 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,11 @@ +# mkin 1.1.2 + +- 'R/convergence.R': New generic to show convergence information with a method for 'mmin' objects. + +- 'R/illparms.R': New generic to show ill-defined parameters with methods for 'mkinfit' and 'mmkin' objects. + +- 'R/summary.mmkin.R': Summary method for mmkin objects. + # mkin 1.1.1 - 'R/{mkinmod,mkinpredict}.R: Store DLL information in mkinmod objects and use that information in mkinpredict to avoid a performance regression brought by a bugfix in R 4.2.x. Thanks to Tomas Kalibera for his analysis of the problem on the r-package-devel list and his suggestion on how to fix it. diff --git a/R/convergence.R b/R/convergence.R new file mode 100644 index 00000000..e75bb1b1 --- /dev/null +++ b/R/convergence.R @@ -0,0 +1,71 @@ +#' Method to get convergence information +#' +#' @param object The object to investigate +#' @param x The object to be printed +#' @param \dots For potential future extensions +#' @return For [mkinfit] objects, a character vector containing +#' For [mmkin] objects, an object of class 'convergence.mmkin' with a +#' suitable printing method. +#' @export +convergence <- function(object, ...) +{ + UseMethod("convergence", object) +} + +#' @rdname convergence +#' @export +#' @examples +#' \dontrun{ +#' fits <- mmkin( +#' c("SFO", "FOMC"), +#' list("FOCUS A" = FOCUS_2006_A, +#' "FOCUS B" = FOCUS_2006_C), +#' quiet = TRUE) +#' convergence(fits) +#' } +convergence.mmkin <- function(object, ...) { + all_summary_warnings <- character() + sww <- 0 # Counter for Shapiro-Wilks warnings + + result <- lapply(object, + function(fit) { + if (inherits(fit, "try-error")) return("E") + sw <- fit$summary_warnings + swn <- names(sw) + if (length(sw) > 0) { + if (any(grepl("S", swn))) { + sww <<- sww + 1 + swn <- gsub("S", paste0("S", sww), swn) + } + warnstring <- paste(swn, collapse = ", ") + names(sw) <- swn + all_summary_warnings <<- c(all_summary_warnings, sw) + return(warnstring) + } else { + return("OK") + } + }) + result <- unlist(result) + dim(result) <- dim(object) + dimnames(result) <- dimnames(object) + + u_swn <- unique(names(all_summary_warnings)) + attr(result, "unique_warnings") <- all_summary_warnings[u_swn] + class(result) <- "convergence.mmkin" + return(result) +} + +#' @rdname convergence +#' @export +print.convergence.mmkin <- function(x, ...) { + u_w <- attr(x, "unique_warnings") + attr(x, "unique_warnings") <- NULL + class(x) <- NULL + print(x, quote = FALSE) + cat("\n") + for (i in seq_along(u_w)) { + cat(names(u_w)[i], ": ", u_w[i], "\n", sep = "") + } + if (any(x == "OK")) cat("OK: No warnings\n") + if (any(x == "E")) cat("E: Error\n") +} diff --git a/R/illparms.R b/R/illparms.R new file mode 100644 index 00000000..f23f1cae --- /dev/null +++ b/R/illparms.R @@ -0,0 +1,62 @@ +#' Method to get the names of ill-defined parameters +#' +#' @param object The object to investigate +#' @param x The object to be printed +#' @param conf.level The confidence level for checking p values +#' @param \dots For potential future extensions +#' @return For [mkinfit] objects, a character vector of parameter names +#' For [mmkin] objects, an object of class 'illparms.mmkin' with a +#' suitable printing method. +#' @export +illparms <- function(object, ...) +{ + UseMethod("illparms", object) +} + +#' @rdname illparms +#' @export +#' @examples +#' fit <- mkinfit("FOMC", FOCUS_2006_A, quiet = TRUE) +#' illparms(fit) +illparms.mkinfit <- function(object, conf.level = 0.95, ...) { + p_values <- suppressWarnings(summary(object)$bpar[, "Pr(>t)"]) + na <- is.na(p_values) + failed <- p_values > 1 - conf.level + names(parms(object))[na | failed] +} + +#' @rdname illparms +#' @export +#' @examples +#' \dontrun{ +#' fits <- mmkin( +#' c("SFO", "FOMC"), +#' list("FOCUS A" = FOCUS_2006_A, +#' "FOCUS C" = FOCUS_2006_C), +#' quiet = TRUE) +#' illparms(fits) +#' } +illparms.mmkin <- function(object, conf.level = 0.95, ...) { + result <- lapply(object, + function(fit) { + if (inherits(fit, "try-error")) return("E") + ill <- illparms(fit, conf.level = conf.level) + if (length(ill) > 0) { + return(paste(ill, collapse = ", ")) + } else { + return("") + } + }) + result <- unlist(result) + dim(result) <- dim(object) + dimnames(result) <- dimnames(object) + class(result) <- "illparms.mmkin" + return(result) +} + +#' @rdname illparms +#' @export +print.illparms.mmkin <- function(x, ...) { + class(x) <- NULL + print(x, quote = FALSE) +} diff --git a/R/mmkin.R b/R/mmkin.R index fe04129e..247fd5fa 100644 --- a/R/mmkin.R +++ b/R/mmkin.R @@ -114,15 +114,18 @@ mmkin <- function(models = c("SFO", "FOMC", "DFOP"), datasets, return(res) } - if (is.null(cluster)) { - results <- parallel::mclapply(as.list(1:n.fits), fit_function, - mc.cores = cores, mc.preschedule = FALSE) - } else { - results <- parallel::parLapply(cluster, as.list(1:n.fits), fit_function) - } + fit_time <- system.time({ + if (is.null(cluster)) { + results <- parallel::mclapply(as.list(1:n.fits), fit_function, + mc.cores = cores, mc.preschedule = FALSE) + } else { + results <- parallel::parLapply(cluster, as.list(1:n.fits), fit_function) + } + }) attributes(results) <- attributes(fit_indices) attr(results, "call") <- call + attr(results, "time") <- fit_time class(results) <- "mmkin" return(results) } @@ -168,41 +171,7 @@ mmkin <- function(models = c("SFO", "FOMC", "DFOP"), datasets, print.mmkin <- function(x, ...) { cat(" object\n") cat("Status of individual fits:\n\n") - all_summary_warnings <- character() - sww <- 0 # Counter for Shapiro-Wilks warnings - - display <- lapply(x, - function(fit) { - if (inherits(fit, "try-error")) return("E") - sw <- fit$summary_warnings - swn <- names(sw) - if (length(sw) > 0) { - if (any(grepl("S", swn))) { - sww <<- sww + 1 - swn <- gsub("S", paste0("S", sww), swn) - } - warnstring <- paste(swn, collapse = ", ") - names(sw) <- swn - all_summary_warnings <<- c(all_summary_warnings, sw) - return(warnstring) - } else { - return("OK") - } - }) - display <- unlist(display) - dim(display) <- dim(x) - dimnames(display) <- dimnames(x) - print(display, quote = FALSE) - - cat("\n") - if (any(display == "OK")) cat("OK: No warnings\n") - if (any(display == "E")) cat("E: Error\n") - u_swn <- unique(names(all_summary_warnings)) - u_w <- all_summary_warnings[u_swn] - for (i in seq_along(u_w)) { - cat(names(u_w)[i], ": ", u_w[i], "\n", sep = "") - } - + print(convergence(x)) } #' @export diff --git a/R/summary.mmkin.R b/R/summary.mmkin.R new file mode 100644 index 00000000..5f4a048b --- /dev/null +++ b/R/summary.mmkin.R @@ -0,0 +1,56 @@ +#' Summary method for class "mmkin" +#' +#' Shows convergence information on the [mkinfit] objects contained in the object +#' and gives an overview of ill-defined parameters calculated by [illparms]. +#' +#' @param object an object of class [mmkin] +#' @param x an object of class \code{summary.mmkin}. +#' @param conf.level confidence level for testing parameters +#' @param digits number of digits to use for printing +#' @param \dots optional arguments passed to methods like \code{print}. +#' @examples +#' +#' fits <- mmkin( +#' c("SFO", "FOMC"), +#' list("FOCUS A" = FOCUS_2006_A, +#' "FOCUS C" = FOCUS_2006_C), +#' quiet = TRUE, cores = 1) +#' summary(fits) +#' +#' @export +summary.mmkin <- function(object, conf.level = 0.95, ...) { + + ans <- list( + err_mod = object[[1, 1]]$err_mod, + time = attr(object, "time"), + illparms = illparms(object), + convergence = convergence(object) + ) + + class(ans) <- c("summary.mmkin") + return(ans) +} + +#' @rdname summary.mmkin +#' @export +print.summary.mmkin <- function(x, digits = max(3, getOption("digits") - 3), ...) { + if (!is.null(x$err_mod)) { + cat("Error model: ") + cat(switch(x$err_mod, + const = "Constant variance", + obs = "Variance unique to each observed variable", + tc = "Two-component variance function"), "\n") + } + cat("Fitted in", x$time[["elapsed"]], "s\n") + + cat("\nConvergence:\n") + print(x$convergence) + + if (any(x$illparms != "")) { + cat("\nIll-defined parameters:\n") + print(x$illparms) + } + + invisible(x) +} + diff --git a/build.log b/build.log index 237294e7..5ac21b0d 100644 --- a/build.log +++ b/build.log @@ -5,5 +5,5 @@ * creating vignettes ... OK * checking for LF line-endings in source and make files and shell scripts * checking for empty or unneeded directories -* building ‘mkin_1.1.1.tar.gz’ +* building ‘mkin_1.1.2.tar.gz’ diff --git a/check.log b/check.log index 807e2f33..8fce3fd1 100644 --- a/check.log +++ b/check.log @@ -1,11 +1,11 @@ * using log directory ‘/home/jranke/git/mkin/mkin.Rcheck’ -* using R version 4.1.3 (2022-03-10) +* using R version 4.2.1 (2022-06-23) * using platform: x86_64-pc-linux-gnu (64-bit) * using session charset: UTF-8 * using options ‘--no-tests --as-cran’ * checking for file ‘mkin/DESCRIPTION’ ... OK * checking extension type ... Package -* this is package ‘mkin’ version ‘1.1.0’ +* this is package ‘mkin’ version ‘1.1.2’ * package encoding: UTF-8 * checking CRAN incoming feasibility ... Note_to_CRAN_maintainers Maintainer: ‘Johannes Ranke ’ @@ -64,6 +64,7 @@ Maintainer: ‘Johannes Ranke ’ * checking package vignettes in ‘inst/doc’ ... OK * checking re-building of vignette outputs ... OK * checking PDF version of manual ... OK +* checking HTML version of manual ... OK * checking for non-standard things in the check directory ... OK * checking for detritus in the temp directory ... OK * DONE diff --git a/man/convergence.Rd b/man/convergence.Rd new file mode 100644 index 00000000..635eb9ae --- /dev/null +++ b/man/convergence.Rd @@ -0,0 +1,39 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/convergence.R +\name{convergence} +\alias{convergence} +\alias{convergence.mmkin} +\alias{print.convergence.mmkin} +\title{Method to get convergence information} +\usage{ +convergence(object, ...) + +\method{convergence}{mmkin}(object, ...) + +\method{print}{convergence.mmkin}(x, ...) +} +\arguments{ +\item{object}{The object to investigate} + +\item{\dots}{For potential future extensions} + +\item{x}{The object to be printed} +} +\value{ +For \link{mkinfit} objects, a character vector containing +For \link{mmkin} objects, an object of class 'convergence.mmkin' with a +suitable printing method. +} +\description{ +Method to get convergence information +} +\examples{ +\dontrun{ +fits <- mmkin( + c("SFO", "FOMC"), + list("FOCUS A" = FOCUS_2006_A, + "FOCUS B" = FOCUS_2006_C), + quiet = TRUE) +convergence(fits) +} +} diff --git a/man/illparms.Rd b/man/illparms.Rd new file mode 100644 index 00000000..7f70229d --- /dev/null +++ b/man/illparms.Rd @@ -0,0 +1,46 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/illparms.R +\name{illparms} +\alias{illparms} +\alias{illparms.mkinfit} +\alias{illparms.mmkin} +\alias{print.illparms.mmkin} +\title{Method to get the names of ill-defined parameters} +\usage{ +illparms(object, ...) + +\method{illparms}{mkinfit}(object, conf.level = 0.95, ...) + +\method{illparms}{mmkin}(object, conf.level = 0.95, ...) + +\method{print}{illparms.mmkin}(x, ...) +} +\arguments{ +\item{object}{The object to investigate} + +\item{\dots}{For potential future extensions} + +\item{conf.level}{The confidence level for checking p values} + +\item{x}{The object to be printed} +} +\value{ +For \link{mkinfit} objects, a character vector of parameter names +For \link{mmkin} objects, an object of class 'illparms.mmkin' with a +suitable printing method. +} +\description{ +Method to get the names of ill-defined parameters +} +\examples{ +fit <- mkinfit("FOMC", FOCUS_2006_A, quiet = TRUE) +illparms(fit) +\dontrun{ +fits <- mmkin( + c("SFO", "FOMC"), + list("FOCUS A" = FOCUS_2006_A, + "FOCUS C" = FOCUS_2006_C), + quiet = TRUE) +illparms(fits) +} +} diff --git a/man/summary.mkinfit.Rd b/man/summary.mkinfit.Rd index 24991d71..b6c1fb87 100644 --- a/man/summary.mkinfit.Rd +++ b/man/summary.mkinfit.Rd @@ -60,7 +60,7 @@ values. } \examples{ - summary(mkinfit(mkinmod(parent = mkinsub("SFO")), FOCUS_2006_A, quiet = TRUE)) + summary(mkinfit("SFO", FOCUS_2006_A, quiet = TRUE)) } \references{ diff --git a/man/summary.mmkin.Rd b/man/summary.mmkin.Rd new file mode 100644 index 00000000..69245621 --- /dev/null +++ b/man/summary.mmkin.Rd @@ -0,0 +1,36 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/summary.mmkin.R +\name{summary.mmkin} +\alias{summary.mmkin} +\alias{print.summary.mmkin} +\title{Summary method for class "mmkin"} +\usage{ +\method{summary}{mmkin}(object, conf.level = 0.95, ...) + +\method{print}{summary.mmkin}(x, digits = max(3, getOption("digits") - 3), ...) +} +\arguments{ +\item{object}{an object of class \link{mmkin}} + +\item{conf.level}{confidence level for testing parameters} + +\item{\dots}{optional arguments passed to methods like \code{print}.} + +\item{x}{an object of class \code{summary.mmkin}.} + +\item{digits}{number of digits to use for printing} +} +\description{ +Shows convergence information on the \link{mkinfit} objects contained in the object +and gives an overview of ill-defined parameters calculated by \link{illparms}. +} +\examples{ + +fits <- mmkin( + c("SFO", "FOMC"), + list("FOCUS A" = FOCUS_2006_A, + "FOCUS C" = FOCUS_2006_C), + quiet = TRUE, cores = 1) + summary(fits) + +} diff --git a/summary_parent_FOCUS_2006.txt b/summary_parent_FOCUS_2006.txt new file mode 100644 index 00000000..d31bd869 --- /dev/null +++ b/summary_parent_FOCUS_2006.txt @@ -0,0 +1,20 @@ +Error model: Constant variance +Fitted in test time 0 s + +Convergence: + dataset +model FOCUS_A FOCUS_C FOCUS_D + SFO OK OK OK + FOMC OK OK OK + DFOP OK OK OK + HS OK OK OK + +OK: No warnings + +Ill-defined parameters: + dataset +model FOCUS_A FOCUS_C FOCUS_D + SFO + FOMC parent_0, alpha, beta, sigma alpha, beta + DFOP g g + HS k2 diff --git a/test.log b/test.log index 55a56153..03755ce5 100644 --- a/test.log +++ b/test.log @@ -3,20 +3,20 @@ Loading required package: parallel ℹ Testing mkin ✔ | F W S OK | Context ✔ | 5 | AIC calculation -✔ | 5 | Analytical solutions for coupled models [3.2s] +✔ | 5 | Analytical solutions for coupled models [3.4s] ✔ | 5 | Calculation of Akaike weights ✔ | 3 | Export dataset for reading into CAKE ✔ | 12 | Confidence intervals and p-values [1.0s] -✔ | 1 12 | Dimethenamid data from 2018 [32.1s] +✔ | 1 12 | Dimethenamid data from 2018 [34.2s] ──────────────────────────────────────────────────────────────────────────────── Skip (test_dmta.R:98:3): Different backends get consistent results for SFO-SFO3+, dimethenamid data Reason: Fitting this ODE model with saemix takes about 15 minutes on my system ──────────────────────────────────────────────────────────────────────────────── -✔ | 14 | Error model fitting [4.8s] +✔ | 14 | Error model fitting [5.1s] ✔ | 5 | Time step normalisation ✔ | 4 | Calculation of FOCUS chi2 error levels [0.6s] ✔ | 14 | Results for FOCUS D established in expertise for UBA (Ranke 2014) [0.8s] -✔ | 4 | Test fitting the decline of metabolites from their maximum [0.3s] +✔ | 4 | Test fitting the decline of metabolites from their maximum [0.4s] ✔ | 1 | Fitting the logistic model [0.2s] ✔ | 1 12 | Nonlinear mixed-effects models [0.2s] ──────────────────────────────────────────────────────────────────────────────── @@ -27,42 +27,25 @@ Reason: Fitting with saemix takes around 10 minutes when using deSolve ✔ | 10 | Special cases of mkinfit calls [0.4s] ✔ | 3 | mkinfit features [0.7s] ✔ | 8 | mkinmod model generation and printing [0.2s] -✔ | 3 | Model predictions with mkinpredict [0.4s] -✔ | 16 | Evaluations according to 2015 NAFTA guidance [1.5s] -✔ | 9 | Nonlinear mixed-effects models with nlme [8.1s] -✖ | 2 14 | Plotting [10.5s] -──────────────────────────────────────────────────────────────────────────────── -Failure (test_plot.R:56:3): Plotting mkinfit, mmkin and mixed model objects is reproducible -Snapshot of `testcase` to 'plot/mixed-model-fit-for-nlme-object.svg' has changed -Run `testthat::snapshot_review('plot/')` to review changes -Backtrace: - 1. vdiffr::expect_doppelganger(...) - at test_plot.R:56:2 - 3. testthat::expect_snapshot_file(...) - -Failure (test_plot.R:64:3): Plotting mkinfit, mmkin and mixed model objects is reproducible -Snapshot of `testcase` to 'plot/mixed-model-fit-for-saem-object-with-mkin-transformations.svg' has changed -Run `testthat::snapshot_review('plot/')` to review changes -Backtrace: - 1. vdiffr::expect_doppelganger(...) - at test_plot.R:64:2 - 3. testthat::expect_snapshot_file(...) -──────────────────────────────────────────────────────────────────────────────── +✔ | 3 | Model predictions with mkinpredict [0.3s] +✔ | 16 | Evaluations according to 2015 NAFTA guidance [1.7s] +✔ | 9 | Nonlinear mixed-effects models with nlme [8.5s] +✔ | 16 | Plotting [10.2s] ✔ | 4 | Residuals extracted from mkinfit models -✔ | 25 | saemix parent models [171.7s] -✔ | 2 | Complex test case from Schaefer et al. (2007) Piacenza paper [1.3s] +✔ | 25 | saemix parent models [175.0s] +✔ | 2 | Complex test case from Schaefer et al. (2007) Piacenza paper [1.4s] ✔ | 7 | Fitting the SFORB model [3.6s] ✔ | 1 | Summaries of old mkinfit objects -✔ | 4 | Summary [0.1s] +✔ | 5 | Summary [0.2s] ✔ | 4 | Results for synthetic data established in expertise for UBA (Ranke 2014) [2.1s] -✔ | 9 | Hypothesis tests [7.7s] -✔ | 4 | Calculation of maximum time weighted average concentrations (TWAs) [2.3s] +✔ | 9 | Hypothesis tests [7.8s] +✔ | 4 | Calculation of maximum time weighted average concentrations (TWAs) [2.2s] ══ Results ═════════════════════════════════════════════════════════════════════ -Duration: 254.3 s +Duration: 260.5 s ── Skipped tests ────────────────────────────────────────────────────────────── • Fitting this ODE model with saemix takes about 15 minutes on my system (1) • Fitting with saemix takes around 10 minutes when using deSolve (1) -[ FAIL 2 | WARN 0 | SKIP 2 | PASS 222 ] +[ FAIL 0 | WARN 0 | SKIP 2 | PASS 225 ] diff --git a/tests/testthat/_snaps/plot/mixed-model-fit-for-nlme-object.new.svg b/tests/testthat/_snaps/plot/mixed-model-fit-for-nlme-object.new.svg deleted file mode 100644 index 051b46b1..00000000 --- a/tests/testthat/_snaps/plot/mixed-model-fit-for-nlme-object.new.svg +++ /dev/null @@ -1,1367 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Population -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 - - - - - - - - - - - - - - - - - -0 -20 -40 -60 -80 -100 -120 - - - - - - - -0 -20 -40 -60 -80 -100 - - - - - - - - -Time -Residues parent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -0 -20 -40 -60 -80 -100 - - - - - - - - --3 --2 --1 -0 -1 -2 -3 - - - - - - - - -Predicted -Standardized residual - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/testthat/_snaps/plot/mixed-model-fit-for-nlme-object.svg b/tests/testthat/_snaps/plot/mixed-model-fit-for-nlme-object.svg index 541bf36d..051b46b1 100644 --- a/tests/testthat/_snaps/plot/mixed-model-fit-for-nlme-object.svg +++ b/tests/testthat/_snaps/plot/mixed-model-fit-for-nlme-object.svg @@ -892,8 +892,8 @@ - - + + @@ -1158,7 +1158,7 @@ - + diff --git a/tests/testthat/_snaps/plot/mixed-model-fit-for-saem-object-with-mkin-transformations.new.svg b/tests/testthat/_snaps/plot/mixed-model-fit-for-saem-object-with-mkin-transformations.new.svg deleted file mode 100644 index 375ab089..00000000 --- a/tests/testthat/_snaps/plot/mixed-model-fit-for-saem-object-with-mkin-transformations.new.svg +++ /dev/null @@ -1,2502 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Population -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 - - - - - - - - - - - - - - - - - -0 -20 -40 -60 -80 -100 -120 - - - - - - - -0 -20 -40 -60 -80 -100 - - - - - - - - -Time -Residues parent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -0 -20 -40 -60 -80 -100 - - - - - - - - --3 --2 --1 -0 -1 -2 -3 - - - - - - - - -Predicted -Standardized residual - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -0 -20 -40 -60 -80 -100 -120 - - - - - - -0 -10 -20 -30 -40 - - - - - - - - -Time -Residues m1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -0 -10 -20 -30 -40 - - - - - - - - --3 --2 --1 -0 -1 -2 -3 - - - - - - - - -Predicted -Standardized residual - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/testthat/_snaps/plot/mixed-model-fit-for-saem-object-with-mkin-transformations.svg b/tests/testthat/_snaps/plot/mixed-model-fit-for-saem-object-with-mkin-transformations.svg index 84a69d24..375ab089 100644 --- a/tests/testthat/_snaps/plot/mixed-model-fit-for-saem-object-with-mkin-transformations.svg +++ b/tests/testthat/_snaps/plot/mixed-model-fit-for-saem-object-with-mkin-transformations.svg @@ -156,7 +156,7 @@ - + @@ -175,7 +175,7 @@ - + @@ -212,7 +212,7 @@ - + @@ -249,7 +249,7 @@ - + @@ -268,7 +268,7 @@ - + @@ -287,7 +287,7 @@ - + @@ -342,7 +342,7 @@ - + @@ -415,7 +415,7 @@ - + @@ -470,7 +470,7 @@ - + @@ -525,7 +525,7 @@ - + @@ -562,7 +562,7 @@ - + @@ -617,7 +617,7 @@ - + @@ -672,7 +672,7 @@ - + @@ -709,7 +709,7 @@ - + @@ -728,8 +728,8 @@ - - + + @@ -739,34 +739,34 @@ - + - - - - - + + + + + 0 -20 -40 -60 -80 -100 - - - - +20 +40 +60 +80 +100 + + + + - - - --3 --2 --1 + + + +-3 +-2 +-1 0 -1 -2 -3 +1 +2 +3 @@ -780,582 +780,582 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1419,7 +1419,7 @@ - + @@ -1436,7 +1436,7 @@ - + @@ -1469,7 +1469,7 @@ - + @@ -1502,7 +1502,7 @@ - + @@ -1519,7 +1519,7 @@ - + @@ -1536,7 +1536,7 @@ - + @@ -1585,7 +1585,7 @@ - + @@ -1650,7 +1650,7 @@ - + @@ -1699,7 +1699,7 @@ - + @@ -1748,7 +1748,7 @@ - + @@ -1781,7 +1781,7 @@ - + @@ -1830,7 +1830,7 @@ - + @@ -1879,7 +1879,7 @@ - + @@ -1912,7 +1912,7 @@ - + @@ -1929,8 +1929,8 @@ - - + + @@ -1940,32 +1940,32 @@ - + - - - - + + + + 0 -10 -20 -30 -40 - - - - +10 +20 +30 +40 + + + + - - - --3 --2 --1 + + + +-3 +-2 +-1 0 -1 -2 -3 +1 +2 +3 @@ -1979,518 +1979,518 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/testthat/summary_parent_FOCUS_2006.txt b/tests/testthat/summary_parent_FOCUS_2006.txt new file mode 100644 index 00000000..d31bd869 --- /dev/null +++ b/tests/testthat/summary_parent_FOCUS_2006.txt @@ -0,0 +1,20 @@ +Error model: Constant variance +Fitted in test time 0 s + +Convergence: + dataset +model FOCUS_A FOCUS_C FOCUS_D + SFO OK OK OK + FOMC OK OK OK + DFOP OK OK OK + HS OK OK OK + +OK: No warnings + +Ill-defined parameters: + dataset +model FOCUS_A FOCUS_C FOCUS_D + SFO + FOMC parent_0, alpha, beta, sigma alpha, beta + DFOP g g + HS k2 diff --git a/tests/testthat/test_summary.R b/tests/testthat/test_summary.R index 5cf6ac6b..a31d3bae 100644 --- a/tests/testthat/test_summary.R +++ b/tests/testthat/test_summary.R @@ -46,6 +46,12 @@ test_that("Summaries are reproducible", { expect_known_output(print(test_summary_3), "summary_DFOP_FOCUS_D_deSolve.txt") }) +test_that("Summaries of mmkin objects are reproducible", { + test_summary <- summary(fits) + test_summary$time <- c(elapsed = "test time 0") + expect_known_output(print(test_summary), "summary_parent_FOCUS_2006.txt") +}) + test_that("A fit generated with mkin 0.9.48.1 can be summarised", { # Generated with mkin 0.9.48.1 # SFO_SFO <- mkinmod(parent = list(type = "SFO", to = "m1"), -- cgit v1.2.1