aboutsummaryrefslogtreecommitdiff
path: root/docs/dev/articles/web_only/dimethenamid_2018.html
diff options
context:
space:
mode:
Diffstat (limited to 'docs/dev/articles/web_only/dimethenamid_2018.html')
-rw-r--r--docs/dev/articles/web_only/dimethenamid_2018.html274
1 files changed, 230 insertions, 44 deletions
diff --git a/docs/dev/articles/web_only/dimethenamid_2018.html b/docs/dev/articles/web_only/dimethenamid_2018.html
index 26b352e1..aa84435d 100644
--- a/docs/dev/articles/web_only/dimethenamid_2018.html
+++ b/docs/dev/articles/web_only/dimethenamid_2018.html
@@ -101,7 +101,7 @@
<h1 data-toc-skip>Example evaluations of the dimethenamid data from 2018</h1>
<h4 class="author">Johannes Ranke</h4>
- <h4 class="date">Last change 17 September 2021, built on 17 Sep 2021</h4>
+ <h4 class="date">Last change 27 September 2021, built on 27 Sep 2021</h4>
<small class="dont-index">Source: <a href="https://github.com/jranke/mkin/blob/master/vignettes/web_only/dimethenamid_2018.rmd"><code>vignettes/web_only/dimethenamid_2018.rmd</code></a></small>
<div class="hidden name"><code>dimethenamid_2018.rmd</code></div>
@@ -174,7 +174,7 @@
<div id="nlme" class="section level3">
<h3 class="hasAnchor">
<a href="#nlme" class="anchor"></a>nlme</h3>
-<p>The nlme package was the first R extension providing facilities to fit nonlinear mixed-effects models. We would like to do model selection from all four combinations of degradation models and error models based on the AIC. However, fitting the DFOP model with constant variance and using default control parameters results in an error, signalling that the maximum number of 50 iterations was reached, potentially indicating overparameterisation. However, the algorithm converges when the two-component error model is used in combination with the DFOP model. This can be explained by the fact that the smaller residues observed at later sampling times get more weight when using the two-component error model which will counteract the tendency of the algorithm to try parameter combinations unsuitable for fitting these data.</p>
+<p>The nlme package was the first R extension providing facilities to fit nonlinear mixed-effects models. We would like to do model selection from all four combinations of degradation models and error models based on the AIC. However, fitting the DFOP model with constant variance and using default control parameters results in an error, signalling that the maximum number of 50 iterations was reached, potentially indicating overparameterisation. Nevertheless, the algorithm converges when the two-component error model is used in combination with the DFOP model. This can be explained by the fact that the smaller residues observed at later sampling times get more weight when using the two-component error model which will counteract the tendency of the algorithm to try parameter combinations unsuitable for fitting these data.</p>
<div class="sourceCode" id="cb7"><pre class="downlit sourceCode r">
<code class="sourceCode R"><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="va">f_parent_nlme_sfo_const</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_parent_mkin_const</span><span class="op">[</span><span class="st">"SFO"</span>, <span class="op">]</span><span class="op">)</span>
@@ -182,7 +182,7 @@
<span class="va">f_parent_nlme_sfo_tc</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_parent_mkin_tc</span><span class="op">[</span><span class="st">"SFO"</span>, <span class="op">]</span><span class="op">)</span>
<span class="va">f_parent_nlme_dfop_tc</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_parent_mkin_tc</span><span class="op">[</span><span class="st">"DFOP"</span>, <span class="op">]</span><span class="op">)</span></code></pre></div>
<p>Note that a certain degree of overparameterisation is also indicated by a warning obtained when fitting DFOP with the two-component error model (‘false convergence’ in the ‘LME step’ in iteration 3). However, as this warning does not occur in later iterations, and specifically not in the last of the 6 iterations, we can ignore this warning.</p>
-<p>The model comparison function of the nlme package can directly be applied to these fits showing a much lower AIC for the DFOP model fitted with the two-component error model. Also, the likelihood ratio test indicates that this difference is significant. as the p-value is below 0.0001.</p>
+<p>The model comparison function of the nlme package can directly be applied to these fits showing a much lower AIC for the DFOP model fitted with the two-component error model. Also, the likelihood ratio test indicates that this difference is significant as the p-value is below 0.0001.</p>
<div class="sourceCode" id="cb8"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/stats/anova.html">anova</a></span><span class="op">(</span>
<span class="va">f_parent_nlme_sfo_const</span>, <span class="va">f_parent_nlme_sfo_tc</span>, <span class="va">f_parent_nlme_dfop_tc</span>
@@ -216,6 +216,8 @@ f_parent_nlme_dfop_tc 3 10 671.91 702.34 -325.96 2 vs 3 134.69 &lt;.0001
<div class="sourceCode" id="cb12"><pre class="downlit sourceCode r">
<code class="sourceCode R"><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>
<span class="va">saemix_control</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/pkg/saemix/man/saemixControl.html">saemixControl</a></span><span class="op">(</span>nbiter.saemix <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="fl">800</span>, <span class="fl">300</span><span class="op">)</span>, nb.chains <span class="op">=</span> <span class="fl">15</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>, displayProgress <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span>
+<span class="va">saemix_control_10k</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/pkg/saemix/man/saemixControl.html">saemixControl</a></span><span class="op">(</span>nbiter.saemix <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="fl">10000</span>, <span class="fl">1000</span><span class="op">)</span>, nb.chains <span class="op">=</span> <span class="fl">15</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>, displayProgress <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></code></pre></div>
<p>The convergence plot for the SFO model using constant variance is shown below.</p>
<div class="sourceCode" id="cb13"><pre class="downlit sourceCode r">
@@ -229,35 +231,65 @@ f_parent_nlme_dfop_tc 3 10 671.91 702.34 -325.96 2 vs 3 134.69 &lt;.0001
control <span class="op">=</span> <span class="va">saemix_control</span>, transformations <span class="op">=</span> <span class="st">"saemix"</span><span class="op">)</span>
<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_parent_saemix_sfo_tc</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></code></pre></div>
<p><img src="dimethenamid_2018_files/figure-html/f_parent_saemix_sfo_tc-1.png" width="700"></p>
-<p>When fitting the DFOP model with constant variance, parameter convergence is not as unambiguous (see the failure of nlme with the default number of iterations above). Therefore, the number of iterations in the first phase of the algorithm was increased, leading to visually satisfying convergence.</p>
+<p>When fitting the DFOP model with constant variance (see below), parameter convergence is not as unambiguous.</p>
<div class="sourceCode" id="cb15"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">f_parent_saemix_dfop_const</span> <span class="op">&lt;-</span> <span class="fu">mkin</span><span class="fu">::</span><span class="fu"><a href="../../reference/saem.html">saem</a></span><span class="op">(</span><span class="va">f_parent_mkin_const</span><span class="op">[</span><span class="st">"DFOP"</span>, <span class="op">]</span>, quiet <span class="op">=</span> <span class="cn">TRUE</span>,
control <span class="op">=</span> <span class="va">saemix_control</span>, transformations <span class="op">=</span> <span class="st">"saemix"</span><span class="op">)</span>
<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_parent_saemix_dfop_const</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></code></pre></div>
<p><img src="dimethenamid_2018_files/figure-html/f_parent_saemix_dfop_const-1.png" width="700"></p>
-<p>The same applies in the case where the DFOP model is fitted with the two-component error model. Convergence of the variance of k2 is enhanced by using the two-component error, it remains more or less stable already after 200 iterations of the first phase.</p>
+<p>This is improved when the DFOP model is fitted with the two-component error model. Convergence of the variance of k2 is enhanced, it remains more or less stable already after 200 iterations of the first phase.</p>
<div class="sourceCode" id="cb16"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">f_parent_saemix_dfop_tc</span> <span class="op">&lt;-</span> <span class="fu">mkin</span><span class="fu">::</span><span class="fu"><a href="../../reference/saem.html">saem</a></span><span class="op">(</span><span class="va">f_parent_mkin_tc</span><span class="op">[</span><span class="st">"DFOP"</span>, <span class="op">]</span>, quiet <span class="op">=</span> <span class="cn">TRUE</span>,
control <span class="op">=</span> <span class="va">saemix_control</span>, transformations <span class="op">=</span> <span class="st">"saemix"</span><span class="op">)</span>
<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_parent_saemix_dfop_tc</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></code></pre></div>
-<p><img src="dimethenamid_2018_files/figure-html/f_parent_saemix_dfop_tc-1.png" width="700"> The four combinations and including the variations of the DFOP/tc combination can be compared using the model comparison function from the saemix package:</p>
+<p><img src="dimethenamid_2018_files/figure-html/f_parent_saemix_dfop_tc-1.png" width="700"></p>
+<p>We also check if using many more iterations (10 000 for the first and 1000 for the second phase) improve the result in a significant way. The AIC values obtained are compared further below.</p>
<div class="sourceCode" id="cb17"><pre class="downlit sourceCode r">
-<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/pkg/saemix/man/compare.saemix.html">compare.saemix</a></span><span class="op">(</span>
+<code class="sourceCode R"><span class="va">f_parent_saemix_dfop_tc_10k</span> <span class="op">&lt;-</span> <span class="fu">mkin</span><span class="fu">::</span><span class="fu"><a href="../../reference/saem.html">saem</a></span><span class="op">(</span><span class="va">f_parent_mkin_tc</span><span class="op">[</span><span class="st">"DFOP"</span>, <span class="op">]</span>, quiet <span class="op">=</span> <span class="cn">TRUE</span>,
+ control <span class="op">=</span> <span class="va">saemix_control_10k</span>, transformations <span class="op">=</span> <span class="st">"saemix"</span><span class="op">)</span>
+<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_parent_saemix_dfop_tc_10k</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></code></pre></div>
+<p><img src="dimethenamid_2018_files/figure-html/f_parent_saemix_dfop_tc_10k-1.png" width="700"></p>
+<p>An alternative way to fit DFOP in combination with the two-component error model is to use the model formulation with transformed parameters as used per default in mkin.</p>
+<div class="sourceCode" id="cb18"><pre class="downlit sourceCode r">
+<code class="sourceCode R"><span class="va">f_parent_saemix_dfop_tc_mkin</span> <span class="op">&lt;-</span> <span class="fu">mkin</span><span class="fu">::</span><span class="fu"><a href="../../reference/saem.html">saem</a></span><span class="op">(</span><span class="va">f_parent_mkin_tc</span><span class="op">[</span><span class="st">"DFOP"</span>, <span class="op">]</span>, quiet <span class="op">=</span> <span class="cn">TRUE</span>,
+ control <span class="op">=</span> <span class="va">saemix_control</span>, transformations <span class="op">=</span> <span class="st">"mkin"</span><span class="op">)</span>
+<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_parent_saemix_dfop_tc_mkin</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></code></pre></div>
+<p><img src="dimethenamid_2018_files/figure-html/f_parent_saemix_dfop_tc_mkin-1.png" width="700"></p>
+<p>As the convergence plots do not clearly indicate that the algorithm has converged, we again use a much larger number of iterations, which leads to satisfactory convergence (see below).</p>
+<div class="sourceCode" id="cb19"><pre class="downlit sourceCode r">
+<code class="sourceCode R"><span class="va">f_parent_saemix_dfop_tc_mkin_10k</span> <span class="op">&lt;-</span> <span class="fu">mkin</span><span class="fu">::</span><span class="fu"><a href="../../reference/saem.html">saem</a></span><span class="op">(</span><span class="va">f_parent_mkin_tc</span><span class="op">[</span><span class="st">"DFOP"</span>, <span class="op">]</span>, quiet <span class="op">=</span> <span class="cn">TRUE</span>,
+ control <span class="op">=</span> <span class="va">saemix_control_10k</span>, transformations <span class="op">=</span> <span class="st">"mkin"</span><span class="op">)</span>
+<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_parent_saemix_dfop_tc_mkin_10k</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></code></pre></div>
+<p><img src="dimethenamid_2018_files/figure-html/f_parent_saemix_dfop_tc_mkin_10k-1.png" width="700"></p>
+<p>The four combinations (SFO/const, SFO/tc, DFOP/const and DFOP/tc), including the variations of the DFOP/tc combination can be compared using the model comparison function of the saemix package:</p>
+<div class="sourceCode" id="cb20"><pre class="downlit sourceCode r">
+<code class="sourceCode R"><span class="va">AIC_parent_saemix</span> <span class="op">&lt;-</span> <span class="fu">saemix</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/saemix/man/compare.saemix.html">compare.saemix</a></span><span class="op">(</span>
<span class="va">f_parent_saemix_sfo_const</span><span class="op">$</span><span class="va">so</span>,
<span class="va">f_parent_saemix_sfo_tc</span><span class="op">$</span><span class="va">so</span>,
<span class="va">f_parent_saemix_dfop_const</span><span class="op">$</span><span class="va">so</span>,
- <span class="va">f_parent_saemix_dfop_tc</span><span class="op">$</span><span class="va">so</span><span class="op">)</span></code></pre></div>
+ <span class="va">f_parent_saemix_dfop_tc</span><span class="op">$</span><span class="va">so</span>,
+ <span class="va">f_parent_saemix_dfop_tc_10k</span><span class="op">$</span><span class="va">so</span>,
+ <span class="va">f_parent_saemix_dfop_tc_mkin</span><span class="op">$</span><span class="va">so</span>,
+ <span class="va">f_parent_saemix_dfop_tc_mkin_10k</span><span class="op">$</span><span class="va">so</span><span class="op">)</span></code></pre></div>
<pre><code>Likelihoods calculated by importance sampling</code></pre>
-<pre><code> AIC BIC
-1 796.37 795.33
-2 798.37 797.13
-3 713.16 711.28
-4 666.10 664.01</code></pre>
-<p>As in the case of nlme fits, the DFOP model fitted with two-component error (number 4) gives the lowest AIC. Using more iterations and/or more chains does not have a large influence on the final AIC (not shown).</p>
+<div class="sourceCode" id="cb22"><pre class="downlit sourceCode r">
+<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/base/colnames.html">rownames</a></span><span class="op">(</span><span class="va">AIC_parent_saemix</span><span class="op">)</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span>
+ <span class="st">"SFO const"</span>, <span class="st">"SFO tc"</span>, <span class="st">"DFOP const"</span>, <span class="st">"DFOP tc"</span>, <span class="st">"DFOP tc more iterations"</span>,
+ <span class="st">"DFOP tc mkintrans"</span>, <span class="st">"DFOP tc mkintrans more iterations"</span><span class="op">)</span>
+<span class="fu"><a href="https://rdrr.io/r/base/print.html">print</a></span><span class="op">(</span><span class="va">AIC_parent_saemix</span><span class="op">)</span></code></pre></div>
+<pre><code> AIC BIC
+SFO const 796.37 795.33
+SFO tc 798.37 797.13
+DFOP const 713.16 711.28
+DFOP tc 666.10 664.01
+DFOP tc more iterations 666.15 664.06
+DFOP tc mkintrans 682.26 680.17
+DFOP tc mkintrans more iterations 666.12 664.04</code></pre>
+<p>As in the case of nlme fits, the DFOP model fitted with two-component error (number 4) gives the lowest AIC. Using a much larger number of iterations does not improve the fit a lot. When the mkin transformations are used instead of the saemix transformations, this large number of iterations leads to a goodness of fit that is comparable to the result obtained with saemix transformations.</p>
<p>In order to check the influence of the likelihood calculation algorithms implemented in saemix, the likelihood from Gaussian quadrature is added to the best fit, and the AIC values obtained from the three methods are compared.</p>
-<div class="sourceCode" id="cb20"><pre class="downlit sourceCode r">
+<div class="sourceCode" id="cb24"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">f_parent_saemix_dfop_tc</span><span class="op">$</span><span class="va">so</span> <span class="op">&lt;-</span>
- <span class="fu"><a href="https://rdrr.io/pkg/saemix/man/llgq.saemix.html">llgq.saemix</a></span><span class="op">(</span><span class="va">f_parent_saemix_dfop_tc</span><span class="op">$</span><span class="va">so</span><span class="op">)</span>
+ <span class="fu">saemix</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/saemix/man/llgq.saemix.html">llgq.saemix</a></span><span class="op">(</span><span class="va">f_parent_saemix_dfop_tc</span><span class="op">$</span><span class="va">so</span><span class="op">)</span>
<span class="va">AIC_parent_saemix_methods</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span><span class="op">(</span>
is <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/stats/AIC.html">AIC</a></span><span class="op">(</span><span class="va">f_parent_saemix_dfop_tc</span><span class="op">$</span><span class="va">so</span>, method <span class="op">=</span> <span class="st">"is"</span><span class="op">)</span>,
gq <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/stats/AIC.html">AIC</a></span><span class="op">(</span><span class="va">f_parent_saemix_dfop_tc</span><span class="op">$</span><span class="va">so</span>, method <span class="op">=</span> <span class="st">"gq"</span><span class="op">)</span>,
@@ -273,19 +305,19 @@ f_parent_nlme_dfop_tc 3 10 671.91 702.34 -325.96 2 vs 3 134.69 &lt;.0001
<a href="#nlmixr" class="anchor"></a>nlmixr</h3>
<p>In the last years, a lot of effort has been put into the nlmixr package which is designed for pharmacokinetics, where nonlinear mixed-effects models are routinely used, but which can also be used for related data like chemical degradation data. A current development branch of the mkin package provides an interface between mkin and nlmixr. Here, we check if we get equivalent results when using a refined version of the First Order Conditional Estimation (FOCE) algorithm used in nlme, namely the First Order Conditional Estimation with Interaction (FOCEI), and the SAEM algorithm as implemented in nlmixr.</p>
<p>First, the focei algorithm is used for the four model combinations. A number of warnings are produced with unclear significance.</p>
-<div class="sourceCode" id="cb22"><pre class="downlit sourceCode r">
+<div class="sourceCode" id="cb26"><pre class="downlit sourceCode r">
<code class="sourceCode R"><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://github.com/nlmixrdevelopment/nlmixr">nlmixr</a></span><span class="op">)</span>
<span class="va">f_parent_nlmixr_focei_sfo_const</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/pkg/nlmixr/man/nlmixr.html">nlmixr</a></span><span class="op">(</span><span class="va">f_parent_mkin_const</span><span class="op">[</span><span class="st">"SFO"</span>, <span class="op">]</span>, est <span class="op">=</span> <span class="st">"focei"</span><span class="op">)</span>
<span class="va">f_parent_nlmixr_focei_sfo_tc</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/pkg/nlmixr/man/nlmixr.html">nlmixr</a></span><span class="op">(</span><span class="va">f_parent_mkin_tc</span><span class="op">[</span><span class="st">"SFO"</span>, <span class="op">]</span>, est <span class="op">=</span> <span class="st">"focei"</span><span class="op">)</span>
<span class="va">f_parent_nlmixr_focei_dfop_const</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/pkg/nlmixr/man/nlmixr.html">nlmixr</a></span><span class="op">(</span><span class="va">f_parent_mkin_const</span><span class="op">[</span><span class="st">"DFOP"</span>, <span class="op">]</span>, est <span class="op">=</span> <span class="st">"focei"</span><span class="op">)</span>
<span class="va">f_parent_nlmixr_focei_dfop_tc</span><span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/pkg/nlmixr/man/nlmixr.html">nlmixr</a></span><span class="op">(</span><span class="va">f_parent_mkin_tc</span><span class="op">[</span><span class="st">"DFOP"</span>, <span class="op">]</span>, est <span class="op">=</span> <span class="st">"focei"</span><span class="op">)</span></code></pre></div>
-<div class="sourceCode" id="cb23"><pre class="downlit sourceCode r">
+<div class="sourceCode" id="cb27"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">aic_nlmixr_focei</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/lapply.html">sapply</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_parent_nlmixr_focei_sfo_const</span><span class="op">$</span><span class="va">nm</span>, <span class="va">f_parent_nlmixr_focei_sfo_tc</span><span class="op">$</span><span class="va">nm</span>,
<span class="va">f_parent_nlmixr_focei_dfop_const</span><span class="op">$</span><span class="va">nm</span>, <span class="va">f_parent_nlmixr_focei_dfop_tc</span><span class="op">$</span><span class="va">nm</span><span class="op">)</span>,
<span class="va">AIC</span><span class="op">)</span></code></pre></div>
<p>The AIC values are very close to the ones obtained with nlme which are repeated below for convenience.</p>
-<div class="sourceCode" id="cb24"><pre class="downlit sourceCode r">
+<div class="sourceCode" id="cb28"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">aic_nlme</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/lapply.html">sapply</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_parent_nlme_sfo_const</span>, <span class="cn">NA</span>, <span class="va">f_parent_nlme_sfo_tc</span>, <span class="va">f_parent_nlme_dfop_tc</span><span class="op">)</span>,
<span class="kw">function</span><span class="op">(</span><span class="va">x</span><span class="op">)</span> <span class="kw">if</span> <span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/NA.html">is.na</a></span><span class="op">(</span><span class="va">x</span><span class="op">[</span><span class="fl">1</span><span class="op">]</span><span class="op">)</span><span class="op">)</span> <span class="cn">NA</span> <span class="kw">else</span> <span class="fu"><a href="https://rdrr.io/r/stats/AIC.html">AIC</a></span><span class="op">(</span><span class="va">x</span><span class="op">)</span><span class="op">)</span>
@@ -297,48 +329,70 @@ f_parent_nlme_dfop_tc 3 10 671.91 702.34 -325.96 2 vs 3 134.69 &lt;.0001
check.names <span class="op">=</span> <span class="cn">FALSE</span>
<span class="op">)</span></code></pre></div>
<p>Secondly, we use the SAEM estimation routine and check the convergence plots. The control parameters also used for the saemix fits are defined beforehand.</p>
-<div class="sourceCode" id="cb25"><pre class="downlit sourceCode r">
-<code class="sourceCode R"><span class="va">nlmixr_saem_control</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/pkg/nlmixr/man/saemControl.html">saemControl</a></span><span class="op">(</span>logLik <span class="op">=</span> <span class="cn">TRUE</span>,
- nBurn <span class="op">=</span> <span class="fl">1000</span>, nEm <span class="op">=</span> <span class="fl">300</span>, nmc <span class="op">=</span> <span class="fl">15</span><span class="op">)</span></code></pre></div>
+<div class="sourceCode" id="cb29"><pre class="downlit sourceCode r">
+<code class="sourceCode R"><span class="va">nlmixr_saem_control_800</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/pkg/nlmixr/man/saemControl.html">saemControl</a></span><span class="op">(</span>logLik <span class="op">=</span> <span class="cn">TRUE</span>,
+ nBurn <span class="op">=</span> <span class="fl">800</span>, nEm <span class="op">=</span> <span class="fl">300</span>, nmc <span class="op">=</span> <span class="fl">15</span><span class="op">)</span>
+<span class="va">nlmixr_saem_control_1000</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/pkg/nlmixr/man/saemControl.html">saemControl</a></span><span class="op">(</span>logLik <span class="op">=</span> <span class="cn">TRUE</span>,
+ nBurn <span class="op">=</span> <span class="fl">1000</span>, nEm <span class="op">=</span> <span class="fl">300</span>, nmc <span class="op">=</span> <span class="fl">15</span><span class="op">)</span>
+<span class="va">nlmixr_saem_control_10k</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/pkg/nlmixr/man/saemControl.html">saemControl</a></span><span class="op">(</span>logLik <span class="op">=</span> <span class="cn">TRUE</span>,
+ nBurn <span class="op">=</span> <span class="fl">10000</span>, nEm <span class="op">=</span> <span class="fl">1000</span>, nmc <span class="op">=</span> <span class="fl">15</span><span class="op">)</span></code></pre></div>
<p>The we fit SFO with constant variance</p>
-<div class="sourceCode" id="cb26"><pre class="downlit sourceCode r">
+<div class="sourceCode" id="cb30"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">f_parent_nlmixr_saem_sfo_const</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/pkg/nlmixr/man/nlmixr.html">nlmixr</a></span><span class="op">(</span><span class="va">f_parent_mkin_const</span><span class="op">[</span><span class="st">"SFO"</span>, <span class="op">]</span>, est <span class="op">=</span> <span class="st">"saem"</span>,
- control <span class="op">=</span> <span class="va">nlmixr_saem_control</span><span class="op">)</span>
+ control <span class="op">=</span> <span class="va">nlmixr_saem_control_800</span><span class="op">)</span>
<span class="fu"><a href="https://rdrr.io/pkg/nlmixr/man/traceplot.html">traceplot</a></span><span class="op">(</span><span class="va">f_parent_nlmixr_saem_sfo_const</span><span class="op">$</span><span class="va">nm</span><span class="op">)</span></code></pre></div>
<p><img src="dimethenamid_2018_files/figure-html/f_parent_nlmixr_saem_sfo_const-1.png" width="700"></p>
<p>and SFO with two-component error.</p>
-<div class="sourceCode" id="cb27"><pre class="downlit sourceCode r">
+<div class="sourceCode" id="cb31"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">f_parent_nlmixr_saem_sfo_tc</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/pkg/nlmixr/man/nlmixr.html">nlmixr</a></span><span class="op">(</span><span class="va">f_parent_mkin_tc</span><span class="op">[</span><span class="st">"SFO"</span>, <span class="op">]</span>, est <span class="op">=</span> <span class="st">"saem"</span>,
- control <span class="op">=</span> <span class="va">nlmixr_saem_control</span><span class="op">)</span>
+ control <span class="op">=</span> <span class="va">nlmixr_saem_control_800</span><span class="op">)</span>
<span class="fu"><a href="https://rdrr.io/pkg/nlmixr/man/traceplot.html">traceplot</a></span><span class="op">(</span><span class="va">f_parent_nlmixr_saem_sfo_tc</span><span class="op">$</span><span class="va">nm</span><span class="op">)</span></code></pre></div>
<p><img src="dimethenamid_2018_files/figure-html/f_parent_nlmixr_saem_sfo_tc-1.png" width="700"></p>
<p>For DFOP with constant variance, the convergence plots show considerable instability of the fit, which indicates overparameterisation which was already observed earlier for this model combination.</p>
-<div class="sourceCode" id="cb28"><pre class="downlit sourceCode r">
+<div class="sourceCode" id="cb32"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">f_parent_nlmixr_saem_dfop_const</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/pkg/nlmixr/man/nlmixr.html">nlmixr</a></span><span class="op">(</span><span class="va">f_parent_mkin_const</span><span class="op">[</span><span class="st">"DFOP"</span>, <span class="op">]</span>, est <span class="op">=</span> <span class="st">"saem"</span>,
- control <span class="op">=</span> <span class="va">nlmixr_saem_control</span><span class="op">)</span>
+ control <span class="op">=</span> <span class="va">nlmixr_saem_control_800</span><span class="op">)</span>
<span class="fu"><a href="https://rdrr.io/pkg/nlmixr/man/traceplot.html">traceplot</a></span><span class="op">(</span><span class="va">f_parent_nlmixr_saem_dfop_const</span><span class="op">$</span><span class="va">nm</span><span class="op">)</span></code></pre></div>
<p><img src="dimethenamid_2018_files/figure-html/f_parent_nlmixr_saem_dfop_const-1.png" width="700"></p>
<p>For DFOP with two-component error, a less erratic convergence is seen.</p>
-<div class="sourceCode" id="cb29"><pre class="downlit sourceCode r">
+<div class="sourceCode" id="cb33"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">f_parent_nlmixr_saem_dfop_tc</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/pkg/nlmixr/man/nlmixr.html">nlmixr</a></span><span class="op">(</span><span class="va">f_parent_mkin_tc</span><span class="op">[</span><span class="st">"DFOP"</span>, <span class="op">]</span>, est <span class="op">=</span> <span class="st">"saem"</span>,
- control <span class="op">=</span> <span class="va">nlmixr_saem_control</span><span class="op">)</span>
+ control <span class="op">=</span> <span class="va">nlmixr_saem_control_800</span><span class="op">)</span>
<span class="fu"><a href="https://rdrr.io/pkg/nlmixr/man/traceplot.html">traceplot</a></span><span class="op">(</span><span class="va">f_parent_nlmixr_saem_dfop_tc</span><span class="op">$</span><span class="va">nm</span><span class="op">)</span></code></pre></div>
<p><img src="dimethenamid_2018_files/figure-html/f_parent_nlmixr_saem_dfop_tc-1.png" width="700"></p>
-<p>The AIC values are internally calculated using Gaussian quadrature. For an unknown reason, the AIC value obtained for the DFOP fit using constant error is given as Infinity.</p>
-<div class="sourceCode" id="cb30"><pre class="downlit sourceCode r">
+<p>To check if an increase in the number of iterations improves the fit, we repeat the fit with 1000 iterations for the burn in phase and 300 iterations for the second phase.</p>
+<div class="sourceCode" id="cb34"><pre class="downlit sourceCode r">
+<code class="sourceCode R"><span class="va">f_parent_nlmixr_saem_dfop_tc_1000</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/pkg/nlmixr/man/nlmixr.html">nlmixr</a></span><span class="op">(</span><span class="va">f_parent_mkin_tc</span><span class="op">[</span><span class="st">"DFOP"</span>, <span class="op">]</span>, est <span class="op">=</span> <span class="st">"saem"</span>,
+ control <span class="op">=</span> <span class="va">nlmixr_saem_control_1000</span><span class="op">)</span>
+<span class="fu"><a href="https://rdrr.io/pkg/nlmixr/man/traceplot.html">traceplot</a></span><span class="op">(</span><span class="va">f_parent_nlmixr_saem_dfop_tc_1000</span><span class="op">$</span><span class="va">nm</span><span class="op">)</span></code></pre></div>
+<p><img src="dimethenamid_2018_files/figure-html/f_parent_nlmixr_saem_dfop_tc_1k-1.png" width="700"></p>
+<p>Here the fit looks very similar, but we will see below that it shows a higher AIC than the fit with 800 iterations in the burn in phase. Next we choose 10 000 iterations for the burn in phase and 1000 iterations for the second phase for comparison with saemix.</p>
+<div class="sourceCode" id="cb35"><pre class="downlit sourceCode r">
+<code class="sourceCode R"><span class="va">f_parent_nlmixr_saem_dfop_tc_10k</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/pkg/nlmixr/man/nlmixr.html">nlmixr</a></span><span class="op">(</span><span class="va">f_parent_mkin_tc</span><span class="op">[</span><span class="st">"DFOP"</span>, <span class="op">]</span>, est <span class="op">=</span> <span class="st">"saem"</span>,
+ control <span class="op">=</span> <span class="va">nlmixr_saem_control_10k</span><span class="op">)</span>
+<span class="fu"><a href="https://rdrr.io/pkg/nlmixr/man/traceplot.html">traceplot</a></span><span class="op">(</span><span class="va">f_parent_nlmixr_saem_dfop_tc_10k</span><span class="op">$</span><span class="va">nm</span><span class="op">)</span></code></pre></div>
+<p><img src="dimethenamid_2018_files/figure-html/f_parent_nlmixr_saem_dfop_tc_10k-1.png" width="700"></p>
+<p>In the above convergence plot, the time course of ‘eta.DMTA_0’ and ‘log_k2’ indicate a false convergence.</p>
+<p>The AIC values are internally calculated using Gaussian quadrature.</p>
+<div class="sourceCode" id="cb36"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/stats/AIC.html">AIC</a></span><span class="op">(</span><span class="va">f_parent_nlmixr_saem_sfo_const</span><span class="op">$</span><span class="va">nm</span>, <span class="va">f_parent_nlmixr_saem_sfo_tc</span><span class="op">$</span><span class="va">nm</span>,
- <span class="va">f_parent_nlmixr_saem_dfop_const</span><span class="op">$</span><span class="va">nm</span>, <span class="va">f_parent_nlmixr_saem_dfop_tc</span><span class="op">$</span><span class="va">nm</span><span class="op">)</span></code></pre></div>
-<pre><code> df AIC
-f_parent_nlmixr_saem_sfo_const$nm 5 798.68
-f_parent_nlmixr_saem_sfo_tc$nm 6 808.88
-f_parent_nlmixr_saem_dfop_const$nm 9 815.95
-f_parent_nlmixr_saem_dfop_tc$nm 10 669.57</code></pre>
+ <span class="va">f_parent_nlmixr_saem_dfop_const</span><span class="op">$</span><span class="va">nm</span>, <span class="va">f_parent_nlmixr_saem_dfop_tc</span><span class="op">$</span><span class="va">nm</span>,
+ <span class="va">f_parent_nlmixr_saem_dfop_tc_1000</span><span class="op">$</span><span class="va">nm</span>,
+ <span class="va">f_parent_nlmixr_saem_dfop_tc_10k</span><span class="op">$</span><span class="va">nm</span><span class="op">)</span></code></pre></div>
+<pre><code> df AIC
+f_parent_nlmixr_saem_sfo_const$nm 5 798.69
+f_parent_nlmixr_saem_sfo_tc$nm 6 810.33
+f_parent_nlmixr_saem_dfop_const$nm 9 736.00
+f_parent_nlmixr_saem_dfop_tc$nm 10 664.85
+f_parent_nlmixr_saem_dfop_tc_1000$nm 10 669.57
+f_parent_nlmixr_saem_dfop_tc_10k$nm 10 Inf</code></pre>
+<p>We can see that again, the DFOP/tc model shows the best goodness of fit. However, increasing the number of burn-in iterations from 800 to 1000 results in a higher AIC. If we further increase the number of iterations to 10 000 (burn-in) and 1000 (second phase), the AIC cannot be calculated for the nlmixr/saem fit, supporting that the fit did not converge properly.</p>
</div>
<div id="comparison" class="section level3">
<h3 class="hasAnchor">
<a href="#comparison" class="anchor"></a>Comparison</h3>
-<p>The following table gives the AIC values obtained with the three packages.</p>
-<div class="sourceCode" id="cb32"><pre class="downlit sourceCode r">
+<p>The following table gives the AIC values obtained with the three packages using the same control parameters (800 iterations burn-in, 300 iterations second phase, 15 chains).</p>
+<div class="sourceCode" id="cb38"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span class="va">AIC_all</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/data.frame.html">data.frame</a></span><span class="op">(</span>
check.names <span class="op">=</span> <span class="cn">FALSE</span>,
<span class="st">"Degradation model"</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">"SFO"</span>, <span class="st">"DFOP"</span>, <span class="st">"DFOP"</span><span class="op">)</span>,
@@ -368,7 +422,7 @@ f_parent_nlmixr_saem_dfop_tc$nm 10 669.57</code></pre>
<td align="right">796.60</td>
<td align="right">796.62</td>
<td align="right">796.37</td>
-<td align="right">798.68</td>
+<td align="right">798.69</td>
</tr>
<tr class="even">
<td align="left">SFO</td>
@@ -376,7 +430,7 @@ f_parent_nlmixr_saem_dfop_tc$nm 10 669.57</code></pre>
<td align="right">798.60</td>
<td align="right">798.61</td>
<td align="right">798.37</td>
-<td align="right">808.88</td>
+<td align="right">810.33</td>
</tr>
<tr class="odd">
<td align="left">DFOP</td>
@@ -384,7 +438,7 @@ f_parent_nlmixr_saem_dfop_tc$nm 10 669.57</code></pre>
<td align="right">NA</td>
<td align="right">750.91</td>
<td align="right">713.16</td>
-<td align="right">815.95</td>
+<td align="right">736.00</td>
</tr>
<tr class="even">
<td align="left">DFOP</td>
@@ -392,10 +446,142 @@ f_parent_nlmixr_saem_dfop_tc$nm 10 669.57</code></pre>
<td align="right">671.91</td>
<td align="right">666.60</td>
<td align="right">666.10</td>
-<td align="right">669.57</td>
+<td align="right">664.85</td>
</tr>
</tbody>
</table>
+<div class="sourceCode" id="cb39"><pre class="downlit sourceCode r">
+<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/pkg/nlme/man/intervals.html">intervals</a></span><span class="op">(</span><span class="va">f_parent_saemix_dfop_tc</span><span class="op">)</span></code></pre></div>
+<pre><code>Approximate 95% confidence intervals
+
+ Fixed effects:
+ lower est. upper
+DMTA_0 96.2802274 98.2761977 100.272168
+k1 0.0339753 0.0645487 0.095122
+k2 0.0058977 0.0088887 0.011880
+g 0.9064373 0.9514417 0.996446
+
+ Random effects:
+ lower est. upper
+sd(DMTA_0) 0.44404 2.102366 3.76069
+sd(k1) 0.25433 0.589731 0.92514
+sd(k2) -0.33139 0.099797 0.53099
+sd(g) 0.39606 1.092234 1.78841
+
+
+ lower est. upper
+a.1 0.863644 1.063021 1.262398
+b.1 0.022555 0.029599 0.036643</code></pre>
+<div class="sourceCode" id="cb41"><pre class="downlit sourceCode r">
+<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/pkg/nlme/man/intervals.html">intervals</a></span><span class="op">(</span><span class="va">f_parent_saemix_dfop_tc</span><span class="op">)</span></code></pre></div>
+<pre><code>Approximate 95% confidence intervals
+
+ Fixed effects:
+ lower est. upper
+DMTA_0 96.2802274 98.2761977 100.272168
+k1 0.0339753 0.0645487 0.095122
+k2 0.0058977 0.0088887 0.011880
+g 0.9064373 0.9514417 0.996446
+
+ Random effects:
+ lower est. upper
+sd(DMTA_0) 0.44404 2.102366 3.76069
+sd(k1) 0.25433 0.589731 0.92514
+sd(k2) -0.33139 0.099797 0.53099
+sd(g) 0.39606 1.092234 1.78841
+
+
+ lower est. upper
+a.1 0.863644 1.063021 1.262398
+b.1 0.022555 0.029599 0.036643</code></pre>
+<div class="sourceCode" id="cb43"><pre class="downlit sourceCode r">
+<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/pkg/nlme/man/intervals.html">intervals</a></span><span class="op">(</span><span class="va">f_parent_saemix_dfop_tc_10k</span><span class="op">)</span></code></pre></div>
+<pre><code>Approximate 95% confidence intervals
+
+ Fixed effects:
+ lower est. upper
+DMTA_0 96.3027896 98.2641150 100.225440
+k1 0.0338214 0.0644055 0.094990
+k2 0.0058857 0.0087896 0.011693
+g 0.9086138 0.9521421 0.995670
+
+ Random effects:
+ lower est. upper
+sd(DMTA_0) 0.41448 2.05327 3.69206
+sd(k1) 0.25507 0.59132 0.92758
+sd(k2) -0.36781 0.09016 0.54813
+sd(g) 0.38585 1.06994 1.75402
+
+
+ lower est. upper
+a.1 0.866273 1.066115 1.265957
+b.1 0.022501 0.029541 0.036581</code></pre>
+<div class="sourceCode" id="cb45"><pre class="downlit sourceCode r">
+<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/pkg/nlme/man/intervals.html">intervals</a></span><span class="op">(</span><span class="va">f_parent_saemix_dfop_tc_mkin_10k</span><span class="op">)</span></code></pre></div>
+<pre><code>Approximate 95% confidence intervals
+
+ Fixed effects:
+ lower est. upper
+DMTA_0 96.3021306 98.2736091 100.245088
+k1 0.0401701 0.0645140 0.103611
+k2 0.0064706 0.0089398 0.012351
+g 0.8817692 0.9511605 0.980716
+
+ Random effects:
+ lower est. upper
+sd(DMTA_0) 0.42392 2.068018 3.71212
+sd(log_k1) 0.25440 0.589877 0.92536
+sd(log_k2) -0.38431 0.084334 0.55298
+sd(g_qlogis) 0.39107 1.077303 1.76353
+
+
+ lower est. upper
+a.1 0.865291 1.064897 1.264504
+b.1 0.022491 0.029526 0.036561</code></pre>
+<div class="sourceCode" id="cb47"><pre class="downlit sourceCode r">
+<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/pkg/nlme/man/intervals.html">intervals</a></span><span class="op">(</span><span class="va">f_parent_nlmixr_saem_dfop_tc</span><span class="op">)</span></code></pre></div>
+<pre><code>Approximate 95% confidence intervals
+
+ Fixed effects:
+ lower est. upper
+DMTA_0 96.3059406 98.2990616 100.292183
+k1 0.0402306 0.0648255 0.104456
+k2 0.0067864 0.0093097 0.012771
+g 0.8769017 0.9505258 0.981067
+
+ Random effects:
+ lower est. upper
+sd(DMTA_0) NA 1.724654 NA
+sd(log_k1) NA 0.592808 NA
+sd(log_k2) NA 0.010741 NA
+sd(g_qlogis) NA 1.087349 NA
+
+
+ lower est. upper
+sigma_low NA 1.081809 NA
+rsd_high NA 0.032051 NA</code></pre>
+<div class="sourceCode" id="cb49"><pre class="downlit sourceCode r">
+<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/pkg/nlme/man/intervals.html">intervals</a></span><span class="op">(</span><span class="va">f_parent_nlmixr_saem_dfop_tc_10k</span><span class="op">)</span></code></pre></div>
+<pre><code>Approximate 95% confidence intervals
+
+ Fixed effects:
+ lower est. upper
+DMTA_0 96.426510 97.8987836 99.371057
+k1 0.040006 0.0644407 0.103799
+k2 0.006748 0.0092476 0.012673
+g 0.879251 0.9511399 0.981147
+
+ Random effects:
+ lower est. upper
+sd(DMTA_0) NA 3.7049e-04 NA
+sd(log_k1) NA 5.9221e-01 NA
+sd(log_k2) NA 3.8628e-07 NA
+sd(g_qlogis) NA 1.0694e+00 NA
+
+
+ lower est. upper
+sigma_low NA 1.082343 NA
+rsd_high NA 0.034895 NA</code></pre>
</div>
</div>
</div>

Contact - Imprint