aboutsummaryrefslogtreecommitdiff
path: root/R/plot.nlme.mmkin.R
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2020-04-15 18:13:04 +0200
committerJohannes Ranke <jranke@uni-bremen.de>2020-04-15 19:00:06 +0200
commit42171ba55222383a0d47e5aacd46a972819e7812 (patch)
tree190320919fe83aece30b654bfeb7687241e36f99 /R/plot.nlme.mmkin.R
parent637bd14fed5ab8a615f0d879012f12c59e1532a4 (diff)
Include random effects in starting parameters
- mean_degparms() now optionally returns starting values for fixed and random effects, which makes it possible to obtain acceptable fits also in more difficult cases (with more parameters) - Fix the anova method, as it is currently not enough to inherit from lme: https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17761 - Show fit information, and per default also errmin information in plot.nlme.mmkin() - Examples for nlme.mmkin: Decrease tolerance and increase the number of iterations in the PNLS step in order to be able to fit FOMC-SFO and DFOP-SFO
Diffstat (limited to 'R/plot.nlme.mmkin.R')
-rw-r--r--R/plot.nlme.mmkin.R22
1 files changed, 17 insertions, 5 deletions
diff --git a/R/plot.nlme.mmkin.R b/R/plot.nlme.mmkin.R
index ef6d100a..0f3ad715 100644
--- a/R/plot.nlme.mmkin.R
+++ b/R/plot.nlme.mmkin.R
@@ -11,6 +11,12 @@
#' @param standardized Should the residuals be standardized? This option
#' is passed to \code{\link{mkinresplot}}, it only takes effect if
#' `resplot = "time"`.
+#' @param show_errmin Should the chi2 error level be shown on top of the plots
+#' to the left?
+#' @param errmin_var The variable for which the FOCUS chi2 error value should
+#' be shown.
+#' @param errmin_digits The number of significant digits for rounding the FOCUS
+#' chi2 error percentage.
#' @param cex Passed to the plot functions and \code{\link{mtext}}.
#' @param rel.height.middle The relative height of the middle plot, if more
#' than two rows of plots are shown.
@@ -25,16 +31,19 @@
#' function(x) subset(x$data[c("name", "time", "value")], name == "parent"))
#' f <- mmkin("SFO", ds, quiet = TRUE, cores = 1)
#' #plot(f) # too many panels for pkgdown
+#' plot(f[, 3:4])
#' library(nlme)
#' f_nlme <- nlme(f)
#'
#' #plot(f_nlme) # too many panels for pkgdown
-#' plot(f_nlme, 1:2)
+#' plot(f_nlme, 3:4)
#' @export
plot.nlme.mmkin <- function(x, i = 1:ncol(x$mmkin_orig),
main = "auto", legends = 1,
resplot = c("time", "errmod"),
standardized = FALSE,
+ show_errmin = TRUE,
+ errmin_var = "All data", errmin_digits = 3,
cex = 0.7, rel.height.middle = 0.9,
ymax = "auto", ...)
{
@@ -79,13 +88,14 @@ plot.nlme.mmkin <- function(x, i = 1:ncol(x$mmkin_orig),
state_ini[names(odeini_optim)] <- odeini_optim
odeparms <- fit_a$bparms.ode
- odeparms[names(odeparms)] <- odeparms_optim
+ odeparms[names(odeparms_optim)] <- odeparms_optim
mkinfit_call[["observed"]] <- ds[[a]]
mkinfit_call[["parms.ini"]] <- odeparms
mkinfit_call[["state.ini"]] <- state_ini
- mkinfit_call[["control"]] <- list(iter.max = 1)
+ mkinfit_call[["control"]] <- list(iter.max = 0)
+ mkinfit_call[["quiet"]] <- TRUE
res <- suppressWarnings(do.call("mkinfit", mkinfit_call))
return(res)
@@ -94,9 +104,11 @@ plot.nlme.mmkin <- function(x, i = 1:ncol(x$mmkin_orig),
# Set dimensions with names and the class (mmkin)
attributes(mmkin_nlme) <- attributes(x$mmkin_orig[, i])
- plot(mmkin_nlme[, i], main = main, legends = legends,
+ plot(mmkin_nlme, main = main, legends = legends,
resplot = resplot, standardized = standardized,
- show_errmin = FALSE, cex = cex,
+ show_errmin = show_errmin,
+ errmin_var = errmin_var, errmin_digits = errmin_digits,
+ cex = cex,
rel.height.middle = rel.height.middle,
ymax = ymax, ...)

Contact - Imprint