From aa74f5a30853fb0a15c99c283e072f08ee819149 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Mon, 9 Nov 2020 17:24:53 +0100 Subject: saemix.mmkin and nlme.mmkin inherit from mixed.mmkin With a plot method. The class mixed.mmkin is currently only a virtual class created to unify the plotting method. --- man/nlme.mmkin.Rd | 7 +-- man/plot.mixed.mmkin.Rd | 99 ++++++++++++++++++++++++++++++++++++++ man/plot_mixed.Rd | 123 ------------------------------------------------ man/saem.Rd | 5 +- 4 files changed, 106 insertions(+), 128 deletions(-) create mode 100644 man/plot.mixed.mmkin.Rd delete mode 100644 man/plot_mixed.Rd (limited to 'man') diff --git a/man/nlme.mmkin.Rd b/man/nlme.mmkin.Rd index 85bd74f6..9526a427 100644 --- a/man/nlme.mmkin.Rd +++ b/man/nlme.mmkin.Rd @@ -66,8 +66,8 @@ parameters taken from the mmkin object are used} \item{object}{An nlme.mmkin object to update} } \value{ -Upon success, a fitted nlme.mmkin object, which is an nlme object -with additional elements +Upon success, a fitted 'nlme.mmkin' object, which is an nlme object +with additional elements. It also inherits from 'mixed.mmkin'. } \description{ This functions sets up a nonlinear mixed effects model for an mmkin row @@ -150,5 +150,6 @@ endpoints(f_nlme_dfop) } } \seealso{ -\code{\link[=nlme_function]{nlme_function()}} +\code{\link[=nlme_function]{nlme_function()}}, \link{plot.mixed.mmkin}, \link{summary.nlme.mmkin}, +\link{parms.nlme.mmkin} } diff --git a/man/plot.mixed.mmkin.Rd b/man/plot.mixed.mmkin.Rd new file mode 100644 index 00000000..66e79f09 --- /dev/null +++ b/man/plot.mixed.mmkin.Rd @@ -0,0 +1,99 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/plot.mixed.mmkin.R +\name{plot.mixed.mmkin} +\alias{plot.mixed.mmkin} +\title{Plot predictions from a fitted nonlinear mixed model obtained via an mmkin row object} +\usage{ +\method{plot}{mixed.mmkin}( + x, + i = 1:ncol(x$mmkin), + obs_vars = names(x$mkinmod$map), + standardized = TRUE, + xlab = "Time", + xlim = range(x$data$time), + resplot = c("predicted", "time"), + ymax = "auto", + maxabs = "auto", + ncol.legend = ifelse(length(i) <= 3, length(i) + 1, ifelse(length(i) <= 8, 3, 4)), + nrow.legend = ceiling((length(i) + 1)/ncol.legend), + rel.height.legend = 0.03 + 0.08 * nrow.legend, + rel.height.bottom = 1.1, + pch_ds = 1:length(i), + col_ds = pch_ds + 1, + lty_ds = col_ds, + frame = TRUE, + ... +) +} +\arguments{ +\item{x}{An object of class \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} + +\item{obs_vars}{A character vector of names of the observed variables for +which the data and the model should be plotted. Defauls to all observed +variables in the model.} + +\item{standardized}{Should the residuals be standardized? Only takes effect if +\code{resplot = "time"}.} + +\item{xlab}{Label for the x axis.} + +\item{xlim}{Plot range in x direction.} + +\item{resplot}{Should the residuals plotted against time or against +predicted values?} + +\item{ymax}{Vector of maximum y axis values} + +\item{maxabs}{Maximum absolute value of the residuals. This is used for the +scaling of the y axis and defaults to "auto".} + +\item{ncol.legend}{Number of columns to use in the legend} + +\item{nrow.legend}{Number of rows to use in the legend} + +\item{rel.height.legend}{The relative height of the legend shown on top} + +\item{rel.height.bottom}{The relative height of the bottom plot row} + +\item{pch_ds}{Symbols to be used for plotting the data.} + +\item{col_ds}{Colors used for plotting the observed data and the +corresponding model prediction lines for the different datasets.} + +\item{lty_ds}{Line types to be used for the model predictions.} + +\item{frame}{Should a frame be drawn around the plots?} + +\item{...}{Further arguments passed to \code{\link{plot}}.} +} +\value{ +The function is called for its side effect. +} +\description{ +Plot predictions from a fitted nonlinear mixed model obtained via an mmkin row object +} +\examples{ +ds <- lapply(experimental_data_for_UBA_2019[6:10], + function(x) x$data[c("name", "time", "value")]) +names(ds) <- paste0("ds ", 6:10) +dfop_sfo <- mkinmod(parent = mkinsub("DFOP", "A1"), + A1 = mkinsub("SFO"), quiet = TRUE) +\dontrun{ +f <- mmkin(list("DFOP-SFO" = dfop_sfo), ds, quiet = TRUE) +plot(f[, 3:4], standardized = TRUE) + +# For this fit we need to increase pnlsMaxiter, and we increase the +# tolerance in order to speed up the fit for this example evaluation +f_nlme <- nlme(f, control = list(pnlsMaxIter = 120, tolerance = 1e-3)) +plot(f_nlme) + +f_saem <- saem(f) +plot(f_saem) +} +} +\author{ +Johannes Ranke +} diff --git a/man/plot_mixed.Rd b/man/plot_mixed.Rd deleted file mode 100644 index d3cee7c9..00000000 --- a/man/plot_mixed.Rd +++ /dev/null @@ -1,123 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/plot_mixed.R -\name{plot_mixed} -\alias{plot_mixed} -\alias{plot.saem.mmkin} -\alias{plot.nlme.mmkin} -\title{Plot predictions from a fitted nonlinear mixed model obtained via an mmkin row object} -\usage{ -\method{plot}{saem.mmkin}( - x, - i = 1:ncol(x$mmkin), - obs_vars = names(x$mkinmod$map), - standardized = TRUE, - xlab = "Time", - xlim = range(x$data$time), - resplot = c("predicted", "time"), - ymax = "auto", - maxabs = "auto", - ncol.legend = ifelse(length(i) <= 3, length(i) + 1, ifelse(length(i) <= 8, 3, 4)), - nrow.legend = ceiling((length(i) + 1)/ncol.legend), - rel.height.legend = 0.03 + 0.08 * nrow.legend, - rel.height.bottom = 1.1, - pch_ds = 1:length(i), - col_ds = pch_ds + 1, - lty_ds = col_ds, - frame = TRUE, - ... -) - -\method{plot}{nlme.mmkin}( - x, - i = 1:ncol(x$mmkin), - obs_vars = names(x$mkinmod$map), - standardized = TRUE, - xlab = "Time", - xlim = range(x$data$time), - resplot = c("predicted", "time"), - ymax = "auto", - maxabs = "auto", - ncol.legend = ifelse(length(i) <= 3, length(i) + 1, ifelse(length(i) <= 8, 3, 4)), - nrow.legend = ceiling((length(i) + 1)/ncol.legend), - rel.height.legend = 0.03 + 0.08 * nrow.legend, - rel.height.bottom = 1.1, - pch_ds = 1:length(i), - col_ds = pch_ds + 1, - lty_ds = col_ds, - frame = TRUE, - ... -) -} -\arguments{ -\item{x}{An object of class \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} - -\item{obs_vars}{A character vector of names of the observed variables for -which the data and the model should be plotted. Defauls to all observed -variables in the model.} - -\item{standardized}{Should the residuals be standardized? Only takes effect if -\code{resplot = "time"}.} - -\item{xlab}{Label for the x axis.} - -\item{xlim}{Plot range in x direction.} - -\item{resplot}{Should the residuals plotted against time or against -predicted values?} - -\item{ymax}{Vector of maximum y axis values} - -\item{maxabs}{Maximum absolute value of the residuals. This is used for the -scaling of the y axis and defaults to "auto".} - -\item{ncol.legend}{Number of columns to use in the legend} - -\item{nrow.legend}{Number of rows to use in the legend} - -\item{rel.height.legend}{The relative height of the legend shown on top} - -\item{rel.height.bottom}{The relative height of the bottom plot row} - -\item{pch_ds}{Symbols to be used for plotting the data.} - -\item{col_ds}{Colors used for plotting the observed data and the -corresponding model prediction lines for the different datasets.} - -\item{lty_ds}{Line types to be used for the model predictions.} - -\item{frame}{Should a frame be drawn around the plots?} - -\item{...}{Further arguments passed to \code{\link{plot}}.} -} -\value{ -The functions are called for their side effect. -} -\description{ -Plot predictions from a fitted nonlinear mixed model obtained via an mmkin row object -} -\examples{ -ds <- lapply(experimental_data_for_UBA_2019[6:10], - function(x) x$data[c("name", "time", "value")]) -names(ds) <- paste0("ds ", 6:10) -dfop_sfo <- mkinmod(parent = mkinsub("DFOP", "A1"), - A1 = mkinsub("SFO"), quiet = TRUE) -\dontrun{ -f <- mmkin(list("DFOP-SFO" = dfop_sfo), ds, quiet = TRUE) -plot(f[, 3:4], standardized = TRUE) - -library(nlme) -# For this fit we need to increase pnlsMaxiter, and we increase the -# tolerance in order to speed up the fit for this example evaluation -f_nlme <- nlme(f, control = list(pnlsMaxIter = 120, tolerance = 1e-3)) -plot(f_nlme) - -f_saem <- saem(f) -plot(f_saem) -} -} -\author{ -Johannes Ranke -} diff --git a/man/saem.Rd b/man/saem.Rd index 56b54fbf..17f777c4 100644 --- a/man/saem.Rd +++ b/man/saem.Rd @@ -44,7 +44,8 @@ by the saemix function?} } \value{ An S3 object of class 'saem.mmkin', containing the fitted -\link[saemix:SaemixObject-class]{saemix::SaemixObject} as a list component named 'so'. +\link[saemix:SaemixObject-class]{saemix::SaemixObject} as a list component named 'so'. The +object also inherits from 'mixed.mmkin'. An \link[saemix:SaemixModel-class]{saemix::SaemixModel} object. @@ -114,5 +115,5 @@ summary(f_saem_dfop_sfo, data = FALSE) } } \seealso{ -\link{summary.saem.mmkin} +\link{summary.saem.mmkin} \link{plot.mixed.mmkin} } -- cgit v1.2.1