aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2020-12-21 06:02:10 +0100
committerJohannes Ranke <jranke@uni-bremen.de>2020-12-21 06:02:10 +0100
commitd28ce9f8ad6f9573e403ebd8eb637ecd5e5b0e02 (patch)
tree0a4d2a924eaf319dd686cc99f1705be3a5e2afe0
parent49280ed2e27ec072232684b27f9b05d7f3cc12c7 (diff)
plot.mixed: Possibility to overlay predictions
-rw-r--r--R/plot.mixed.mmkin.R37
-rw-r--r--docs/dev/pkgdown.yml2
-rw-r--r--docs/dev/reference/Rplot001.pngbin1011 -> 19395 bytes
-rw-r--r--docs/dev/reference/plot.mixed.mmkin-3.pngbin163488 -> 163536 bytes
-rw-r--r--docs/dev/reference/plot.mixed.mmkin-4.pngbin0 -> 166687 bytes
-rw-r--r--docs/dev/reference/plot.mixed.mmkin.html23
-rw-r--r--docs/dev/reference/saem.html57
-rw-r--r--man/plot.mixed.mmkin.Rd13
-rw-r--r--man/saem.Rd5
9 files changed, 95 insertions, 42 deletions
diff --git a/R/plot.mixed.mmkin.R b/R/plot.mixed.mmkin.R
index db29376e..109df283 100644
--- a/R/plot.mixed.mmkin.R
+++ b/R/plot.mixed.mmkin.R
@@ -8,6 +8,8 @@ utils::globalVariables("ds")
#' @inheritParams plot.mkinfit
#' @param standardized Should the residuals be standardized? Only takes effect if
#' `resplot = "time"`.
+#' @param pred_over Named list of alternative predictions as obtained
+#' from [mkinpredict] with a compatible [mkinmod].
#' @param rel.height.legend The relative height of the legend shown on top
#' @param rel.height.bottom The relative height of the bottom plot row
#' @param ymax Vector of maximum y axis values
@@ -37,8 +39,15 @@ utils::globalVariables("ds")
#' f_nlme <- nlme(f, control = list(pnlsMaxIter = 120, tolerance = 1e-3))
#' plot(f_nlme)
#'
-#' f_saem <- saem(f)
+#' f_saem <- saem(f, transformations = "saemix")
#' plot(f_saem)
+#'
+#' # We can overlay the two variants if we generate predictions
+#' pred_nlme <- mkinpredict(dfop_sfo,
+#' f_nlme$bparms.optim[-1],
+#' c(parent = f_nlme$bparms.optim[[1]], A1 = 0),
+#' seq(0, 180, by = 0.2))
+#' plot(f_saem, pred_over = list(nlme = pred_nlme))
#' }
#' @export
plot.mixed.mmkin <- function(x,
@@ -48,6 +57,7 @@ plot.mixed.mmkin <- function(x,
xlab = "Time",
xlim = range(x$data$time),
resplot = c("predicted", "time"),
+ pred_over = NULL,
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),
@@ -174,12 +184,19 @@ plot.mixed.mmkin <- function(x,
par(mar = c(0.1, 2.1, 0.6, 2.1))
+ # Empty plot with legend
+ if (!is.null(pred_over)) lty_over <- seq(2, length.out = length(pred_over))
+ else lty_over <- NULL
+ n_pop <- 1 + length(lty_over)
+ lty_pop <- c(1, lty_over)
+
plot(0, type = "n", axes = FALSE, ann = FALSE)
legend("center", bty = "n", ncol = ncol.legend,
- 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))
+ legend = c("Population", names(pred_over), ds_names[i]),
+ lty = c(lty_pop, lty_ds),
+ lwd = c(rep(2, n_pop), rep(1, length(i))),
+ col = c(rep(1, n_pop), col_ds),
+ pch = c(rep(NA, n_pop), pch_ds))
resplot <- match.arg(resplot)
@@ -206,10 +223,18 @@ plot.mixed.mmkin <- function(x,
}
plot(pred_pop$time, pred_pop[[obs_var]],
- type = "l", lwd = 2,
+ type = "l", lwd = 2, lty = lty_pop,
xlim = xlim, ylim = ylim_row,
xlab = xlab, ylab = obs_var, frame = frame)
+ if (!is.null(pred_over)) {
+ for (i_over in seq_along(pred_over)) {
+ pred_frame <- as.data.frame(pred_over[[i_over]])
+ lines(pred_frame$time, pred_frame[[obs_var]],
+ lwd = 2, lty = lty_over[i_over])
+ }
+ }
+
for (ds_i in seq_along(i)) {
points(subset(observed_row, ds == ds_names[ds_i], c("time", "value")),
col = col_ds[ds_i], pch = pch_ds[ds_i])
diff --git a/docs/dev/pkgdown.yml b/docs/dev/pkgdown.yml
index b3124589..85a358df 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-12-19T11:24Z
+last_built: 2020-12-21T04:57Z
urls:
reference: https://pkgdown.jrwb.de/mkin/reference
article: https://pkgdown.jrwb.de/mkin/articles
diff --git a/docs/dev/reference/Rplot001.png b/docs/dev/reference/Rplot001.png
index 17a35806..bca41e2c 100644
--- a/docs/dev/reference/Rplot001.png
+++ b/docs/dev/reference/Rplot001.png
Binary files differ
diff --git a/docs/dev/reference/plot.mixed.mmkin-3.png b/docs/dev/reference/plot.mixed.mmkin-3.png
index 3055c0c9..5e00afe6 100644
--- a/docs/dev/reference/plot.mixed.mmkin-3.png
+++ b/docs/dev/reference/plot.mixed.mmkin-3.png
Binary files differ
diff --git a/docs/dev/reference/plot.mixed.mmkin-4.png b/docs/dev/reference/plot.mixed.mmkin-4.png
new file mode 100644
index 00000000..6a5f3b9c
--- /dev/null
+++ b/docs/dev/reference/plot.mixed.mmkin-4.png
Binary files differ
diff --git a/docs/dev/reference/plot.mixed.mmkin.html b/docs/dev/reference/plot.mixed.mmkin.html
index 90ba9184..55c411e7 100644
--- a/docs/dev/reference/plot.mixed.mmkin.html
+++ b/docs/dev/reference/plot.mixed.mmkin.html
@@ -121,7 +121,7 @@
<ul class="nav navbar-nav navbar-right">
<li>
<a href="https://github.com/jranke/mkin/">
- <span class="fab fa fab fa-github fa-lg"></span>
+ <span class="fab fa-github fa-lg"></span>
</a>
</li>
@@ -156,6 +156,7 @@
xlab <span class='op'>=</span> <span class='st'>"Time"</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>,
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>,
+ pred_over <span class='op'>=</span> <span class='cn'>NULL</span>,
ymax <span class='op'>=</span> <span class='st'>"auto"</span>,
maxabs <span class='op'>=</span> <span class='st'>"auto"</span>,
ncol.legend <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/ifelse.html'>ifelse</a></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> <span class='op'>&lt;=</span> <span class='fl'>3</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> <span class='op'>+</span> <span class='fl'>1</span>, <span class='fu'><a href='https://rdrr.io/r/base/ifelse.html'>ifelse</a></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> <span class='op'>&lt;=</span> <span class='fl'>8</span>, <span class='fl'>3</span>, <span class='fl'>4</span><span class='op'>)</span><span class='op'>)</span>,
@@ -206,6 +207,11 @@ variables in the model.</p></td>
predicted values?</p></td>
</tr>
<tr>
+ <th>pred_over</th>
+ <td><p>Named list of alternative predictions as obtained
+from <a href='mkinpredict.html'>mkinpredict</a> with a compatible <a href='mkinmod.html'>mkinmod</a>.</p></td>
+ </tr>
+ <tr>
<th>ymax</th>
<td><p>Vector of maximum y axis values</p></td>
</tr>
@@ -275,13 +281,20 @@ corresponding model prediction lines for the different datasets.</p></td>
<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.mixed.mmkin-2.png' alt='' width='700' height='433' /></div><div class='input'>
-<span class='va'>f_saem</span> <span class='op'>&lt;-</span> <span class='fu'><a href='saem.html'>saem</a></span><span class='op'>(</span><span class='va'>f</span><span class='op'>)</span>
+<span class='va'>f_saem</span> <span class='op'>&lt;-</span> <span class='fu'><a href='saem.html'>saem</a></span><span class='op'>(</span><span class='va'>f</span>, transformations <span class='op'>=</span> <span class='st'>"saemix"</span><span class='op'>)</span>
</div><div class='output co'>#&gt; Running main SAEM algorithm
-#&gt; [1] "Fri Dec 11 15:37:36 2020"
+#&gt; [1] "Mon Dec 21 05:58:23 2020"
#&gt; ....
#&gt; Minimisation finished
-#&gt; [1] "Fri Dec 11 15:37:45 2020"</div><div class='input'><span class='fu'><a href='https://rdrr.io/r/graphics/plot.default.html'>plot</a></span><span class='op'>(</span><span class='va'>f_saem</span><span class='op'>)</span>
-</div><div class='img'><img src='plot.mixed.mmkin-3.png' alt='' width='700' height='433' /></div><div class='input'><span class='co'># }</span>
+#&gt; [1] "Mon Dec 21 05:58:30 2020"</div><div class='input'><span class='fu'><a href='https://rdrr.io/r/graphics/plot.default.html'>plot</a></span><span class='op'>(</span><span class='va'>f_saem</span><span class='op'>)</span>
+</div><div class='img'><img src='plot.mixed.mmkin-3.png' alt='' width='700' height='433' /></div><div class='input'>
+<span class='co'># We can overlay the two variants if we generate predictions</span>
+<span class='va'>pred_nlme</span> <span class='op'>&lt;-</span> <span class='fu'><a href='mkinpredict.html'>mkinpredict</a></span><span class='op'>(</span><span class='va'>dfop_sfo</span>,
+ <span class='va'>f_nlme</span><span class='op'>$</span><span class='va'>bparms.optim</span><span class='op'>[</span><span class='op'>-</span><span class='fl'>1</span><span class='op'>]</span>,
+ <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span><span class='op'>(</span>parent <span class='op'>=</span> <span class='va'>f_nlme</span><span class='op'>$</span><span class='va'>bparms.optim</span><span class='op'>[[</span><span class='fl'>1</span><span class='op'>]</span><span class='op'>]</span>, A1 <span class='op'>=</span> <span class='fl'>0</span><span class='op'>)</span>,
+ <span class='fu'><a href='https://rdrr.io/r/base/seq.html'>seq</a></span><span class='op'>(</span><span class='fl'>0</span>, <span class='fl'>180</span>, by <span class='op'>=</span> <span class='fl'>0.2</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_saem</span>, pred_over <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/list.html'>list</a></span><span class='op'>(</span>nlme <span class='op'>=</span> <span class='va'>pred_nlme</span><span class='op'>)</span><span class='op'>)</span>
+</div><div class='img'><img src='plot.mixed.mmkin-4.png' alt='' width='700' height='433' /></div><div class='input'><span class='co'># }</span>
</div></pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">
diff --git a/docs/dev/reference/saem.html b/docs/dev/reference/saem.html
index 67468f89..1e92e3fb 100644
--- a/docs/dev/reference/saem.html
+++ b/docs/dev/reference/saem.html
@@ -123,7 +123,7 @@ Expectation Maximisation algorithm (SAEM)." />
<ul class="nav navbar-nav navbar-right">
<li>
<a href="https://github.com/jranke/mkin/">
- <span class="fab fa fab fa-github fa-lg"></span>
+ <span class="fab fa-github fa-lg"></span>
</a>
</li>
@@ -157,6 +157,7 @@ Expectation Maximisation algorithm (SAEM).</p>
<span class='fu'>saem</span><span class='op'>(</span>
<span class='va'>object</span>,
transformations <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'>"mkin"</span>, <span class='st'>"saemix"</span><span class='op'>)</span>,
+ degparms_start <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/numeric.html'>numeric</a></span><span class='op'>(</span><span class='op'>)</span>,
solution_type <span class='op'>=</span> <span class='st'>"auto"</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>displayProgress <span class='op'>=</span> <span class='cn'>FALSE</span>, print <span class='op'>=</span> <span class='cn'>FALSE</span>, save <span class='op'>=</span> <span class='cn'>FALSE</span>, save.graphs <span class='op'>=</span>
<span class='cn'>FALSE</span><span class='op'>)</span>,
@@ -173,6 +174,7 @@ Expectation Maximisation algorithm (SAEM).</p>
<span class='va'>object</span>,
solution_type <span class='op'>=</span> <span class='st'>"auto"</span>,
transformations <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'>"mkin"</span>, <span class='st'>"saemix"</span><span class='op'>)</span>,
+ degparms_start <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/numeric.html'>numeric</a></span><span class='op'>(</span><span class='op'>)</span>,
verbose <span class='op'>=</span> <span class='cn'>FALSE</span>,
<span class='va'>...</span>
<span class='op'>)</span>
@@ -200,6 +202,11 @@ supported in cases where the initial concentration of the parent is not fixed,
SFO or DFOP is used for the parent and there is either no metabolite or one.</p></td>
</tr>
<tr>
+ <th>degparms_start</th>
+ <td><p>Parameter values given as a named numeric vector will
+be used to override the starting values obtained from the 'mmkin' object.</p></td>
+ </tr>
+ <tr>
<th>solution_type</th>
<td><p>Possibility to specify the solution type in case the
automatic choice is not desired</p></td>
@@ -260,36 +267,33 @@ using <a href='mmkin.html'>mmkin</a>.</p>
state.ini <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span><span class='op'>(</span>parent <span class='op'>=</span> <span class='fl'>100</span><span class='op'>)</span>, fixed_initials <span class='op'>=</span> <span class='st'>"parent"</span>, quiet <span class='op'>=</span> <span class='cn'>TRUE</span><span class='op'>)</span>
<span class='va'>f_saem_p0_fixed</span> <span class='op'>&lt;-</span> <span class='fu'>saem</span><span class='op'>(</span><span class='va'>f_mmkin_parent_p0_fixed</span><span class='op'>)</span>
</div><div class='output co'>#&gt; Running main SAEM algorithm
-#&gt; [1] "Wed Dec 16 18:27:30 2020"
+#&gt; [1] "Mon Dec 21 05:58:33 2020"
#&gt; ....
#&gt; Minimisation finished
-#&gt; [1] "Wed Dec 16 18:27:31 2020"</div><div class='input'>
+#&gt; [1] "Mon Dec 21 05:58:34 2020"</div><div class='input'>
<span class='va'>f_mmkin_parent</span> <span class='op'>&lt;-</span> <span class='fu'><a href='mmkin.html'>mmkin</a></span><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'>"SFO"</span>, <span class='st'>"FOMC"</span>, <span class='st'>"DFOP"</span><span class='op'>)</span>, <span class='va'>ds</span>, quiet <span class='op'>=</span> <span class='cn'>TRUE</span><span class='op'>)</span>
<span class='va'>f_saem_sfo</span> <span class='op'>&lt;-</span> <span class='fu'>saem</span><span class='op'>(</span><span class='va'>f_mmkin_parent</span><span class='op'>[</span><span class='st'>"SFO"</span>, <span class='op'>]</span><span class='op'>)</span>
</div><div class='output co'>#&gt; Running main SAEM algorithm
-#&gt; [1] "Wed Dec 16 18:27:33 2020"
+#&gt; [1] "Mon Dec 21 05:58:36 2020"
#&gt; ....
#&gt; Minimisation finished
-#&gt; [1] "Wed Dec 16 18:27:35 2020"</div><div class='input'><span class='va'>f_saem_fomc</span> <span class='op'>&lt;-</span> <span class='fu'>saem</span><span class='op'>(</span><span class='va'>f_mmkin_parent</span><span class='op'>[</span><span class='st'>"FOMC"</span>, <span class='op'>]</span><span class='op'>)</span>
+#&gt; [1] "Mon Dec 21 05:58:37 2020"</div><div class='input'><span class='va'>f_saem_fomc</span> <span class='op'>&lt;-</span> <span class='fu'>saem</span><span class='op'>(</span><span class='va'>f_mmkin_parent</span><span class='op'>[</span><span class='st'>"FOMC"</span>, <span class='op'>]</span><span class='op'>)</span>
</div><div class='output co'>#&gt; Running main SAEM algorithm
-#&gt; [1] "Wed Dec 16 18:27:35 2020"
+#&gt; [1] "Mon Dec 21 05:58:38 2020"
#&gt; ....
#&gt; Minimisation finished
-#&gt; [1] "Wed Dec 16 18:27:37 2020"</div><div class='input'><span class='va'>f_saem_dfop</span> <span class='op'>&lt;-</span> <span class='fu'>saem</span><span class='op'>(</span><span class='va'>f_mmkin_parent</span><span class='op'>[</span><span class='st'>"DFOP"</span>, <span class='op'>]</span><span class='op'>)</span>
+#&gt; [1] "Mon Dec 21 05:58:40 2020"</div><div class='input'><span class='va'>f_saem_dfop</span> <span class='op'>&lt;-</span> <span class='fu'>saem</span><span class='op'>(</span><span class='va'>f_mmkin_parent</span><span class='op'>[</span><span class='st'>"DFOP"</span>, <span class='op'>]</span><span class='op'>)</span>
</div><div class='output co'>#&gt; Running main SAEM algorithm
-#&gt; [1] "Wed Dec 16 18:27:37 2020"
+#&gt; [1] "Mon Dec 21 05:58:40 2020"
#&gt; ....
#&gt; Minimisation finished
-#&gt; [1] "Wed Dec 16 18:27:40 2020"</div><div class='input'>
+#&gt; [1] "Mon Dec 21 05:58:43 2020"</div><div class='input'>
<span class='co'># The returned saem.mmkin object contains an SaemixObject, therefore we can use</span>
<span class='co'># functions from saemix</span>
<span class='kw'><a href='https://rdrr.io/r/base/library.html'>library</a></span><span class='op'>(</span><span class='va'>saemix</span><span class='op'>)</span>
</div><div class='output co'>#&gt; <span class='message'>Package saemix, version 3.1.9000</span>
#&gt; <span class='message'> please direct bugs, questions and feedback to emmanuelle.comets@inserm.fr</span></div><div class='input'><span class='fu'><a href='https://rdrr.io/pkg/saemix/man/compare.saemix.html'>compare.saemix</a></span><span class='op'>(</span><span class='fu'><a href='https://rdrr.io/r/base/list.html'>list</a></span><span class='op'>(</span><span class='va'>f_saem_sfo</span><span class='op'>$</span><span class='va'>so</span>, <span class='va'>f_saem_fomc</span><span class='op'>$</span><span class='va'>so</span>, <span class='va'>f_saem_dfop</span><span class='op'>$</span><span class='va'>so</span><span class='op'>)</span><span class='op'>)</span>
-</div><div class='output co'>#&gt; Likelihoods computed by importance sampling </div><div class='output co'>#&gt; AIC BIC
-#&gt; 1 624.2484 622.2956
-#&gt; 2 467.7096 464.9757
-#&gt; 3 495.4373 491.9222</div><div class='input'><span class='fu'><a href='https://rdrr.io/pkg/saemix/man/plot-SaemixObject-method.html'>plot</a></span><span class='op'>(</span><span class='va'>f_saem_fomc</span><span class='op'>$</span><span class='va'>so</span>, plot.type <span class='op'>=</span> <span class='st'>"convergence"</span><span class='op'>)</span>
+</div><div class='output co'>#&gt; <span class='error'>Error in compare.saemix(list(f_saem_sfo$so, f_saem_fomc$so, f_saem_dfop$so)): 'compare.saemix' requires at least two models.</span></div><div class='input'><span class='fu'><a href='https://rdrr.io/pkg/saemix/man/plot-SaemixObject-method.html'>plot</a></span><span class='op'>(</span><span class='va'>f_saem_fomc</span><span class='op'>$</span><span class='va'>so</span>, plot.type <span class='op'>=</span> <span class='st'>"convergence"</span><span class='op'>)</span>
</div><div class='output co'>#&gt; Plotting convergence plots</div><div class='input'><span class='fu'><a href='https://rdrr.io/pkg/saemix/man/plot-SaemixObject-method.html'>plot</a></span><span class='op'>(</span><span class='va'>f_saem_fomc</span><span class='op'>$</span><span class='va'>so</span>, plot.type <span class='op'>=</span> <span class='st'>"individual.fit"</span><span class='op'>)</span>
</div><div class='img'><img src='saem-1.png' alt='' width='700' height='433' /></div><div class='output co'>#&gt; Plotting individual fits</div><div class='input'><span class='fu'><a href='https://rdrr.io/pkg/saemix/man/plot-SaemixObject-method.html'>plot</a></span><span class='op'>(</span><span class='va'>f_saem_fomc</span><span class='op'>$</span><span class='va'>so</span>, plot.type <span class='op'>=</span> <span class='st'>"npde"</span><span class='op'>)</span>
</div><div class='img'><img src='saem-2.png' alt='' width='700' height='433' /></div><div class='output co'>#&gt; Simulating data using nsim = 1000 simulated datasets
@@ -326,13 +330,11 @@ using <a href='mmkin.html'>mmkin</a>.</p>
<span class='va'>f_mmkin_parent_tc</span> <span class='op'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/r/stats/update.html'>update</a></span><span class='op'>(</span><span class='va'>f_mmkin_parent</span>, error_model <span class='op'>=</span> <span class='st'>"tc"</span><span class='op'>)</span>
<span class='va'>f_saem_fomc_tc</span> <span class='op'>&lt;-</span> <span class='fu'>saem</span><span class='op'>(</span><span class='va'>f_mmkin_parent_tc</span><span class='op'>[</span><span class='st'>"FOMC"</span>, <span class='op'>]</span><span class='op'>)</span>
</div><div class='output co'>#&gt; Running main SAEM algorithm
-#&gt; [1] "Wed Dec 16 18:27:43 2020"
+#&gt; [1] "Mon Dec 21 05:58:46 2020"
#&gt; ....
#&gt; Minimisation finished
-#&gt; [1] "Wed Dec 16 18:27:48 2020"</div><div class='input'><span class='fu'><a href='https://rdrr.io/pkg/saemix/man/compare.saemix.html'>compare.saemix</a></span><span class='op'>(</span><span class='fu'><a href='https://rdrr.io/r/base/list.html'>list</a></span><span class='op'>(</span><span class='va'>f_saem_fomc</span><span class='op'>$</span><span class='va'>so</span>, <span class='va'>f_saem_fomc_tc</span><span class='op'>$</span><span class='va'>so</span><span class='op'>)</span><span class='op'>)</span>
-</div><div class='output co'>#&gt; Likelihoods computed by importance sampling </div><div class='output co'>#&gt; AIC BIC
-#&gt; 1 467.7096 464.9757
-#&gt; 2 469.5208 466.3963</div><div class='input'>
+#&gt; [1] "Mon Dec 21 05:58:51 2020"</div><div class='input'><span class='fu'><a href='https://rdrr.io/pkg/saemix/man/compare.saemix.html'>compare.saemix</a></span><span class='op'>(</span><span class='fu'><a href='https://rdrr.io/r/base/list.html'>list</a></span><span class='op'>(</span><span class='va'>f_saem_fomc</span><span class='op'>$</span><span class='va'>so</span>, <span class='va'>f_saem_fomc_tc</span><span class='op'>$</span><span class='va'>so</span><span class='op'>)</span><span class='op'>)</span>
+</div><div class='output co'>#&gt; <span class='error'>Error in compare.saemix(list(f_saem_fomc$so, f_saem_fomc_tc$so)): 'compare.saemix' requires at least two models.</span></div><div class='input'>
<span class='va'>sfo_sfo</span> <span class='op'>&lt;-</span> <span class='fu'><a href='mkinmod.html'>mkinmod</a></span><span class='op'>(</span>parent <span class='op'>=</span> <span class='fu'><a href='mkinmod.html'>mkinsub</a></span><span class='op'>(</span><span class='st'>"SFO"</span>, <span class='st'>"A1"</span><span class='op'>)</span>,
A1 <span class='op'>=</span> <span class='fu'><a href='mkinmod.html'>mkinsub</a></span><span class='op'>(</span><span class='st'>"SFO"</span><span class='op'>)</span><span class='op'>)</span>
</div><div class='output co'>#&gt; <span class='message'>Temporary DLL for differentials generated and loaded</span></div><div class='input'><span class='va'>fomc_sfo</span> <span class='op'>&lt;-</span> <span class='fu'><a href='mkinmod.html'>mkinmod</a></span><span class='op'>(</span>parent <span class='op'>=</span> <span class='fu'><a href='mkinmod.html'>mkinsub</a></span><span class='op'>(</span><span class='st'>"FOMC"</span>, <span class='st'>"A1"</span><span class='op'>)</span>,
@@ -350,15 +352,15 @@ using <a href='mmkin.html'>mmkin</a>.</p>
<span class='co'># four minutes</span>
<span class='va'>f_saem_sfo_sfo</span> <span class='op'>&lt;-</span> <span class='fu'>saem</span><span class='op'>(</span><span class='va'>f_mmkin</span><span class='op'>[</span><span class='st'>"SFO-SFO"</span>, <span class='op'>]</span><span class='op'>)</span>
</div><div class='output co'>#&gt; Running main SAEM algorithm
-#&gt; [1] "Wed Dec 16 18:27:50 2020"
+#&gt; [1] "Mon Dec 21 05:58:53 2020"
#&gt; ....
#&gt; Minimisation finished
-#&gt; [1] "Wed Dec 16 18:27:55 2020"</div><div class='input'><span class='va'>f_saem_dfop_sfo</span> <span class='op'>&lt;-</span> <span class='fu'>saem</span><span class='op'>(</span><span class='va'>f_mmkin</span><span class='op'>[</span><span class='st'>"DFOP-SFO"</span>, <span class='op'>]</span><span class='op'>)</span>
+#&gt; [1] "Mon Dec 21 05:58:58 2020"</div><div class='input'><span class='va'>f_saem_dfop_sfo</span> <span class='op'>&lt;-</span> <span class='fu'>saem</span><span class='op'>(</span><span class='va'>f_mmkin</span><span class='op'>[</span><span class='st'>"DFOP-SFO"</span>, <span class='op'>]</span><span class='op'>)</span>
</div><div class='output co'>#&gt; Running main SAEM algorithm
-#&gt; [1] "Wed Dec 16 18:27:56 2020"
+#&gt; [1] "Mon Dec 21 05:58:59 2020"
#&gt; ....
#&gt; Minimisation finished
-#&gt; [1] "Wed Dec 16 18:28:05 2020"</div><div class='input'><span class='co'># We can use print, plot and summary methods to check the results</span>
+#&gt; [1] "Mon Dec 21 05:59:08 2020"</div><div class='input'><span class='co'># We can use print, plot and summary methods to check the results</span>
<span class='fu'><a href='https://rdrr.io/r/base/print.html'>print</a></span><span class='op'>(</span><span class='va'>f_saem_dfop_sfo</span><span class='op'>)</span>
</div><div class='output co'>#&gt; Kinetic nonlinear mixed-effects model fit by SAEM
#&gt; Structural model:
@@ -373,8 +375,6 @@ using <a href='mmkin.html'>mmkin</a>.</p>
#&gt; 170 observations of 2 variable(s) grouped in 5 datasets
#&gt;
#&gt; Likelihood computed by importance sampling
-#&gt;
-#&gt; LL by is "-407.78 (df=13)"
#&gt; AIC BIC logLik
#&gt; 841.6 836.5 -407.8
#&gt;
@@ -400,12 +400,11 @@ using <a href='mmkin.html'>mmkin</a>.</p>
#&gt; SD.log_k2 1.90634 0.70934 3.1033
#&gt; SD.g_qlogis 0.44771 -0.86417 1.7596</div><div class='input'><span class='fu'><a href='https://rdrr.io/pkg/saemix/man/plot-SaemixObject-method.html'>plot</a></span><span class='op'>(</span><span class='va'>f_saem_dfop_sfo</span><span class='op'>)</span>
</div><div class='img'><img src='saem-5.png' alt='' width='700' height='433' /></div><div class='input'><span class='fu'><a href='https://rdrr.io/pkg/saemix/man/summary-methods.html'>summary</a></span><span class='op'>(</span><span class='va'>f_saem_dfop_sfo</span>, data <span class='op'>=</span> <span class='cn'>TRUE</span><span class='op'>)</span>
-</div><div class='output co'>#&gt;
-#&gt; LL by is "-407.78 (df=13)"</div><div class='output co'>#&gt; saemix version used for fitting: 3.1.9000
+</div><div class='output co'>#&gt; saemix version used for fitting: 3.1.9000
#&gt; mkin version used for pre-fitting: 0.9.50.4
#&gt; R version used for fitting: 4.0.3
-#&gt; Date of fit: Wed Dec 16 18:28:06 2020
-#&gt; Date of summary: Wed Dec 16 18:28:06 2020
+#&gt; Date of fit: Mon Dec 21 05:59:09 2020
+#&gt; Date of summary: Mon Dec 21 05:59:09 2020
#&gt;
#&gt; Equations:
#&gt; d_parent/dt = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) * exp(-k2 *
@@ -420,7 +419,7 @@ using <a href='mmkin.html'>mmkin</a>.</p>
#&gt;
#&gt; Model predictions using solution type analytical
#&gt;
-#&gt; Fitted in 9.889 s using 300, 100 iterations
+#&gt; Fitted in 9.836 s using 300, 100 iterations
#&gt;
#&gt; Variance model: Constant variance
#&gt;
diff --git a/man/plot.mixed.mmkin.Rd b/man/plot.mixed.mmkin.Rd
index b90a4b3a..c7b2344f 100644
--- a/man/plot.mixed.mmkin.Rd
+++ b/man/plot.mixed.mmkin.Rd
@@ -12,6 +12,7 @@
xlab = "Time",
xlim = range(x$data$time),
resplot = c("predicted", "time"),
+ pred_over = NULL,
ymax = "auto",
maxabs = "auto",
ncol.legend = ifelse(length(i) <= 3, length(i) + 1, ifelse(length(i) <= 8, 3, 4)),
@@ -45,6 +46,9 @@ variables in the model.}
\item{resplot}{Should the residuals plotted against time or against
predicted values?}
+\item{pred_over}{Named list of alternative predictions as obtained
+from \link{mkinpredict} with a compatible \link{mkinmod}.}
+
\item{ymax}{Vector of maximum y axis values}
\item{maxabs}{Maximum absolute value of the residuals. This is used for the
@@ -90,8 +94,15 @@ plot(f[, 3:4], standardized = TRUE)
f_nlme <- nlme(f, control = list(pnlsMaxIter = 120, tolerance = 1e-3))
plot(f_nlme)
-f_saem <- saem(f)
+f_saem <- saem(f, transformations = "saemix")
plot(f_saem)
+
+# We can overlay the two variants if we generate predictions
+pred_nlme <- mkinpredict(dfop_sfo,
+ f_nlme$bparms.optim[-1],
+ c(parent = f_nlme$bparms.optim[[1]], A1 = 0),
+ seq(0, 180, by = 0.2))
+plot(f_saem, pred_over = list(nlme = pred_nlme))
}
}
\author{
diff --git a/man/saem.Rd b/man/saem.Rd
index dba948bb..775a8e7b 100644
--- a/man/saem.Rd
+++ b/man/saem.Rd
@@ -13,6 +13,7 @@ saem(object, ...)
\method{saem}{mmkin}(
object,
transformations = c("mkin", "saemix"),
+ degparms_start = numeric(),
solution_type = "auto",
control = list(displayProgress = FALSE, print = FALSE, save = FALSE, save.graphs =
FALSE),
@@ -28,6 +29,7 @@ saemix_model(
object,
solution_type = "auto",
transformations = c("mkin", "saemix"),
+ degparms_start = numeric(),
verbose = FALSE,
...
)
@@ -46,6 +48,9 @@ are done in 'saemix' for the supported cases. Currently this is only
supported in cases where the initial concentration of the parent is not fixed,
SFO or DFOP is used for the parent and there is either no metabolite or one.}
+\item{degparms_start}{Parameter values given as a named numeric vector will
+be used to override the starting values obtained from the 'mmkin' object.}
+
\item{solution_type}{Possibility to specify the solution type in case the
automatic choice is not desired}

Contact - Imprint