diff options
Diffstat (limited to 'R/summary.saem.mmkin.R')
-rw-r--r-- | R/summary.saem.mmkin.R | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/R/summary.saem.mmkin.R b/R/summary.saem.mmkin.R index fa52a579..651cc29e 100644 --- a/R/summary.saem.mmkin.R +++ b/R/summary.saem.mmkin.R @@ -73,7 +73,12 @@ #' f_mmkin_dfop_sfo <- mmkin(list(dfop_sfo), ds_syn_dfop_sfo, #' quiet = TRUE, error_model = "tc", cores = 5) #' f_saem_dfop_sfo <- saem(f_mmkin_dfop_sfo) -#' summary(f_saem_dfop_sfo, data = TRUE) +#' print(f_saem_dfop_sfo) +#' illparms(f_saem_dfop_sfo) +#' f_saem_dfop_sfo_2 <- update(f_saem_dfop_sfo, covariance.model = diag(c(0, 0, 1, 1, 1, 0))) +#' illparms(f_saem_dfop_sfo_2) +#' intervals(f_saem_dfop_sfo_2) +#' summary(f_saem_dfop_sfo_2, data = TRUE) #' } #' #' @export @@ -82,18 +87,19 @@ summary.saem.mmkin <- function(object, data = FALSE, verbose = FALSE, distimes = mod_vars <- names(object$mkinmod$diffs) pnames <- names(object$mean_dp_start) - np <- length(pnames) + names_fixed_effects <- object$so@results@name.fixed + n_fixed <- length(names_fixed_effects) conf.int <- object$so@results@conf.int rownames(conf.int) <- conf.int$name - confint_trans <- as.matrix(conf.int[pnames, c("estimate", "lower", "upper")]) + confint_trans <- as.matrix(parms(object, ci = TRUE)) colnames(confint_trans)[1] <- "est." # In case objects were produced by earlier versions of saem if (is.null(object$transformations)) object$transformations <- "mkin" if (object$transformations == "mkin") { - bp <- backtransform_odeparms(confint_trans[, "est."], object$mkinmod, + bp <- backtransform_odeparms(confint_trans[pnames, "est."], object$mkinmod, object$transform_rates, object$transform_fractions) bpnames <- names(bp) @@ -126,20 +132,20 @@ summary.saem.mmkin <- function(object, data = FALSE, verbose = FALSE, distimes = } } } else { - confint_back <- confint_trans + confint_back <- confint_trans[names_fixed_effects, ] } # Correlation of fixed effects (inspired by summary.nlme) - varFix <- vcov(object$so)[1:np, 1:np] + varFix <- vcov(object$so)[1:n_fixed, 1:n_fixed] stdFix <- sqrt(diag(varFix)) object$corFixed <- array( t(varFix/stdFix)/stdFix, dim(varFix), - list(pnames, pnames)) + list(names_fixed_effects, names_fixed_effects)) # Random effects - rnames <- paste0("SD.", pnames) - confint_ranef <- as.matrix(conf.int[rnames, c("estimate", "lower", "upper")]) + sdnames <- intersect(rownames(conf.int), paste0("SD.", pnames)) + confint_ranef <- as.matrix(conf.int[sdnames, c("estimate", "lower", "upper")]) colnames(confint_ranef)[1] <- "est." # Error model @@ -147,7 +153,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." - object$confint_trans <- confint_trans object$confint_ranef <- confint_ranef object$confint_errmod <- confint_errmod @@ -202,7 +207,7 @@ print.summary.saem.mmkin <- function(x, digits = max(3, getOption("digits") - 3) cat("\nModel predictions using solution type", x$solution_type, "\n") cat("\nFitted in", x$time[["elapsed"]], "s\n") - cat("Using", paste(x$so@options$nbiter.saemix, collapse = ", "), + cat("Using", paste(x$so@options$nbiter.saemix, collapse = ", "), "iterations and", x$so@options$nb.chains, "chains\n") cat("\nVariance model: ") |