Plot a fitted nonlinear mixed model obtained via an mmkin row object

# S3 method for nlme.mmkin
plot(
  x,
  i = 1:ncol(x$mmkin_orig),
  main = rownames(x$mmkin_orig),
  obs_vars = names(x$mkinmod$map),
  standardized = TRUE,
  xlab = "Time",
  ylab = "Observed",
  xlim = range(x$data$time),
  legends = 1,
  lpos = "topright",
  inset = c(0.05, 0.05),
  resplot = c("predicted", "time"),
  ymax = "auto",
  maxabs = "auto",
  cex = 0.7,
  rel.height.middle = 0.9,
  pch_ds = 1:length(i),
  col_ds = pch_ds + 1,
  lty_ds = col_ds,
  frame = TRUE,
  ...
)

Arguments

x

An object of class nlme.mmkin

i

A numeric index to select datasets for which to plot the nlme fit, in case plots get too large

main

The main title placed on the outer margin of the plot.

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.

standardized

Should the residuals be standardized? Only takes effect if resplot = "time".

xlab

Label for the x axis.

ylab

Label for the y axis.

xlim

Plot range in x direction.

legends

An index for the fits for which legends should be shown.

lpos

Position(s) of the legend(s). Passed to legend as the first argument. If not length one, this should be of the same length as the obs_var argument.

inset

Passed to legend if applicable.

resplot

Should the residuals plotted against time or against predicted values?

ymax

Vector of maximum y axis values

maxabs

Maximum absolute value of the residuals. This is used for the scaling of the y axis and defaults to "auto".

cex

Passed to the plot functions and mtext.

rel.height.middle

The relative height of the middle plot, if more than two rows of plots are shown.

pch_ds

Symbols to be used for plotting the data.

col_ds

Colors used for plotting the observed data and the corresponding model prediction lines for the different datasets.

lty_ds

Line types to be used for the model predictions.

frame

Should a frame be drawn around the plots?

...

Further arguments passed to plot.mkinfit and mkinresplot.

Value

The function is called for its side effect.

Author

Johannes Ranke

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) f <- mmkin(list("DFOP-SFO" = dfop_sfo), ds, quiet = TRUE, cores = 1) 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-4)) plot(f_nlme)