aboutsummaryrefslogtreecommitdiff
path: root/man/plot_mixed.Rd
blob: d3cee7c90b00d3cdca5bb64c1020050622b6142b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
% 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
}

Contact - Imprint