Showing 1 of 6 files from the diff.

@@ -10,9 +10,7 @@
Loading
10 10
#' @param legends An index for the fits for which legends should be shown.
11 11
#' @param standardized Should the residuals be standardized? Only takes effect if
12 12
#'   `resplot = "time"`.
13 -
#' @param cex Passed to the plot functions and \code{\link{mtext}}.
14 -
#' @param rel.height.middle The relative height of the middle plot, if more
15 -
#'   than two rows of plots are shown.
13 +
#' @param rel.height.bottom The relative height of the bottom plot row
16 14
#' @param ymax Vector of maximum y axis values
17 15
#' @param \dots Further arguments passed to \code{\link{plot.mkinfit}} and
18 16
#'   \code{\link{mkinresplot}}.
@@ -36,20 +34,20 @@
Loading
36 34
#' library(nlme)
37 35
#' # For this fit we need to increase pnlsMaxiter, and we increase the
38 36
#' # tolerance in order to speed up the fit for this example evaluation
39 -
#' f_nlme <- nlme(f, control = list(pnlsMaxIter = 120, tolerance = 1e-4))
37 +
#' f_nlme <- nlme(f, control = list(pnlsMaxIter = 120, tolerance = 1e-3))
40 38
#' plot(f_nlme)
41 39
#' @export
42 40
plot.nlme.mmkin <- function(x, i = 1:ncol(x$mmkin_orig),
43 -
  main = rownames(x$mmkin_orig),
41 +
  main = NULL,
44 42
  obs_vars = names(x$mkinmod$map),
45 43
  standardized = TRUE,
46 -
  xlab = "Time", ylab = "Observed",
44 +
  xlab = "Time",
47 45
  xlim = range(x$data$time),
48 46
  legends = 1,
49 47
  lpos = "topright", inset = c(0.05, 0.05),
50 48
  resplot = c("predicted", "time"),
51 49
  ymax = "auto", maxabs = "auto",
52 -
  cex = 0.7, rel.height.middle = 0.9,
50 +
  rel.height.bottom = 1.1,
53 51
  pch_ds = 1:length(i),
54 52
  col_ds = pch_ds + 1,
55 53
  lty_ds = col_ds,
@@ -82,11 +80,7 @@
Loading
82 80
83 81
  # Set relative plot heights, so the first and the last plot are the norm
84 82
  # and the middle plots (if n_plot_rows >2) are smaller by rel.height.middle
85 -
  rel.heights <- if (n_plot_rows > 2) {
86 -
    c(1, rep(rel.height.middle, n_plot_rows - 2), 1)
87 -
  } else {
88 -
    rep(1, n_plot_rows)
89 -
  }
83 +
  rel.heights <- if (n_plot_rows > 1) c(rep(1, n_plot_rows - 1), rel.height.bottom) else 1
90 84
91 85
  layout_matrix = matrix(1:n_plots,
92 86
    n_plot_rows, 2, byrow = TRUE)
@@ -145,31 +139,18 @@
Loading
145 139
      ylim_row = c(0, ymax[plot_row])
146 140
    }
147 141
148 -
    # Margins for top row of plots when we have more than one row
149 -
    # Reduce bottom margin by 2.1 - hides x axis legend
150 -
    if (plot_row == 1 & n_plot_rows > 1) {
151 -
      par(mar = c(3.0, 4.1, 4.1, 2.1))
152 -
    }
153 -
154 -
    # Margins for middle rows of plots, if any
155 -
    if (plot_row > 1 & plot_row < n_plot_rows) {
156 -
      # Reduce top margin by 2 after the first plot as we have no main title,
157 -
      # reduced plot height, therefore we need rel.height.middle in the layout
158 -
      par(mar = c(3.0, 4.1, 2.1, 2.1))
159 -
    }
160 -
161 142
    # Margins for bottom row of plots when we have more than one row
162 -
    if (plot_row == n_plot_rows & n_plot_rows > 1) {
163 -
      # Restore bottom margin for last plot to show x axis legend
143 +
    # This is the only row that needs to show the x axis legend
144 +
    if (plot_row == n_plot_rows) {
164 145
      par(mar = c(5.1, 4.1, 2.1, 2.1))
146 +
    } else {
147 +
      par(mar = c(3.0, 4.1, 2.1, 2.1))
165 148
    }
166 149
167 150
    plot(pred_pop$time, pred_pop[[obs_var]],
168 -
      main = obs_var,
169 151
      type = "l", lwd = 2,
170 152
      xlim = xlim, ylim = ylim_row,
171 -
      xlab = xlab, ylab = ylab, frame = frame,
172 -
      cex = cex)
153 +
      xlab = xlab, ylab = obs_var, frame = frame)
173 154
174 155
    for (ds_i in seq_along(i)) {
175 156
      points(subset(observed_row, ds == ds_names[ds_i], c("time", "value")),
@@ -180,7 +161,7 @@
Loading
180 161
181 162
    if (plot_row %in% legends) {
182 163
      legend(lpos, inset = inset,
183 -
        legend = c("Population mean", ds_names[i]),
164 +
        legend = c("Population", ds_names[i]),
184 165
        lty = c(1, lty_ds), lwd = c(2, rep(1, length(i))),
185 166
        col = c(1, col_ds),
186 167
        pch = c(NA, pch_ds))
@@ -193,9 +174,9 @@
Loading
193 174
194 175
    if (identical(resplot, "time")) {
195 176
      plot(0, type = "n", xlim = xlim, xlab = "Time",
196 -
        main = obs_var,
197 177
        ylim = c(-1.2 * maxabs, 1.2 * maxabs),
198 178
        ylab = if (standardized) "Standardized residual" else "Residual")
179 +
199 180
      abline(h = 0, lty = 2)
200 181
201 182
      for (ds_i in seq_along(i)) {
@@ -206,7 +187,6 @@
Loading
206 187
207 188
    if (identical(resplot, "predicted")) {
208 189
      plot(0, type = "n",
209 -
        main = obs_var,
210 190
        xlim = c(0, max(pred_ds[[obs_var]])),
211 191
        xlab = "Predicted",
212 192
        ylim = c(-1.2 * maxabs, 1.2 * maxabs),
Files Coverage
R 84.09%
Project Totals (39 files) 84.09%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading