From f606838c5310f365eea1c0d6421f5c3636a4dc79 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Tue, 8 Dec 2020 22:08:38 +0100 Subject: mixed.mmkin and test coverage --- NAMESPACE | 3 + NEWS.md | 2 + R/mixed.mmkin.R | 101 + R/mkinfit.R | 4 +- R/plot.mixed.mmkin.R | 61 +- R/saem.R | 4 +- R/summary.saem.mmkin.R | 75 +- check.log | 9 +- man/mixed.Rd | 69 + man/mkinmod.Rd | 4 +- man/plot.mixed.mmkin.Rd | 2 +- man/saem.Rd | 26 +- test.log | 40 +- .../plotting/mixed-model-fit-for-mmkin-object.svg | 2482 ++++++++++++++++++++ .../plotting/mixed-model-fit-for-nlme-object.svg | 2482 ++++++++++++++++++++ ...t-for-saem-object-with-mkin-transformations.svg | 2482 ++++++++++++++++++++ ...for-saem-object-with-saemix-transformations.svg | 2482 ++++++++++++++++++++ tests/testthat/setup_script.R | 64 + tests/testthat/test_AIC.R | 1 + tests/testthat/test_confidence.R | 17 +- tests/testthat/test_mixed.R | 35 + tests/testthat/test_nafta.R | 2 - tests/testthat/test_plot.R | 10 +- tests/testthat/test_saem.R | 118 + 24 files changed, 10487 insertions(+), 88 deletions(-) create mode 100644 R/mixed.mmkin.R create mode 100644 man/mixed.Rd create mode 100644 tests/figs/plotting/mixed-model-fit-for-mmkin-object.svg create mode 100644 tests/figs/plotting/mixed-model-fit-for-nlme-object.svg create mode 100644 tests/figs/plotting/mixed-model-fit-for-saem-object-with-mkin-transformations.svg create mode 100644 tests/figs/plotting/mixed-model-fit-for-saem-object-with-saemix-transformations.svg create mode 100644 tests/testthat/test_mixed.R create mode 100644 tests/testthat/test_saem.R diff --git a/NAMESPACE b/NAMESPACE index 6ff00109..f2497283 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -12,6 +12,7 @@ S3method(loftest,mkinfit) S3method(logLik,mkinfit) S3method(lrtest,mkinfit) S3method(lrtest,mmkin) +S3method(mixed,mmkin) S3method(mkinpredict,mkinfit) S3method(mkinpredict,mkinmod) S3method(nlme,mmkin) @@ -22,6 +23,7 @@ S3method(plot,mixed.mmkin) S3method(plot,mkinfit) S3method(plot,mmkin) S3method(plot,nafta) +S3method(print,mixed.mmkin) S3method(print,mkinds) S3method(print,mkindsg) S3method(print,mkinmod) @@ -65,6 +67,7 @@ export(max_twa_hs) export(max_twa_parent) export(max_twa_sfo) export(mean_degparms) +export(mixed) export(mkin_long_to_wide) export(mkin_wide_to_long) export(mkinds) diff --git a/NEWS.md b/NEWS.md index 0fd78b59..ac67688d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # mkin 0.9.50.4 (unreleased) +- 'mixed.mmkin' New container for mmkin objects for plotting with the 'plot.mixed.mmkin' method + - 'mkinmod' models gain arguments 'name' and 'dll_dir' which, in conjunction with a current version of the 'inline' package, make it possible to still use the DLL used for fast ODE solutions with 'deSolve' after saving and restoring the 'mkinmod' object. - 'f_norm_temp_focus' generic function to normalise time intervals using the FOCUS method, with methods for numeric vectors and 'mkindsg' objects diff --git a/R/mixed.mmkin.R b/R/mixed.mmkin.R new file mode 100644 index 00000000..6fe5130d --- /dev/null +++ b/R/mixed.mmkin.R @@ -0,0 +1,101 @@ +#' Create a mixed effects model from an mmkin row object +#' +#' @param object An [mmkin] row object +#' @param method The method to be used +#' @param \dots Currently not used +#' @examples +#' sampling_times = c(0, 1, 3, 7, 14, 28, 60, 90, 120) +#' n_biphasic <- 8 +#' err_1 = list(const = 1, prop = 0.07) +#' +#' DFOP_SFO <- mkinmod( +#' parent = mkinsub("DFOP", "m1"), +#' m1 = mkinsub("SFO"), +#' quiet = TRUE) +#' +#' set.seed(123456) +#' log_sd <- 0.3 +#' syn_biphasic_parms <- as.matrix(data.frame( +#' k1 = rlnorm(n_biphasic, log(0.05), log_sd), +#' k2 = rlnorm(n_biphasic, log(0.01), log_sd), +#' g = plogis(rnorm(n_biphasic, 0, log_sd)), +#' f_parent_to_m1 = plogis(rnorm(n_biphasic, 0, log_sd)), +#' k_m1 = rlnorm(n_biphasic, log(0.002), log_sd))) +#' +#' ds_biphasic_mean <- lapply(1:n_biphasic, +#' function(i) { +#' mkinpredict(DFOP_SFO, syn_biphasic_parms[i, ], +#' c(parent = 100, m1 = 0), sampling_times) +#' } +#' ) +#' +#' set.seed(123456L) +#' ds_biphasic <- lapply(ds_biphasic_mean, function(ds) { +#' add_err(ds, +#' sdfunc = function(value) sqrt(err_1$const^2 + value^2 * err_1$prop^2), +#' n = 1, secondary = "m1")[[1]] +#' }) +#' +#' \dontrun{ +#' f_mmkin <- mmkin(list("DFOP-SFO" = DFOP_SFO), ds_biphasic, error_model = "tc", quiet = TRUE) +#' +#' f_mixed <- mixed(f_mmkin) +#' print(f_mixed) +#' plot(f_mixed) +#' } +#' @export +mixed <- function(object, ...) { + UseMethod("mixed") +} + +#' @export +#' @rdname mixed +mixed.mmkin <- function(object, method = c("none"), ...) { + if (nrow(object) > 1) stop("Only row objects allowed") + + method <- match.arg(method) + if (method == "default") method = c("naive", "nlme") + + ds_names <- colnames(object) + res <- list(mmkin = object, mkinmod = object[[1]]$mkinmod) + + if (method[1] == "none") { + ds_list <- lapply(object, + function(x) x$data[c("variable", "time", "observed", "predicted", "residual")]) + + names(ds_list) <- ds_names + res$data <- purrr::map_dfr(ds_list, function(x) x, .id = "ds") + names(res$data)[1:4] <- c("ds", "name", "time", "value") + res$data$name <- as.character(res$data$name) + res$data$ds <- ordered(res$data$ds, levels = unique(res$data$ds)) + standardized <- unlist(lapply(object, residuals, standardized = TRUE)) + res$data$std <- res$data$residual / standardized + res$data$standardized <- standardized + + class(res) <- c("mixed.mmkin") + return(res) + } +} + +#' @export +#' @rdname mixed +#' @param x A mixed.mmkin object to print +#' @param digits Number of digits to use for printing. +print.mixed.mmkin <- function(x, digits = max(3, getOption("digits") - 3), ...) { + cat("Kinetic model fitted by nonlinear regression to each dataset" ) + cat("\nStructural model:\n") + diffs <- x$mmkin[[1]]$mkinmod$diffs + nice_diffs <- gsub("^(d.*) =", "\\1/dt =", diffs) + writeLines(strwrap(nice_diffs, exdent = 11)) + cat("\nData:\n") + cat(nrow(x$data), "observations of", + length(unique(x$data$name)), "variable(s) grouped in", + length(unique(x$data$ds)), "datasets\n\n") + + print(x$mmkin) + + cat("\nMean fitted parameters:\n") + print(mean_degparms(x$mmkin)) + + invisible(x) +} diff --git a/R/mkinfit.R b/R/mkinfit.R index a6efc858..c659e446 100644 --- a/R/mkinfit.R +++ b/R/mkinfit.R @@ -885,8 +885,8 @@ mkinfit <- function(mkinmod, observed, fit$rss <- function(P) cost_function(P, OLS = TRUE, update_data = FALSE) # Log-likelihood with possibility to fix degparms or errparms - fit$ll <- function(P, fixed_degparms = FALSE, fixed_errparms = FALSE) { - - cost_function(P, trans = FALSE, fixed_degparms = fixed_degparms, + fit$ll <- function(P, fixed_degparms = FALSE, fixed_errparms = FALSE, trans = FALSE) { + - cost_function(P, trans = trans, fixed_degparms = fixed_degparms, fixed_errparms = fixed_errparms, OLS = FALSE, update_data = FALSE) } diff --git a/R/plot.mixed.mmkin.R b/R/plot.mixed.mmkin.R index d8a1c2ac..db29376e 100644 --- a/R/plot.mixed.mmkin.R +++ b/R/plot.mixed.mmkin.R @@ -2,7 +2,7 @@ utils::globalVariables("ds") #' Plot predictions from a fitted nonlinear mixed model obtained via an mmkin row object #' -#' @param x An object of class [saem.mmkin] or [nlme.mmkin] +#' @param x An object of class [mixed.mmkin], [saem.mmkin] or [nlme.mmkin] #' @param i A numeric index to select datasets for which to plot the individual predictions, #' in case plots get too large #' @inheritParams plot.mkinfit @@ -63,31 +63,43 @@ plot.mixed.mmkin <- function(x, fit_1 <- x$mmkin[[1]] ds_names <- colnames(x$mmkin) + backtransform = TRUE + + if (identical(class(x), "mixed.mmkin")) { + degparms_pop <- mean_degparms(x$mmkin) + + degparms_tmp <- parms(x$mmkin, transformed = TRUE) + degparms_i <- as.data.frame(t(degparms_tmp[setdiff(rownames(degparms_tmp), names(fit_1$errparms)), ])) + residual_type = ifelse(standardized, "standardized", "residual") + residuals <- x$data[[residual_type]] + } + if (inherits(x, "nlme.mmkin")) { - degparms_optim <- coefficients(x) + degparms_i <- coefficients(x) degparms_pop <- nlme::fixef(x) residuals <- residuals(x, type = ifelse(standardized, "pearson", "response")) } if (inherits(x, "saem.mmkin")) { - degparms_optim <- saemix::psi(x$so) - rownames(degparms_optim) <- ds_names - degparms_optim_names <- setdiff(names(fit_1$par), names(fit_1$errparms)) - colnames(degparms_optim) <- degparms_optim_names - residual_type = ifelse(standardized, "residual", "standardized") + if (x$transformations == "saemix") backtransform = FALSE + degparms_i <- saemix::psi(x$so) + rownames(degparms_i) <- ds_names + degparms_i_names <- setdiff(x$so@results@name.fixed, names(fit_1$errparms)) + colnames(degparms_i) <- degparms_i_names + residual_type = ifelse(standardized, "standardized", "residual") residuals <- x$data[[residual_type]] degparms_pop <- x$so@results@fixed.effects - names(degparms_pop) <- degparms_optim_names + names(degparms_pop) <- degparms_i_names } degparms_fixed <- fit_1$fixed$value names(degparms_fixed) <- rownames(fit_1$fixed) - degparms_all <- cbind(as.matrix(degparms_optim), - matrix(rep(degparms_fixed, nrow(degparms_optim)), + degparms_all <- cbind(as.matrix(degparms_i), + matrix(rep(degparms_fixed, nrow(degparms_i)), ncol = length(degparms_fixed), - nrow = nrow(degparms_optim), byrow = TRUE)) - degparms_all_names <- c(names(degparms_optim), names(degparms_fixed)) + nrow = nrow(degparms_i), byrow = TRUE)) + degparms_all_names <- c(names(degparms_i), names(degparms_fixed)) colnames(degparms_all) <- degparms_all_names degparms_all_pop <- c(degparms_pop, degparms_fixed) @@ -106,10 +118,14 @@ plot.mixed.mmkin <- function(x, pred_ds <- purrr::map_dfr(i, function(ds_i) { odeparms_trans <- degparms_all[ds_i, odeparms_names] names(odeparms_trans) <- odeparms_names # needed if only one odeparm - odeparms <- backtransform_odeparms(odeparms_trans, - x$mkinmod, - transform_rates = fit_1$transform_rates, - transform_fractions = fit_1$transform_fractions) + if (backtransform) { + odeparms <- backtransform_odeparms(odeparms_trans, + x$mkinmod, + transform_rates = fit_1$transform_rates, + transform_fractions = fit_1$transform_fractions) + } else { + odeparms <- odeparms_trans + } odeini <- degparms_all[ds_i, odeini_names] names(odeini) <- gsub("_0", "", odeini_names) @@ -121,10 +137,15 @@ plot.mixed.mmkin <- function(x, }) odeparms_pop_trans <- degparms_all_pop[odeparms_names] - odeparms_pop <- backtransform_odeparms(odeparms_pop_trans, - x$mkinmod, - transform_rates = fit_1$transform_rates, - transform_fractions = fit_1$transform_fractions) + + if (backtransform) { + odeparms_pop <- backtransform_odeparms(odeparms_pop_trans, + x$mkinmod, + transform_rates = fit_1$transform_rates, + transform_fractions = fit_1$transform_fractions) + } else { + odeparms_pop <- odeparms_pop_trans + } odeini_pop <- degparms_all_pop[odeini_names] names(odeini_pop) <- gsub("_0", "", odeini_names) diff --git a/R/saem.R b/R/saem.R index e5634ac7..88b8e172 100644 --- a/R/saem.R +++ b/R/saem.R @@ -92,7 +92,7 @@ utils::globalVariables(c("predicted", "std")) #' plot(f_saem_fomc) #' } #' @export -saem <- function(object, control, ...) UseMethod("saem") +saem <- function(object, ...) UseMethod("saem") #' @rdname saem #' @export @@ -104,9 +104,11 @@ saem.mmkin <- function(object, cores = 1, verbose = FALSE, suppressPlot = TRUE, quiet = FALSE, ...) { + transformations <- match.arg(transformations) m_saemix <- saemix_model(object, cores = cores, verbose = verbose, solution_type = solution_type, transformations = transformations, ...) d_saemix <- saemix_data(object, verbose = verbose) + if (suppressPlot) { # We suppress the log-likelihood curve that saemix currently # produces at the end of the fit by plotting to a file diff --git a/R/summary.saem.mmkin.R b/R/summary.saem.mmkin.R index 97f9f2da..27c2ce6c 100644 --- a/R/summary.saem.mmkin.R +++ b/R/summary.saem.mmkin.R @@ -89,9 +89,42 @@ summary.saem.mmkin <- function(object, data = FALSE, verbose = FALSE, distimes = confint_trans <- as.matrix(conf.int[pnames, c("estimate", "lower", "upper")]) colnames(confint_trans)[1] <- "est." - bp <- backtransform_odeparms(confint_trans[, "est."], object$mkinmod, - object$transform_rates, object$transform_fractions) - bpnames <- names(bp) + if (object$transformations == "mkin") { + bp <- backtransform_odeparms(confint_trans[, "est."], object$mkinmod, + object$transform_rates, object$transform_fractions) + bpnames <- names(bp) + + # Transform boundaries of CI for one parameter at a time, + # with the exception of sets of formation fractions (single fractions are OK). + f_names_skip <- character(0) + for (box in mod_vars) { # Figure out sets of fractions to skip + f_names <- grep(paste("^f", box, sep = "_"), pnames, value = TRUE) + n_paths <- length(f_names) + if (n_paths > 1) f_names_skip <- c(f_names_skip, f_names) + } + + confint_back <- matrix(NA, nrow = length(bp), ncol = 3, + dimnames = list(bpnames, colnames(confint_trans))) + confint_back[, "est."] <- bp + + for (pname in pnames) { + if (!pname %in% f_names_skip) { + par.lower <- confint_trans[pname, "lower"] + par.upper <- confint_trans[pname, "upper"] + names(par.lower) <- names(par.upper) <- pname + bpl <- backtransform_odeparms(par.lower, object$mkinmod, + object$transform_rates, + object$transform_fractions) + bpu <- backtransform_odeparms(par.upper, object$mkinmod, + object$transform_rates, + object$transform_fractions) + confint_back[names(bpl), "lower"] <- bpl + confint_back[names(bpu), "upper"] <- bpu + } + } + } else { + confint_back <- confint_trans + } # Correlation of fixed effects (inspired by summary.nlme) varFix <- vcov(object$so)[1:np, 1:np] @@ -111,34 +144,6 @@ summary.saem.mmkin <- function(object, data = FALSE, verbose = FALSE, distimes = confint_errmod <- as.matrix(conf.int[enames, c("estimate", "lower", "upper")]) colnames(confint_errmod)[1] <- "est." - # Transform boundaries of CI for one parameter at a time, - # with the exception of sets of formation fractions (single fractions are OK). - f_names_skip <- character(0) - for (box in mod_vars) { # Figure out sets of fractions to skip - f_names <- grep(paste("^f", box, sep = "_"), pnames, value = TRUE) - n_paths <- length(f_names) - if (n_paths > 1) f_names_skip <- c(f_names_skip, f_names) - } - - confint_back <- matrix(NA, nrow = length(bp), ncol = 3, - dimnames = list(bpnames, colnames(confint_trans))) - confint_back[, "est."] <- bp - - for (pname in pnames) { - if (!pname %in% f_names_skip) { - par.lower <- confint_trans[pname, "lower"] - par.upper <- confint_trans[pname, "upper"] - names(par.lower) <- names(par.upper) <- pname - bpl <- backtransform_odeparms(par.lower, object$mkinmod, - object$transform_rates, - object$transform_fractions) - bpu <- backtransform_odeparms(par.upper, object$mkinmod, - object$transform_rates, - object$transform_fractions) - confint_back[names(bpl), "lower"] <- bpl - confint_back[names(bpu), "upper"] <- bpu - } - } object$confint_trans <- confint_trans object$confint_ranef <- confint_ranef @@ -213,7 +218,7 @@ print.summary.saem.mmkin <- function(x, digits = max(3, getOption("digits") - 3) print(data.frame(AIC = x$AIC, BIC = x$BIC, logLik = x$logLik, row.names = " "), digits = digits) - cat("\nOptimised, transformed parameters with symmetric confidence intervals:\n") + cat("\nOptimised parameters:\n") print(x$confint_trans, digits = digits) if (nrow(x$confint_trans) > 1) { @@ -228,8 +233,10 @@ print.summary.saem.mmkin <- function(x, digits = max(3, getOption("digits") - 3) cat("\nVariance model:\n") print(x$confint_errmod, digits = digits) - cat("\nBacktransformed parameters with asymmetric confidence intervals:\n") - print(x$confint_back, digits = digits) + if (x$transformations == "mkin") { + cat("\nBacktransformed parameters:\n") + print(x$confint_back, digits = digits) + } printSFORB <- !is.null(x$SFORB) if(printSFORB){ diff --git a/check.log b/check.log index 3dfee39f..68367bee 100644 --- a/check.log +++ b/check.log @@ -21,7 +21,8 @@ Maintainer: ‘Johannes Ranke ’ * checking whether package ‘mkin’ can be installed ... OK * checking installed package size ... OK * checking package directory ... OK -* checking for future file timestamps ... OK +* checking for future file timestamps ... NOTE +unable to verify current time * checking ‘build’ directory ... OK * checking DESCRIPTION meta-information ... OK * checking top-level files ... OK @@ -67,5 +68,9 @@ Maintainer: ‘Johannes Ranke ’ * checking for detritus in the temp directory ... OK * DONE -Status: OK +Status: 1 NOTE +See + ‘/home/jranke/git/mkin/mkin.Rcheck/00check.log’ +for details. + diff --git a/man/mixed.Rd b/man/mixed.Rd new file mode 100644 index 00000000..8b00382d --- /dev/null +++ b/man/mixed.Rd @@ -0,0 +1,69 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/mixed.mmkin.R +\name{mixed} +\alias{mixed} +\alias{mixed.mmkin} +\alias{print.mixed.mmkin} +\title{Create a mixed effects model from an mmkin row object} +\usage{ +mixed(object, ...) + +\method{mixed}{mmkin}(object, method = c("none"), ...) + +\method{print}{mixed.mmkin}(x, digits = max(3, getOption("digits") - 3), ...) +} +\arguments{ +\item{object}{An \link{mmkin} row object} + +\item{\dots}{Currently not used} + +\item{method}{The method to be used} + +\item{x}{A mixed.mmkin object to print} + +\item{digits}{Number of digits to use for printing.} +} +\description{ +Create a mixed effects model from an mmkin row object +} +\examples{ +sampling_times = c(0, 1, 3, 7, 14, 28, 60, 90, 120) +n_biphasic <- 8 +err_1 = list(const = 1, prop = 0.07) + +DFOP_SFO <- mkinmod( + parent = mkinsub("DFOP", "m1"), + m1 = mkinsub("SFO"), + quiet = TRUE) + +set.seed(123456) +log_sd <- 0.3 +syn_biphasic_parms <- as.matrix(data.frame( + k1 = rlnorm(n_biphasic, log(0.05), log_sd), + k2 = rlnorm(n_biphasic, log(0.01), log_sd), + g = plogis(rnorm(n_biphasic, 0, log_sd)), + f_parent_to_m1 = plogis(rnorm(n_biphasic, 0, log_sd)), + k_m1 = rlnorm(n_biphasic, log(0.002), log_sd))) + +ds_biphasic_mean <- lapply(1:n_biphasic, + function(i) { + mkinpredict(DFOP_SFO, syn_biphasic_parms[i, ], + c(parent = 100, m1 = 0), sampling_times) + } +) + +set.seed(123456L) +ds_biphasic <- lapply(ds_biphasic_mean, function(ds) { + add_err(ds, + sdfunc = function(value) sqrt(err_1$const^2 + value^2 * err_1$prop^2), + n = 1, secondary = "m1")[[1]] +}) + +\dontrun{ +f_mmkin <- mmkin(list("DFOP-SFO" = DFOP_SFO), ds_biphasic, error_model = "tc", quiet = TRUE) + +f_mixed <- mixed(f_mmkin) +print(f_mixed) +plot(f_mixed) +} +} diff --git a/man/mkinmod.Rd b/man/mkinmod.Rd index 95cec09a..bf073634 100644 --- a/man/mkinmod.Rd +++ b/man/mkinmod.Rd @@ -41,8 +41,8 @@ In print.mkinmod, this argument is currently not used.} \item{use_of_ff}{Specification of the use of formation fractions in the model equations and, if applicable, the coefficient matrix. If "max", formation fractions are always used (default). If "min", a minimum use of -formation fractions is made, i.e. each pathway to a metabolite has its -own rate constant.} +formation fractions is made, i.e. each first-order pathway to a metabolite +has its own rate constant.} \item{name}{A name for the model. Should be a valid R object name.} diff --git a/man/plot.mixed.mmkin.Rd b/man/plot.mixed.mmkin.Rd index 66e79f09..b90a4b3a 100644 --- a/man/plot.mixed.mmkin.Rd +++ b/man/plot.mixed.mmkin.Rd @@ -26,7 +26,7 @@ ) } \arguments{ -\item{x}{An object of class \link{saem.mmkin} or \link{nlme.mmkin}} +\item{x}{An object of class \link{mixed.mmkin}, \link{saem.mmkin} or \link{nlme.mmkin}} \item{i}{A numeric index to select datasets for which to plot the individual predictions, in case plots get too large} diff --git a/man/saem.Rd b/man/saem.Rd index ef5480f1..d8d6ea0f 100644 --- a/man/saem.Rd +++ b/man/saem.Rd @@ -8,10 +8,12 @@ \alias{saemix_data} \title{Fit nonlinear mixed models with SAEM} \usage{ -saem(object, control, ...) +saem(object, ...) \method{saem}{mmkin}( object, + transformations = c("mkin", "saemix"), + solution_type = "auto", control = list(displayProgress = FALSE, print = FALSE, save = FALSE, save.graphs = FALSE), cores = 1, @@ -23,7 +25,14 @@ saem(object, control, ...) \method{print}{saem.mmkin}(x, digits = max(3, getOption("digits") - 3), ...) -saemix_model(object, cores = 1, verbose = FALSE, ...) +saemix_model( + object, + solution_type = "auto", + transformations = c("mkin", "saemix"), + cores = 1, + verbose = FALSE, + ... +) saemix_data(object, verbose = FALSE, ...) } @@ -31,10 +40,19 @@ saemix_data(object, verbose = FALSE, ...) \item{object}{An \link{mmkin} row object containing several fits of the same \link{mkinmod} model to different datasets} -\item{control}{Passed to \link[saemix:saemix]{saemix::saemix}} - \item{\dots}{Further parameters passed to \link[saemix:saemixModel]{saemix::saemixModel}.} +\item{transformations}{Per default, all parameter transformations are done +in mkin. If this argument is set to 'saemix', parameter transformations +are done in 'saemix' for the supported cases. Currently this is only +supported in cases where the initial concentration of the parent is not fixed, +SFO or DFOP is used for the parent and there is either no metabolite or one.} + +\item{solution_type}{Possibility to specify the solution type in case the +automatic choice is not desired} + +\item{control}{Passed to \link[saemix:saemix]{saemix::saemix}} + \item{cores}{The number of cores to be used for multicore processing using \code{\link[parallel:mclapply]{parallel::mclapply()}}. Using more than 1 core is experimental and may lead to excessive forking, apparently depending on the BLAS version diff --git a/test.log b/test.log index c977d6a0..70011abb 100644 --- a/test.log +++ b/test.log @@ -2,48 +2,54 @@ Loading mkin Loading required package: parallel Testing mkin ✔ | OK F W S | Context -✔ | 4 | AIC calculation +✔ | 5 | AIC calculation ✔ | 2 | Export dataset for reading into CAKE -✔ | 14 | Results for FOCUS D established in expertise for UBA (Ranke 2014) [0.9 s] -✔ | 4 | Calculation of FOCUS chi2 error levels [0.4 s] +✔ | 14 | Results for FOCUS D established in expertise for UBA (Ranke 2014) [1.0 s] +✔ | 4 | Calculation of FOCUS chi2 error levels [0.5 s] ✔ | 7 | Fitting the SFORB model [3.5 s] -✔ | 5 | Analytical solutions for coupled models [3.1 s] +✔ | 5 | Analytical solutions for coupled models [3.2 s] ✔ | 5 | Calculation of Akaike weights -✔ | 10 | Confidence intervals and p-values [1.0 s] -✔ | 14 | Error model fitting [4.7 s] +✔ | 14 | Confidence intervals and p-values [1.2 s] +✔ | 14 | Error model fitting [4.5 s] ✔ | 4 | Test fitting the decline of metabolites from their maximum [0.3 s] ✔ | 1 | Fitting the logistic model [0.2 s] ✔ | 1 | Test dataset class mkinds used in gmkin ✔ | 1 | mkinfit features [0.3 s] ✔ | 12 | Special cases of mkinfit calls [0.7 s] -✔ | 8 | mkinmod model generation and printing [0.3 s] +✔ | 8 | mkinmod model generation and printing [0.2 s] ✔ | 3 | Model predictions with mkinpredict [0.4 s] -✔ | 14 2 | Evaluations according to 2015 NAFTA guidance [1.2 s] +✔ | 14 2 | Evaluations according to 2015 NAFTA guidance [1.3 s] ──────────────────────────────────────────────────────────────────────────────── -Skip (test_nafta.R:26:5): Test data from Appendix B are correctly evaluated +Skip (test_nafta.R:25:5): Test data from Appendix B are correctly evaluated Reason: getRversion() < "4.1.0" is TRUE -Skip (test_nafta.R:55:5): Test data from Appendix D are correctly evaluated +Skip (test_nafta.R:53:5): Test data from Appendix D are correctly evaluated Reason: getRversion() < "4.1.0" is TRUE ──────────────────────────────────────────────────────────────────────────────── -✔ | 9 | Nonlinear mixed-effects models [8.0 s] +✔ | 9 | Nonlinear mixed-effects models [7.9 s] ✔ | 0 1 | Plotting [0.7 s] ──────────────────────────────────────────────────────────────────────────────── -Skip (test_plot.R:25:3): Plotting mkinfit and mmkin objects is reproducible +Skip (test_plot.R:28:3): Plotting mkinfit and mmkin objects is reproducible Reason: getRversion() < "4.1.0" is TRUE ──────────────────────────────────────────────────────────────────────────────── ✔ | 4 | Residuals extracted from mkinfit models -✔ | 2 | Complex test case from Schaefer et al. (2007) Piacenza paper [1.7 s] -✔ | 4 | Summary [0.2 s] +✔ | 13 1 | Nonlinear mixed effects models fitted with SAEM from saemix [19.0 s] +──────────────────────────────────────────────────────────────────────────────── +Skip (test_saem.R:103:1): Simple models with metabolite can be fitted with saemix +Reason: empty test +──────────────────────────────────────────────────────────────────────────────── +✔ | 2 | Complex test case from Schaefer et al. (2007) Piacenza paper [1.5 s] +✔ | 4 | Summary [0.1 s] ✔ | 1 | Summaries of old mkinfit objects ✔ | 4 | Results for synthetic data established in expertise for UBA (Ranke 2014) [2.3 s] -✔ | 9 | Hypothesis tests [7.2 s] +✔ | 9 | Hypothesis tests [7.3 s] ✔ | 4 | Calculation of maximum time weighted average concentrations (TWAs) [2.4 s] ══ Results ═════════════════════════════════════════════════════════════════════ -Duration: 39.8 s +Duration: 59.7 s ── Skipped tests ────────────────────────────────────────────────────────────── +● empty test (1) ● getRversion() < "4.1.0" is TRUE (3) -[ FAIL 0 | WARN 0 | SKIP 3 | PASS 146 ] +[ FAIL 0 | WARN 0 | SKIP 4 | PASS 164 ] diff --git a/tests/figs/plotting/mixed-model-fit-for-mmkin-object.svg b/tests/figs/plotting/mixed-model-fit-for-mmkin-object.svg new file mode 100644 index 00000000..53a826df --- /dev/null +++ b/tests/figs/plotting/mixed-model-fit-for-mmkin-object.svg @@ -0,0 +1,2482 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +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 +parent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +0 +20 +40 +60 +80 +100 + + + + + + +-4 +-2 +0 +2 +4 + + + + + + +Predicted +Standardized residual + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +0 +20 +40 +60 +80 +100 +120 + + + + + + +0 +10 +20 +30 +40 + + + + + + +Time +m1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +0 +10 +20 +30 +40 + + + + + + +-4 +-2 +0 +2 +4 + + + + + + +Predicted +Standardized residual + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/figs/plotting/mixed-model-fit-for-nlme-object.svg b/tests/figs/plotting/mixed-model-fit-for-nlme-object.svg new file mode 100644 index 00000000..4ac2d738 --- /dev/null +++ b/tests/figs/plotting/mixed-model-fit-for-nlme-object.svg @@ -0,0 +1,2482 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +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 +parent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +0 +20 +40 +60 +80 +100 + + + + + + +-4 +-2 +0 +2 +4 + + + + + + +Predicted +Standardized residual + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +0 +20 +40 +60 +80 +100 +120 + + + + + + +0 +10 +20 +30 +40 + + + + + + +Time +m1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +0 +10 +20 +30 +40 + + + + + + +-4 +-2 +0 +2 +4 + + + + + + +Predicted +Standardized residual + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/figs/plotting/mixed-model-fit-for-saem-object-with-mkin-transformations.svg b/tests/figs/plotting/mixed-model-fit-for-saem-object-with-mkin-transformations.svg new file mode 100644 index 00000000..a75094a5 --- /dev/null +++ b/tests/figs/plotting/mixed-model-fit-for-saem-object-with-mkin-transformations.svg @@ -0,0 +1,2482 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +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 +parent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +0 +20 +40 +60 +80 +100 + + + + + + +-4 +-2 +0 +2 +4 + + + + + + +Predicted +Standardized residual + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +0 +20 +40 +60 +80 +100 +120 + + + + + + +0 +10 +20 +30 +40 + + + + + + +Time +m1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +0 +10 +20 +30 +40 + + + + + + +-4 +-2 +0 +2 +4 + + + + + + +Predicted +Standardized residual + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/figs/plotting/mixed-model-fit-for-saem-object-with-saemix-transformations.svg b/tests/figs/plotting/mixed-model-fit-for-saem-object-with-saemix-transformations.svg new file mode 100644 index 00000000..40320ec8 --- /dev/null +++ b/tests/figs/plotting/mixed-model-fit-for-saem-object-with-saemix-transformations.svg @@ -0,0 +1,2482 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +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 +parent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +0 +20 +40 +60 +80 +100 + + + + + + +-4 +-2 +0 +2 +4 + + + + + + +Predicted +Standardized residual + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +0 +20 +40 +60 +80 +100 +120 + + + + + + +0 +10 +20 +30 +40 + + + + + + +Time +m1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +0 +10 +20 +30 +40 + + + + + + +-4 +-2 +0 +2 +4 + + + + + + +Predicted +Standardized residual + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/testthat/setup_script.R b/tests/testthat/setup_script.R index 8d8ba3e9..9ec91425 100644 --- a/tests/testthat/setup_script.R +++ b/tests/testthat/setup_script.R @@ -100,3 +100,67 @@ fit_obs_1 <- mkinfit(m_synth_SFO_lin, SFO_lin_a, error_model = "obs", quiet = TR # We know threestep is OK, and threestep (and IRLS) is faster here fit_tc_1 <- mkinfit(m_synth_SFO_lin, SFO_lin_a, error_model = "tc", quiet = TRUE, error_model_algorithm = "threestep") + +# Mixed models data +set.seed(123456) +sampling_times = c(0, 1, 3, 7, 14, 28, 60, 90, 120) +n <- n_biphasic <- 15 +log_sd <- 0.3 +err_1 = list(const = 1, prop = 0.05) +tc <- function(value) sigma_twocomp(value, err_1$const, err_1$prop) +const <- function(value) 2 + +SFO <- mkinmod(parent = mkinsub("SFO")) +k_parent = rlnorm(n, log(0.03), log_sd) +ds_sfo <- lapply(1:n, function(i) { + ds_mean <- mkinpredict(SFO, c(k_parent = k_parent[i]), + c(parent = 100), sampling_times) + add_err(ds_mean, tc, n = 1)[[1]] +}) + +DFOP <- mkinmod(parent = mkinsub("DFOP")) +dfop_pop <- list(parent_0 = 100, k1 = 0.06, k2 = 0.015, g = 0.4) +dfop_parms <- as.matrix(data.frame( + k1 = rlnorm(n, log(dfop_pop$k1), log_sd), + k2 = rlnorm(n, log(dfop_pop$k2), log_sd), + g = plogis(rnorm(n, qlogis(dfop_pop$g), log_sd)))) +ds_dfop <- lapply(1:n, function(i) { + ds_mean <- mkinpredict(DFOP, dfop_parms[i, ], + c(parent = dfop_pop$parent_0), sampling_times) + add_err(ds_mean, const, n = 1)[[1]] +}) + +set.seed(123456) +DFOP_SFO <- mkinmod( + parent = mkinsub("DFOP", "m1"), + m1 = mkinsub("SFO"), + quiet = TRUE) +dfop_sfo_pop <- list(parent_0 = 100, + k_m1 = 0.002, f_parent_to_m1 = 0.5, + k1 = 0.05, k2 = 0.01, g = 0.5) +syn_biphasic_parms <- as.matrix(data.frame( + k1 = rlnorm(n_biphasic, log(dfop_sfo_pop$k1), log_sd), + k2 = rlnorm(n_biphasic, log(dfop_sfo_pop$k2), log_sd), + g = plogis(rnorm(n_biphasic, qlogis(dfop_sfo_pop$g), log_sd)), + f_parent_to_m1 = plogis(rnorm(n_biphasic, + qlogis(dfop_sfo_pop$f_parent_to_m1), log_sd)), + k_m1 = rlnorm(n_biphasic, log(dfop_sfo_pop$k_m1), log_sd))) +ds_biphasic_mean <- lapply(1:n_biphasic, + function(i) { + mkinpredict(DFOP_SFO, syn_biphasic_parms[i, ], + c(parent = 100, m1 = 0), sampling_times) + } +) +ds_biphasic <- lapply(ds_biphasic_mean, function(ds) { + add_err(ds, + sdfunc = function(value) sqrt(err_1$const^2 + value^2 * err_1$prop^2), + n = 1, secondary = "m1")[[1]] +}) + +# Mixed model fits +mmkin_sfo_1 <- mmkin("SFO", ds_sfo, quiet = TRUE, error_model = "tc") +sfo_saemix_1 <- saem(mmkin_sfo_1, quiet = TRUE, transformations = "saemix") +mmkin_biphasic <- mmkin(list("DFOP-SFO" = DFOP_SFO), ds_biphasic, quiet = TRUE) +nlme_biphasic <- nlme(mmkin_biphasic) +saem_biphasic_m <- saem(mmkin_biphasic, transformations = "mkin", quiet = TRUE) +saem_biphasic_s <- saem(mmkin_biphasic, transformations = "saemix", quiet = TRUE) diff --git a/tests/testthat/test_AIC.R b/tests/testthat/test_AIC.R index e9698f7c..57b9a673 100644 --- a/tests/testthat/test_AIC.R +++ b/tests/testthat/test_AIC.R @@ -6,6 +6,7 @@ test_that("The AIC is reproducible", { data.frame(df = c(3, 4, 5, 5), AIC = c(59.3, 44.7, 29.0, 39.2)), scale = 1, tolerance = 0.1) expect_error(AIC(fits["SFO", ]), "column object") + expect_error(BIC(fits["SFO", ]), "column object") expect_equivalent(BIC(fits[, "FOCUS_C"]), data.frame(df = c(3, 4, 5, 5), AIC = c(59.9, 45.5, 30.0, 40.2)), scale = 1, tolerance = 0.1) diff --git a/tests/testthat/test_confidence.R b/tests/testthat/test_confidence.R index 3fdd3f2c..54be675c 100644 --- a/tests/testthat/test_confidence.R +++ b/tests/testthat/test_confidence.R @@ -1,6 +1,19 @@ context("Confidence intervals and p-values") +test_that("Some special cases of confidence interval calculation work", { + + tmp <- expect_warning(mkinfit("FOMC", FOCUS_2006_A, quiet = TRUE), "not converge") + + expect_equivalent( + confint(tmp, transform = FALSE), + matrix(rep(NA, 8), nrow = 4)) +}) + test_that("The confint method 'quadratic' is consistent with the summary", { + expect_equivalent( + confint(fit_nw_1, parm = "parent_0", method = "quadratic"), + summary(fit_nw_1)$bpar["parent_0", c("Lower", "Upper")]) + expect_equivalent( confint(fit_nw_1, method = "quadratic"), summary(fit_nw_1)$bpar[, c("Lower", "Upper")]) @@ -74,8 +87,8 @@ test_that("Likelihood profile based confidence intervals work", { } f_mle <- stats4::mle(f_nll, start = as.list(parms(f)), nobs = nrow(FOCUS_2006_C)) - ci_mkin_1_p_0.95 <- confint(f, method = "profile", level = 0.95, - cores = n_cores, quiet = TRUE) + ci_mkin_1_p_0.95 <- expect_message(confint(f, method = "profile", level = 0.95, + cores = n_cores, quiet = FALSE), "Profiling the likelihood") # Magically, we get very similar boundaries as stats4::mle # (we need to capture the output to avoid printing this while testing as diff --git a/tests/testthat/test_mixed.R b/tests/testthat/test_mixed.R new file mode 100644 index 00000000..2d69e13e --- /dev/null +++ b/tests/testthat/test_mixed.R @@ -0,0 +1,35 @@ +context("Fitting of nonlinear mixed effects models") + +sampling_times = c(0, 1, 3, 7, 14, 28, 60, 90, 120) +n_biphasic <- 8 +err_1 = list(const = 1, prop = 0.07) + +DFOP_SFO <- mkinmod( + parent = mkinsub("DFOP", "m1"), + m1 = mkinsub("SFO"), + quiet = TRUE) + +set.seed(123456) +log_sd <- 0.3 +syn_biphasic_parms <- as.matrix(data.frame( + k1 = rlnorm(n_biphasic, log(0.05), log_sd), + k2 = rlnorm(n_biphasic, log(0.01), log_sd), + g = plogis(rnorm(n_biphasic, 0, log_sd)), + f_parent_to_m1 = plogis(rnorm(n_biphasic, 0, log_sd)), + k_m1 = rlnorm(n_biphasic, log(0.002), log_sd))) + +ds_biphasic_mean <- lapply(1:n_biphasic, + function(i) { + mkinpredict(DFOP_SFO, syn_biphasic_parms[i, ], + c(parent = 100, m1 = 0), sampling_times) + } +) + +set.seed(123456L) +ds_biphasic <- lapply(ds_biphasic_mean, function(ds) { + add_err(ds, + sdfunc = function(value) sqrt(err_1$const^2 + value^2 * err_1$prop^2), + n = 1, secondary = "m1")[[1]] +}) + +f_mmkin <- mmkin(list("DFOP-SFO" = DFOP_SFO), ds_biphasic, quiet = TRUE) diff --git a/tests/testthat/test_nafta.R b/tests/testthat/test_nafta.R index fcab4ffb..62c88983 100644 --- a/tests/testthat/test_nafta.R +++ b/tests/testthat/test_nafta.R @@ -20,7 +20,6 @@ test_that("Test data from Appendix B are correctly evaluated", { expect_known_output(print(res), "NAFTA_SOP_Appendix_B.txt") - skip_on_travis() plot_nafta <- function() plot(res) if(requireNamespace("vdiffr", quietly = TRUE)) { skip_if(getRversion() < "4.1.0") @@ -49,7 +48,6 @@ test_that("Test data from Appendix D are correctly evaluated", { expect_known_output(print(res), "NAFTA_SOP_Appendix_D.txt") - skip_on_travis() plot_nafta <- function() plot(res) if(requireNamespace("vdiffr", quietly = TRUE)) { skip_if(getRversion() < "4.1.0") diff --git a/tests/testthat/test_plot.R b/tests/testthat/test_plot.R index 587ec02e..72f1020c 100644 --- a/tests/testthat/test_plot.R +++ b/tests/testthat/test_plot.R @@ -2,7 +2,6 @@ context("Plotting") test_that("Plotting mkinfit and mmkin objects is reproducible", { skip_on_cran() - skip_on_travis() plot_default_FOCUS_C_SFO <- function() plot(fits[["SFO", "FOCUS_C"]]) plot_res_FOCUS_C_SFO <- function() plot(fits[["SFO", "FOCUS_C"]], show_residuals = TRUE) plot_res_FOCUS_C_SFO_2 <- function() plot_res(fits[["SFO", "FOCUS_C"]]) @@ -17,6 +16,11 @@ test_that("Plotting mkinfit and mmkin objects is reproducible", { plot_errmod_fit_D_obs_eigen <- function() plot_err(fit_D_obs_eigen, sep_obs = FALSE) plot_errmod_fit_C_tc <- function() plot_err(fit_C_tc) + plot_biphasic_mmkin <- function() plot(mixed(mmkin_biphasic)) + plot_biphasic_nlme <- function() plot(nlme_biphasic) + plot_biphasic_saem_s <- function() plot(saem_biphasic_s) + plot_biphasic_saem_m <- function() plot(saem_biphasic_m) + plot_res_sfo_sfo <- function() plot_res(f_sfo_sfo_desolve) plot_err_sfo_sfo <- function() plot_err(f_sfo_sfo_desolve) plot_errmod_fit_obs_1 <- function() plot_err(fit_obs_1, sep_obs = FALSE) @@ -32,6 +36,10 @@ test_that("Plotting mkinfit and mmkin objects is reproducible", { vdiffr::expect_doppelganger("mmkin plot for FOCUS C", mmkin_FOCUS_C) vdiffr::expect_doppelganger("mmkin plot for SFO (FOCUS C and D)", mmkin_SFO) vdiffr::expect_doppelganger("plot_errmod with FOCUS C tc", plot_errmod_fit_C_tc) + vdiffr::expect_doppelganger("mixed model fit for mmkin object", plot_biphasic_mmkin) + vdiffr::expect_doppelganger("mixed model fit for nlme object", plot_biphasic_nlme) + vdiffr::expect_doppelganger("mixed model fit for saem object with saemix transformations", plot_biphasic_saem_s) + vdiffr::expect_doppelganger("mixed model fit for saem object with mkin transformations", plot_biphasic_saem_m) skip_on_travis() # Still not working on Travis, maybe because of deSolve producing # different results when not working with a compiled model or eigenvalues vdiffr::expect_doppelganger("plot_errmod with FOCUS D obs eigen", plot_errmod_fit_D_obs_eigen) diff --git a/tests/testthat/test_saem.R b/tests/testthat/test_saem.R new file mode 100644 index 00000000..0b6d4531 --- /dev/null +++ b/tests/testthat/test_saem.R @@ -0,0 +1,118 @@ +context("Nonlinear mixed effects models fitted with SAEM from saemix") + +set.seed(123456) +sampling_times = c(0, 1, 3, 7, 14, 28, 60, 90, 120) +n <- n_biphasic <- 15 +log_sd <- 0.3 +err_1 = list(const = 1, prop = 0.05) +tc <- function(value) sigma_twocomp(value, err_1$const, err_1$prop) +const <- function(value) 2 + +SFO <- mkinmod(parent = mkinsub("SFO")) +k_parent = rlnorm(n, log(0.03), log_sd) +ds_sfo <- lapply(1:n, function(i) { + ds_mean <- mkinpredict(SFO, c(k_parent = k_parent[i]), + c(parent = 100), sampling_times) + add_err(ds_mean, tc, n = 1)[[1]] +}) + +DFOP <- mkinmod(parent = mkinsub("DFOP")) +dfop_pop <- list(parent_0 = 100, k1 = 0.06, k2 = 0.015, g = 0.4) +dfop_parms <- as.matrix(data.frame( + k1 = rlnorm(n, log(dfop_pop$k1), log_sd), + k2 = rlnorm(n, log(dfop_pop$k2), log_sd), + g = plogis(rnorm(n, qlogis(dfop_pop$g), log_sd)))) +ds_dfop <- lapply(1:n, function(i) { + ds_mean <- mkinpredict(DFOP, dfop_parms[i, ], + c(parent = dfop_pop$parent_0), sampling_times) + add_err(ds_mean, const, n = 1)[[1]] +}) + +set.seed(123456) +DFOP_SFO <- mkinmod( + parent = mkinsub("DFOP", "m1"), + m1 = mkinsub("SFO"), + quiet = TRUE) +syn_biphasic_parms <- as.matrix(data.frame( + k1 = rlnorm(n_biphasic, log(0.05), log_sd), + k2 = rlnorm(n_biphasic, log(0.01), log_sd), + g = plogis(rnorm(n_biphasic, 0, log_sd)), + f_parent_to_m1 = plogis(rnorm(n_biphasic, 0, log_sd)), + k_m1 = rlnorm(n_biphasic, log(0.002), log_sd))) +ds_biphasic_mean <- lapply(1:n_biphasic, + function(i) { + mkinpredict(DFOP_SFO, syn_biphasic_parms[i, ], + c(parent = 100, m1 = 0), sampling_times) + } +) +ds_biphasic <- lapply(ds_biphasic_mean, function(ds) { + add_err(ds, + sdfunc = function(value) sqrt(err_1$const^2 + value^2 * err_1$prop^2), + n = 1, secondary = "m1")[[1]] +}) + +test_that("Parent only models can be fitted with saemix", { + # Some fits were done in the setup script + mmkin_sfo_2 <- mmkin("SFO", ds_sfo, fixed_initials = c(parent = 100), quiet = TRUE) + + sfo_saemix_2 <- saem(mmkin_sfo_1, quiet = TRUE, transformations = "mkin") + sfo_saemix_3 <- expect_error(saem(mmkin_sfo_2, quiet = TRUE), "at least two parameters") + s_sfo_s1 <- summary(sfo_saemix_1) + s_sfo_s2 <- summary(sfo_saemix_2) + + sfo_nlme_1 <- expect_warning(nlme(mmkin_sfo_1), "not converge") + s_sfo_n <- summary(sfo_nlme_1) + + # Compare with input + expect_equal(round(s_sfo_s2$confint_ranef["SD.log_k_parent", "est."], 1), 0.3) + # k_parent is a bit different from input 0.03 here + expect_equal(round(s_sfo_s1$confint_back["k_parent", "est."], 3), 0.035) + expect_equal(round(s_sfo_s2$confint_back["k_parent", "est."], 3), 0.035) + + # But the result is pretty unanimous between methods + expect_equal(round(s_sfo_s1$confint_back["k_parent", "est."], 3), + round(s_sfo_s2$confint_back["k_parent", "est."], 3)) + expect_equal(round(s_sfo_s1$confint_back["k_parent", "est."], 3), + round(s_sfo_n$confint_back["k_parent", "est."], 3)) + + mmkin_dfop_1 <- mmkin("DFOP", ds_dfop, quiet = TRUE) + + dfop_saemix_1 <- saem(mmkin_dfop_1, quiet = TRUE, transformations = "mkin") + dfop_saemix_2 <- saem(mmkin_dfop_1, quiet = TRUE, transformations = "saemix") + dfop_nlme_1 <- nlme(mmkin_dfop_1) + s_dfop_s1 <- summary(dfop_saemix_1) + s_dfop_s2 <- summary(dfop_saemix_2) + s_dfop_n <- summary(dfop_nlme_1) + + dfop_pop <- as.numeric(dfop_pop) + expect_true(all(s_dfop_s1$confint_back[, "lower"] < dfop_pop)) + expect_true(all(s_dfop_s1$confint_back[, "upper"] > dfop_pop)) + expect_true(all(s_dfop_s2$confint_back[, "lower"] < dfop_pop)) + expect_true(all(s_dfop_s2$confint_back[, "upper"] > dfop_pop)) + + + # We get < 20% deviations with transformations made in mkin + rel_diff_1 <- (s_dfop_s1$confint_back[, "est."] - dfop_pop) / dfop_pop + expect_true(all(rel_diff_1 < 0.2)) + + # We get < 8% deviations with transformations made in saemix + rel_diff_2 <- (s_dfop_s2$confint_back[, "est."] - dfop_pop) / dfop_pop + expect_true(all(rel_diff_2 < 0.08)) +}) + +test_that("Simple models with metabolite can be fitted with saemix", { + + dfop_sfo_pop <- as.numeric(dfop_sfo_pop) + ci_dfop_sfo_s_s <- summary(saem_biphasic_s)$confint_back + expect_true(all(ci_dfop_sfo_s_s[, "lower"] < dfop_sfo_pop)) + expect_true(all(ci_dfop_sfo_s_s[, "upper"] > dfop_sfo_pop)) + + # The following does not work, the k1 and k2 are not fitted well + ci_dfop_sfo_s_m <- summary(saem_biphasic_m)$confint_back + # expect_true(all(ci_dfop_sfo_s_m[, "lower"] < dfop_sfo_pop)) + #expect_true(all(ci_dfop_sfo_s_m[, "upper"] > dfop_sfo_pop)) + + # Somehow this does not work at the moment. But it took forever (~ 10 min) anyways... + #saem_biphasic_2 <- saem(mmkin_biphasic, solution_type = "deSolve", quiet = TRUE) + +}) -- cgit v1.2.1