From 4ad235a0e23718c9ad855b25e3a8e24971cc3ccc Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Sun, 30 Oct 2022 18:01:04 +0100 Subject: saem summary in case of non-invertible FIM parts --- R/summary.saem.mmkin.R | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'R') diff --git a/R/summary.saem.mmkin.R b/R/summary.saem.mmkin.R index 651cc29e..ea2f02e2 100644 --- a/R/summary.saem.mmkin.R +++ b/R/summary.saem.mmkin.R @@ -136,12 +136,16 @@ summary.saem.mmkin <- function(object, data = FALSE, verbose = FALSE, distimes = } # Correlation of fixed effects (inspired by summary.nlme) - varFix <- vcov(object$so)[1:n_fixed, 1:n_fixed] - stdFix <- sqrt(diag(varFix)) - object$corFixed <- array( - t(varFix/stdFix)/stdFix, - dim(varFix), - list(names_fixed_effects, names_fixed_effects)) + varFix <- try(vcov(object$so)[1:n_fixed, 1:n_fixed]) + if (inherits(varFix, "try-error")) { + object$corFixed <- NA + } else { + stdFix <- sqrt(diag(varFix)) + object$corFixed <- array( + t(varFix/stdFix)/stdFix, + dim(varFix), + list(names_fixed_effects, names_fixed_effects)) + } # Random effects sdnames <- intersect(rownames(conf.int), paste0("SD.", pnames)) @@ -231,7 +235,9 @@ print.summary.saem.mmkin <- function(x, digits = max(3, getOption("digits") - 3) cat("\nOptimised parameters:\n") print(x$confint_trans, digits = digits) - if (nrow(x$confint_trans) > 1) { + if (identical(x$corFixed, NA)) { + cat("\nCorrelation is not available\n") + } else { corr <- x$corFixed class(corr) <- "correlation" print(corr, title = "\nCorrelation:", rdig = digits, ...) -- cgit v1.2.1