aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--R/plot.nlme.mmkin.R46
-rw-r--r--docs/dev/pkgdown.yml2
-rw-r--r--docs/dev/reference/Rplot002.pngbin63682 -> 64132 bytes
-rw-r--r--docs/dev/reference/plot.nlme.mmkin-2.pngbin177237 -> 179274 bytes
-rw-r--r--docs/dev/reference/plot.nlme.mmkin.html21
-rw-r--r--man/plot.nlme.mmkin.Rd15
6 files changed, 23 insertions, 61 deletions
diff --git a/R/plot.nlme.mmkin.R b/R/plot.nlme.mmkin.R
index 084099ac..2356070e 100644
--- a/R/plot.nlme.mmkin.R
+++ b/R/plot.nlme.mmkin.R
@@ -10,9 +10,7 @@ if(getRversion() >= '2.15.1') utils::globalVariables("ds")
#' @param legends An index for the fits for which legends should be shown.
#' @param standardized Should the residuals be standardized? Only takes effect if
#' `resplot = "time"`.
-#' @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.
+#' @param rel.height.bottom The relative height of the bottom plot row
#' @param ymax Vector of maximum y axis values
#' @param \dots Further arguments passed to \code{\link{plot.mkinfit}} and
#' \code{\link{mkinresplot}}.
@@ -36,20 +34,20 @@ if(getRversion() >= '2.15.1') utils::globalVariables("ds")
#' 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))
+#' f_nlme <- nlme(f, control = list(pnlsMaxIter = 120, tolerance = 1e-3))
#' plot(f_nlme)
#' @export
plot.nlme.mmkin <- function(x, i = 1:ncol(x$mmkin_orig),
- main = rownames(x$mmkin_orig),
+ main = NULL,
obs_vars = names(x$mkinmod$map),
standardized = TRUE,
- xlab = "Time", ylab = "Observed",
+ xlab = "Time",
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,
+ rel.height.bottom = 1.1,
pch_ds = 1:length(i),
col_ds = pch_ds + 1,
lty_ds = col_ds,
@@ -82,11 +80,7 @@ plot.nlme.mmkin <- function(x, i = 1:ncol(x$mmkin_orig),
# Set relative plot heights, so the first and the last plot are the norm
# and the middle plots (if n_plot_rows >2) are smaller by rel.height.middle
- rel.heights <- if (n_plot_rows > 2) {
- c(1, rep(rel.height.middle, n_plot_rows - 2), 1)
- } else {
- rep(1, n_plot_rows)
- }
+ rel.heights <- if (n_plot_rows > 1) c(rep(1, n_plot_rows - 1), rel.height.bottom) else 1
layout_matrix = matrix(1:n_plots,
n_plot_rows, 2, byrow = TRUE)
@@ -145,31 +139,18 @@ plot.nlme.mmkin <- function(x, i = 1:ncol(x$mmkin_orig),
ylim_row = c(0, ymax[plot_row])
}
- # Margins for top row of plots when we have more than one row
- # Reduce bottom margin by 2.1 - hides x axis legend
- if (plot_row == 1 & n_plot_rows > 1) {
- par(mar = c(3.0, 4.1, 4.1, 2.1))
- }
-
- # Margins for middle rows of plots, if any
- if (plot_row > 1 & plot_row < n_plot_rows) {
- # Reduce top margin by 2 after the first plot as we have no main title,
- # reduced plot height, therefore we need rel.height.middle in the layout
- par(mar = c(3.0, 4.1, 2.1, 2.1))
- }
-
# Margins for bottom row of plots when we have more than one row
- if (plot_row == n_plot_rows & n_plot_rows > 1) {
- # Restore bottom margin for last plot to show x axis legend
+ # This is the only row that needs to show the x axis legend
+ if (plot_row == n_plot_rows) {
par(mar = c(5.1, 4.1, 2.1, 2.1))
+ } else {
+ par(mar = c(3.0, 4.1, 2.1, 2.1))
}
plot(pred_pop$time, pred_pop[[obs_var]],
- main = obs_var,
type = "l", lwd = 2,
xlim = xlim, ylim = ylim_row,
- xlab = xlab, ylab = ylab, frame = frame,
- cex = cex)
+ xlab = xlab, ylab = obs_var, frame = frame)
for (ds_i in seq_along(i)) {
points(subset(observed_row, ds == ds_names[ds_i], c("time", "value")),
@@ -180,7 +161,7 @@ plot.nlme.mmkin <- function(x, i = 1:ncol(x$mmkin_orig),
if (plot_row %in% legends) {
legend(lpos, inset = inset,
- legend = c("Population mean", ds_names[i]),
+ legend = c("Population", ds_names[i]),
lty = c(1, lty_ds), lwd = c(2, rep(1, length(i))),
col = c(1, col_ds),
pch = c(NA, pch_ds))
@@ -193,9 +174,9 @@ plot.nlme.mmkin <- function(x, i = 1:ncol(x$mmkin_orig),
if (identical(resplot, "time")) {
plot(0, type = "n", xlim = xlim, xlab = "Time",
- main = obs_var,
ylim = c(-1.2 * maxabs, 1.2 * maxabs),
ylab = if (standardized) "Standardized residual" else "Residual")
+
abline(h = 0, lty = 2)
for (ds_i in seq_along(i)) {
@@ -206,7 +187,6 @@ plot.nlme.mmkin <- function(x, i = 1:ncol(x$mmkin_orig),
if (identical(resplot, "predicted")) {
plot(0, type = "n",
- main = obs_var,
xlim = c(0, max(pred_ds[[obs_var]])),
xlab = "Predicted",
ylim = c(-1.2 * maxabs, 1.2 * maxabs),
diff --git a/docs/dev/pkgdown.yml b/docs/dev/pkgdown.yml
index 8c97cd7c..61fa6e5d 100644
--- a/docs/dev/pkgdown.yml
+++ b/docs/dev/pkgdown.yml
@@ -10,7 +10,7 @@ articles:
web_only/NAFTA_examples: NAFTA_examples.html
web_only/benchmarks: benchmarks.html
web_only/compiled_models: compiled_models.html
-last_built: 2020-10-23T22:30Z
+last_built: 2020-10-23T23:38Z
urls:
reference: https://pkgdown.jrwb.de/mkin/reference
article: https://pkgdown.jrwb.de/mkin/articles
diff --git a/docs/dev/reference/Rplot002.png b/docs/dev/reference/Rplot002.png
index 71c768bd..cffa10c1 100644
--- a/docs/dev/reference/Rplot002.png
+++ b/docs/dev/reference/Rplot002.png
Binary files differ
diff --git a/docs/dev/reference/plot.nlme.mmkin-2.png b/docs/dev/reference/plot.nlme.mmkin-2.png
index 57128ade..4ec26146 100644
--- a/docs/dev/reference/plot.nlme.mmkin-2.png
+++ b/docs/dev/reference/plot.nlme.mmkin-2.png
Binary files differ
diff --git a/docs/dev/reference/plot.nlme.mmkin.html b/docs/dev/reference/plot.nlme.mmkin.html
index f17a23e3..c633e15a 100644
--- a/docs/dev/reference/plot.nlme.mmkin.html
+++ b/docs/dev/reference/plot.nlme.mmkin.html
@@ -151,11 +151,10 @@
<span class='fu'><a href='https://rdrr.io/r/graphics/plot.default.html'>plot</a></span><span class='op'>(</span>
<span class='va'>x</span>,
i <span class='op'>=</span> <span class='fl'>1</span><span class='op'>:</span><span class='fu'><a href='https://rdrr.io/r/base/nrow.html'>ncol</a></span><span class='op'>(</span><span class='va'>x</span><span class='op'>$</span><span class='va'>mmkin_orig</span><span class='op'>)</span>,
- main <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/colnames.html'>rownames</a></span><span class='op'>(</span><span class='va'>x</span><span class='op'>$</span><span class='va'>mmkin_orig</span><span class='op'>)</span>,
+ main <span class='op'>=</span> <span class='cn'>NULL</span>,
obs_vars <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/names.html'>names</a></span><span class='op'>(</span><span class='va'>x</span><span class='op'>$</span><span class='va'>mkinmod</span><span class='op'>$</span><span class='va'>map</span><span class='op'>)</span>,
standardized <span class='op'>=</span> <span class='cn'>TRUE</span>,
xlab <span class='op'>=</span> <span class='st'>"Time"</span>,
- ylab <span class='op'>=</span> <span class='st'>"Observed"</span>,
xlim <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/range.html'>range</a></span><span class='op'>(</span><span class='va'>x</span><span class='op'>$</span><span class='va'>data</span><span class='op'>$</span><span class='va'>time</span><span class='op'>)</span>,
legends <span class='op'>=</span> <span class='fl'>1</span>,
lpos <span class='op'>=</span> <span class='st'>"topright"</span>,
@@ -163,8 +162,7 @@
resplot <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span><span class='op'>(</span><span class='st'>"predicted"</span>, <span class='st'>"time"</span><span class='op'>)</span>,
ymax <span class='op'>=</span> <span class='st'>"auto"</span>,
maxabs <span class='op'>=</span> <span class='st'>"auto"</span>,
- cex <span class='op'>=</span> <span class='fl'>0.7</span>,
- rel.height.middle <span class='op'>=</span> <span class='fl'>0.9</span>,
+ rel.height.bottom <span class='op'>=</span> <span class='fl'>1.1</span>,
pch_ds <span class='op'>=</span> <span class='fl'>1</span><span class='op'>:</span><span class='fu'><a href='https://rdrr.io/r/base/length.html'>length</a></span><span class='op'>(</span><span class='va'>i</span><span class='op'>)</span>,
col_ds <span class='op'>=</span> <span class='va'>pch_ds</span> <span class='op'>+</span> <span class='fl'>1</span>,
lty_ds <span class='op'>=</span> <span class='va'>col_ds</span>,
@@ -204,10 +202,6 @@ variables in the model.</p></td>
<td><p>Label for the x axis.</p></td>
</tr>
<tr>
- <th>ylab</th>
- <td><p>Label for the y axis.</p></td>
- </tr>
- <tr>
<th>xlim</th>
<td><p>Plot range in x direction.</p></td>
</tr>
@@ -240,13 +234,8 @@ predicted values?</p></td>
scaling of the y axis and defaults to "auto".</p></td>
</tr>
<tr>
- <th>cex</th>
- <td><p>Passed to the plot functions and <code><a href='https://rdrr.io/r/graphics/mtext.html'>mtext</a></code>.</p></td>
- </tr>
- <tr>
- <th>rel.height.middle</th>
- <td><p>The relative height of the middle plot, if more
-than two rows of plots are shown.</p></td>
+ <th>rel.height.bottom</th>
+ <td><p>The relative height of the bottom plot row</p></td>
</tr>
<tr>
<th>pch_ds</th>
@@ -290,7 +279,7 @@ corresponding model prediction lines for the different datasets.</p></td>
</div><div class='img'><img src='plot.nlme.mmkin-1.png' alt='' width='700' height='433' /></div><div class='input'><span class='kw'><a href='https://rdrr.io/r/base/library.html'>library</a></span><span class='op'>(</span><span class='va'><a href='https://svn.r-project.org/R-packages/trunk/nlme/'>nlme</a></span><span class='op'>)</span>
<span class='co'># For this fit we need to increase pnlsMaxiter, and we increase the</span>
<span class='co'># tolerance in order to speed up the fit for this example evaluation</span>
-<span class='va'>f_nlme</span> <span class='op'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/pkg/nlme/man/nlme.html'>nlme</a></span><span class='op'>(</span><span class='va'>f</span>, control <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/list.html'>list</a></span><span class='op'>(</span>pnlsMaxIter <span class='op'>=</span> <span class='fl'>120</span>, tolerance <span class='op'>=</span> <span class='fl'>1e-4</span><span class='op'>)</span><span class='op'>)</span>
+<span class='va'>f_nlme</span> <span class='op'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/pkg/nlme/man/nlme.html'>nlme</a></span><span class='op'>(</span><span class='va'>f</span>, control <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/list.html'>list</a></span><span class='op'>(</span>pnlsMaxIter <span class='op'>=</span> <span class='fl'>120</span>, tolerance <span class='op'>=</span> <span class='fl'>1e-3</span><span class='op'>)</span><span class='op'>)</span>
<span class='fu'><a href='https://rdrr.io/r/graphics/plot.default.html'>plot</a></span><span class='op'>(</span><span class='va'>f_nlme</span><span class='op'>)</span>
</div><div class='img'><img src='plot.nlme.mmkin-2.png' alt='' width='700' height='433' /></div></pre>
</div>
diff --git a/man/plot.nlme.mmkin.Rd b/man/plot.nlme.mmkin.Rd
index d1fde212..5f6e4ed3 100644
--- a/man/plot.nlme.mmkin.Rd
+++ b/man/plot.nlme.mmkin.Rd
@@ -7,11 +7,10 @@
\method{plot}{nlme.mmkin}(
x,
i = 1:ncol(x$mmkin_orig),
- main = rownames(x$mmkin_orig),
+ main = NULL,
obs_vars = names(x$mkinmod$map),
standardized = TRUE,
xlab = "Time",
- ylab = "Observed",
xlim = range(x$data$time),
legends = 1,
lpos = "topright",
@@ -19,8 +18,7 @@
resplot = c("predicted", "time"),
ymax = "auto",
maxabs = "auto",
- cex = 0.7,
- rel.height.middle = 0.9,
+ rel.height.bottom = 1.1,
pch_ds = 1:length(i),
col_ds = pch_ds + 1,
lty_ds = col_ds,
@@ -45,8 +43,6 @@ variables in the model.}
\item{xlab}{Label for the x axis.}
-\item{ylab}{Label for the y axis.}
-
\item{xlim}{Plot range in x direction.}
\item{legends}{An index for the fits for which legends should be shown.}
@@ -65,10 +61,7 @@ predicted values?}
\item{maxabs}{Maximum absolute value of the residuals. This is used for the
scaling of the y axis and defaults to "auto".}
-\item{cex}{Passed to the plot functions and \code{\link{mtext}}.}
-
-\item{rel.height.middle}{The relative height of the middle plot, if more
-than two rows of plots are shown.}
+\item{rel.height.bottom}{The relative height of the bottom plot row}
\item{pch_ds}{Symbols to be used for plotting the data.}
@@ -99,7 +92,7 @@ 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))
+f_nlme <- nlme(f, control = list(pnlsMaxIter = 120, tolerance = 1e-3))
plot(f_nlme)
}
\author{

Contact - Imprint