aboutsummaryrefslogtreecommitdiff
path: root/R
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2020-11-10 05:14:57 +0100
committerJohannes Ranke <jranke@uni-bremen.de>2020-11-10 05:14:57 +0100
commit606ef9ad6cae0ddfae6db6b90deb03f81140e46f (patch)
tree5a0a581a2251621efdcbd5a5c425cb04eca306f5 /R
parent96500fa127b59bddb2fcfe77b7b97415bd105f4a (diff)
Digits for summary methods, print.saem.mmkin
Diffstat (limited to 'R')
-rw-r--r--R/nlme.mmkin.R7
-rw-r--r--R/saemix.R30
-rw-r--r--R/summary.nlme.mmkin.R14
-rw-r--r--R/summary.saem.mmkin.R16
4 files changed, 49 insertions, 18 deletions
diff --git a/R/nlme.mmkin.R b/R/nlme.mmkin.R
index d26b86ac..a9e1694f 100644
--- a/R/nlme.mmkin.R
+++ b/R/nlme.mmkin.R
@@ -210,7 +210,8 @@ nlme.mmkin <- function(model, data = sys.frame(sys.parent()),
#' @export
#' @rdname nlme.mmkin
#' @param x An nlme.mmkin object to print
-print.nlme.mmkin <- function(x, ...) {
+#' @param digits Number of digits to use for printing
+print.nlme.mmkin <- function(x, digits = max(3, getOption("digits") - 3), ...) {
cat( "Kinetic nonlinear mixed-effects model fit by " )
cat( if(x$method == "REML") "REML\n" else "maximum likelihood\n")
cat("\nStructural model:\n")
@@ -230,9 +231,9 @@ print.nlme.mmkin <- function(x, ...) {
x$call$fixed
else
lapply(fixF, function(el) as.name(deparse(el)))), "\n")
- print(fixef(x), ...)
+ print(fixef(x), digits = digits, ...)
cat("\n")
- print(summary(x$modelStruct), sigma = x$sigma, ...)
+ print(summary(x$modelStruct), sigma = x$sigma, digits = digits, ...)
invisible(x)
}
diff --git a/R/saemix.R b/R/saemix.R
index 8955aa54..68bbd233 100644
--- a/R/saemix.R
+++ b/R/saemix.R
@@ -139,6 +139,36 @@ saem.mmkin <- function(object,
return(result)
}
+#' @export
+#' @rdname saem
+#' @param x An saem.mmkin object to print
+#' @param digits Number of digits to use for printing
+print.saem.mmkin <- function(x, digits = max(3, getOption("digits") - 3), ...) {
+ cat( "Kinetic nonlinear mixed-effects model fit by SAEM" )
+ 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")
+
+ cat("\nLikelihood computed by importance sampling\n")
+ print(data.frame(
+ AIC = AIC(x$so, type = "is"),
+ BIC = BIC(x$so, type = "is"),
+ logLik = logLik(x$so, type = "is"),
+ row.names = " "), digits = digits)
+
+ cat("\nFitted parameters:\n")
+ conf.int <- x$so@results@conf.int[c("estimate", "lower", "upper")]
+ rownames(conf.int) <- x$so@results@conf.int[["name"]]
+ print(conf.int, digits = digits)
+
+ invisible(x)
+}
+
#' @rdname saem
#' @return An [saemix::SaemixModel] object.
#' @export
diff --git a/R/summary.nlme.mmkin.R b/R/summary.nlme.mmkin.R
index ad730f9a..42326b39 100644
--- a/R/summary.nlme.mmkin.R
+++ b/R/summary.nlme.mmkin.R
@@ -191,10 +191,10 @@ print.summary.nlme.mmkin <- function(x, digits = max(3, getOption("digits") - 3)
cat("\nResults:\n\n")
print(data.frame(AIC = x$AIC, BIC = x$BIC, logLik = x$logLik,
- row.names = " "))
+ row.names = " "), ...)
cat("\nOptimised, transformed parameters with symmetric confidence intervals:\n")
- print(x$confint_trans)
+ print(x$confint_trans, digits = digits, ...)
if (nrow(x$confint_trans) > 1) {
corr <- x$corFixed
@@ -204,28 +204,28 @@ print.summary.nlme.mmkin <- function(x, digits = max(3, getOption("digits") - 3)
cat("\n") # Random effects
print(summary(x$modelStruct), sigma = x$sigma,
- reEstimates = x$coef$random, verbose = verbose, ...)
+ reEstimates = x$coef$random, digits = digits, verbose = verbose, ...)
cat("\nBacktransformed parameters with asymmetric confidence intervals:\n")
- print(x$confint_back)
+ print(x$confint_back, digits = digits, ...)
printSFORB <- !is.null(x$SFORB)
if(printSFORB){
cat("\nEstimated Eigenvalues of SFORB model(s):\n")
- print(x$SFORB, digits=digits,...)
+ print(x$SFORB, digits = digits,...)
}
printff <- !is.null(x$ff)
if(printff){
cat("\nResulting formation fractions:\n")
- print(data.frame(ff = x$ff), digits=digits,...)
+ print(data.frame(ff = x$ff), ...)
}
printdistimes <- !is.null(x$distimes)
if(printdistimes){
cat("\nEstimated disappearance times:\n")
- print(x$distimes, digits=digits,...)
+ print(x$distimes, digits = digits, ...)
}
if (x$print_data){
diff --git a/R/summary.saem.mmkin.R b/R/summary.saem.mmkin.R
index 75fdb045..337120b2 100644
--- a/R/summary.saem.mmkin.R
+++ b/R/summary.saem.mmkin.R
@@ -213,10 +213,10 @@ print.summary.saem.mmkin <- function(x, digits = max(3, getOption("digits") - 3)
cat("\nResults:\n\n")
cat("Likelihood computed by importance sampling\n")
print(data.frame(AIC = x$AIC, BIC = x$BIC, logLik = x$logLik,
- row.names = " "))
+ row.names = " "), digits = digits)
cat("\nOptimised, transformed parameters with symmetric confidence intervals:\n")
- print(x$confint_trans)
+ print(x$confint_trans, digits = digits)
if (nrow(x$confint_trans) > 1) {
corr <- x$corFixed
@@ -225,30 +225,30 @@ print.summary.saem.mmkin <- function(x, digits = max(3, getOption("digits") - 3)
}
cat("\nRandom effects:\n")
- print(x$confint_ranef)
+ print(x$confint_ranef, digits = digits)
cat("\nVariance model:\n")
- print(x$confint_errmod)
+ print(x$confint_errmod, digits = digits)
cat("\nBacktransformed parameters with asymmetric confidence intervals:\n")
- print(x$confint_back)
+ print(x$confint_back, digits = digits)
printSFORB <- !is.null(x$SFORB)
if(printSFORB){
cat("\nEstimated Eigenvalues of SFORB model(s):\n")
- print(x$SFORB, digits=digits,...)
+ print(x$SFORB, digits = digits,...)
}
printff <- !is.null(x$ff)
if(printff){
cat("\nResulting formation fractions:\n")
- print(data.frame(ff = x$ff), digits=digits,...)
+ print(data.frame(ff = x$ff), digits = digits,...)
}
printdistimes <- !is.null(x$distimes)
if(printdistimes){
cat("\nEstimated disappearance times:\n")
- print(x$distimes, digits=digits,...)
+ print(x$distimes, digits = digits,...)
}
if (x$print_data){

Contact - Imprint