aboutsummaryrefslogtreecommitdiff
path: root/docs/dev/articles/web_only
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2022-10-26 10:36:19 +0200
committerJohannes Ranke <jranke@uni-bremen.de>2022-10-26 10:36:19 +0200
commit08e600c0eea6153b433659c08ea49aead5ffd932 (patch)
tree2b9e09bd881e392b20fa34b80db7c925687a9037 /docs/dev/articles/web_only
parentd25974f643ee46b7cd5ccd8331dd7bb0b14ab27a (diff)
Update multistart example code and vignette
Diffstat (limited to 'docs/dev/articles/web_only')
-rw-r--r--docs/dev/articles/web_only/multistart.html44
-rw-r--r--docs/dev/articles/web_only/multistart_files/figure-html/unnamed-chunk-3-1.pngbin55167 -> 59606 bytes
-rw-r--r--docs/dev/articles/web_only/multistart_files/figure-html/unnamed-chunk-4-1.pngbin21474 -> 55167 bytes
-rw-r--r--docs/dev/articles/web_only/multistart_files/figure-html/unnamed-chunk-5-1.pngbin0 -> 21474 bytes
-rw-r--r--docs/dev/articles/web_only/multistart_files/figure-html/unnamed-chunk-6-1.pngbin0 -> 54481 bytes
5 files changed, 32 insertions, 12 deletions
diff --git a/docs/dev/articles/web_only/multistart.html b/docs/dev/articles/web_only/multistart.html
index 4af5def0..275fc520 100644
--- a/docs/dev/articles/web_only/multistart.html
+++ b/docs/dev/articles/web_only/multistart.html
@@ -109,7 +109,7 @@
<h1 data-toc-skip>Short demo of the multistart method</h1>
<h4 data-toc-skip class="author">Johannes Ranke</h4>
- <h4 data-toc-skip class="date">Last change 19 September 2022 (rebuilt 2022-10-26)</h4>
+ <h4 data-toc-skip class="date">Last change 26 September 2022 (rebuilt 2022-10-26)</h4>
<small class="dont-index">Source: <a href="https://github.com/jranke/mkin/blob/HEAD/vignettes/web_only/multistart.rmd" class="external-link"><code>vignettes/web_only/multistart.rmd</code></a></small>
<div class="hidden name"><code>multistart.rmd</code></div>
@@ -118,7 +118,7 @@
-<p>This is a vignette, because the multistart method does not seem to work in pkgdown example code and I wanted to show the plots in the online docs. The dimethenamid data from 2018 from seven soils is used as example data.</p>
+<p>The dimethenamid data from 2018 from seven soils is used as example data in this vignette.</p>
<div class="sourceCode" id="cb1"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">library</a></span><span class="op">(</span><span class="va"><a href="https://pkgdown.jrwb.de/mkin/">mkin</a></span><span class="op">)</span></span>
<span><span class="va">dmta_ds</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/base/lapply.html" class="external-link">lapply</a></span><span class="op">(</span><span class="fl">1</span><span class="op">:</span><span class="fl">7</span>, <span class="kw">function</span><span class="op">(</span><span class="va">i</span><span class="op">)</span> <span class="op">{</span></span>
@@ -134,20 +134,40 @@
<div class="sourceCode" id="cb2"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="va">f_mmkin</span> <span class="op">&lt;-</span> <span class="fu"><a href="../../reference/mmkin.html">mmkin</a></span><span class="op">(</span><span class="st">"DFOP"</span>, <span class="va">dmta_ds</span>, error_model <span class="op">=</span> <span class="st">"tc"</span>, cores <span class="op">=</span> <span class="fl">7</span>, quiet <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span>
<span><span class="va">f_saem_full</span> <span class="op">&lt;-</span> <span class="fu"><a href="../../reference/saem.html">saem</a></span><span class="op">(</span><span class="va">f_mmkin</span><span class="op">)</span></span>
-<span><span class="va">f_saem_full_multi</span> <span class="op">&lt;-</span> <span class="fu"><a href="../../reference/multistart.html">multistart</a></span><span class="op">(</span><span class="va">f_saem_full</span>, n <span class="op">=</span> <span class="fl">16</span>, cores <span class="op">=</span> <span class="fl">16</span><span class="op">)</span></span>
+<span><span class="fu"><a href="../../reference/illparms.html">illparms</a></span><span class="op">(</span><span class="va">f_saem_full</span><span class="op">)</span></span></code></pre></div>
+<pre><code><span><span class="co">## [1] "sd(log_k2)"</span></span></code></pre>
+<p>We see that not all variability parameters are identifiable. The <code>illparms</code> function tells us that the confidence interval for the standard deviation of ‘log_k2’ includes zero. We check this assessment using multiple runs with different starting values.</p>
+<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
+<code class="sourceCode R"><span><span class="va">f_saem_full_multi</span> <span class="op">&lt;-</span> <span class="fu"><a href="../../reference/multistart.html">multistart</a></span><span class="op">(</span><span class="va">f_saem_full</span>, n <span class="op">=</span> <span class="fl">16</span>, cores <span class="op">=</span> <span class="fl">16</span><span class="op">)</span></span>
<span><span class="fu"><a href="../../reference/parhist.html">parhist</a></span><span class="op">(</span><span class="va">f_saem_full_multi</span><span class="op">)</span></span></code></pre></div>
-<p><img src="multistart_files/figure-html/unnamed-chunk-2-1.png" width="700"></p>
-<p>We see that not all variability parameters are identifiable, most problematic is the variance of k2. So we reduce the parameter distribution model by removing the intersoil variability for this parameter.</p>
-<div class="sourceCode" id="cb3"><pre class="downlit sourceCode r">
-<code class="sourceCode R"><span><span class="va">f_saem_reduced</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/stats/update.html" class="external-link">update</a></span><span class="op">(</span><span class="va">f_saem_full</span>, covariance.model <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/diag.html" class="external-link">diag</a></span><span class="op">(</span><span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fl">1</span>, <span class="fl">1</span>, <span class="fl">0</span>, <span class="fl">1</span><span class="op">)</span><span class="op">)</span><span class="op">)</span></span>
-<span><span class="va">f_saem_reduced_multi</span> <span class="op">&lt;-</span> <span class="fu"><a href="../../reference/multistart.html">multistart</a></span><span class="op">(</span><span class="va">f_saem_reduced</span>, n <span class="op">=</span> <span class="fl">16</span>, cores <span class="op">=</span> <span class="fl">16</span><span class="op">)</span></span>
-<span><span class="fu"><a href="../../reference/parhist.html">parhist</a></span><span class="op">(</span><span class="va">f_saem_reduced_multi</span>, lpos <span class="op">=</span> <span class="st">"topright"</span><span class="op">)</span></span></code></pre></div>
<p><img src="multistart_files/figure-html/unnamed-chunk-3-1.png" width="700"></p>
+<p>This confirms that the variance of k2 is the most problematic parameter, so we reduce the parameter distribution model by removing the intersoil variability for k2.</p>
+<div class="sourceCode" id="cb5"><pre class="downlit sourceCode r">
+<code class="sourceCode R"><span><span class="va">f_saem_reduced</span> <span class="op">&lt;-</span> <span class="fu"><a href="https://rdrr.io/r/stats/update.html" class="external-link">update</a></span><span class="op">(</span><span class="va">f_saem_full</span>, no_random_effect <span class="op">=</span> <span class="st">"log_k2"</span><span class="op">)</span></span>
+<span><span class="fu"><a href="../../reference/illparms.html">illparms</a></span><span class="op">(</span><span class="va">f_saem_reduced</span><span class="op">)</span></span></code></pre></div>
+<pre><code><span><span class="co">## character(0)</span></span></code></pre>
+<div class="sourceCode" id="cb7"><pre class="downlit sourceCode r">
+<code class="sourceCode R"><span><span class="va">f_saem_reduced_multi</span> <span class="op">&lt;-</span> <span class="fu"><a href="../../reference/multistart.html">multistart</a></span><span class="op">(</span><span class="va">f_saem_reduced</span>, n <span class="op">=</span> <span class="fl">16</span>, cores <span class="op">=</span> <span class="fl">16</span><span class="op">)</span></span>
+<span><span class="fu"><a href="../../reference/parhist.html">parhist</a></span><span class="op">(</span><span class="va">f_saem_reduced_multi</span>, lpos <span class="op">=</span> <span class="st">"topright"</span><span class="op">)</span></span></code></pre></div>
+<p><img src="multistart_files/figure-html/unnamed-chunk-4-1.png" width="700"></p>
+<p>The results confirm that all remaining parameters can be determined with sufficient certainty.</p>
<p>We can also analyse the log-likelihoods obtained in the multiple runs:</p>
-<div class="sourceCode" id="cb4"><pre class="downlit sourceCode r">
+<div class="sourceCode" id="cb8"><pre class="downlit sourceCode r">
<code class="sourceCode R"><span><span class="fu"><a href="../../reference/llhist.html">llhist</a></span><span class="op">(</span><span class="va">f_saem_reduced_multi</span><span class="op">)</span></span></code></pre></div>
-<p><img src="multistart_files/figure-html/unnamed-chunk-4-1.png" width="700"></p>
-<p>The one run with the lower likelihood is probably responsible for the outliers in the boxplots above, and caused by some weird starting value combination. In any case, the converged values from the original fit (red circles) appear perfectly acceptable, supporting the choice of starting values made by mkin.</p>
+<p><img src="multistart_files/figure-html/unnamed-chunk-5-1.png" width="700"></p>
+<p>The parameter histograms can be further improved by excluding the result with the low likelihood.</p>
+<div class="sourceCode" id="cb9"><pre class="downlit sourceCode r">
+<code class="sourceCode R"><span><span class="fu"><a href="../../reference/parhist.html">parhist</a></span><span class="op">(</span><span class="va">f_saem_reduced_multi</span>, lpos <span class="op">=</span> <span class="st">"topright"</span>, llmin <span class="op">=</span> <span class="op">-</span><span class="fl">326</span>, ylim <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html" class="external-link">c</a></span><span class="op">(</span><span class="fl">0.5</span>, <span class="fl">2</span><span class="op">)</span><span class="op">)</span></span></code></pre></div>
+<p><img src="multistart_files/figure-html/unnamed-chunk-6-1.png" width="700"></p>
+<p>We can use the <code>anova</code> method to compare the models, including a likelihood ratio test if the models are nested.</p>
+<div class="sourceCode" id="cb10"><pre class="downlit sourceCode r">
+<code class="sourceCode R"><span><span class="fu"><a href="https://rdrr.io/r/stats/anova.html" class="external-link">anova</a></span><span class="op">(</span><span class="va">f_saem_full</span>, <span class="fu"><a href="../../reference/multistart.html">best</a></span><span class="op">(</span><span class="va">f_saem_reduced_multi</span><span class="op">)</span>, test <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span></code></pre></div>
+<pre><code><span><span class="co">## Data: 155 observations of 1 variable(s) grouped in 6 datasets</span></span>
+<span><span class="co">## </span></span>
+<span><span class="co">## npar AIC BIC Lik Chisq Df Pr(&gt;Chisq)</span></span>
+<span><span class="co">## best(f_saem_reduced_multi) 9 663.81 661.93 -322.90 </span></span>
+<span><span class="co">## f_saem_full 10 668.27 666.19 -324.13 0 1 1</span></span></code></pre>
+<p>While AIC and BIC are lower for the reduced model, the likelihood ratio test does not indicate a significant difference between the fits.</p>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">
diff --git a/docs/dev/articles/web_only/multistart_files/figure-html/unnamed-chunk-3-1.png b/docs/dev/articles/web_only/multistart_files/figure-html/unnamed-chunk-3-1.png
index d32e1214..e3baa59b 100644
--- a/docs/dev/articles/web_only/multistart_files/figure-html/unnamed-chunk-3-1.png
+++ b/docs/dev/articles/web_only/multistart_files/figure-html/unnamed-chunk-3-1.png
Binary files differ
diff --git a/docs/dev/articles/web_only/multistart_files/figure-html/unnamed-chunk-4-1.png b/docs/dev/articles/web_only/multistart_files/figure-html/unnamed-chunk-4-1.png
index d72722f0..d32e1214 100644
--- a/docs/dev/articles/web_only/multistart_files/figure-html/unnamed-chunk-4-1.png
+++ b/docs/dev/articles/web_only/multistart_files/figure-html/unnamed-chunk-4-1.png
Binary files differ
diff --git a/docs/dev/articles/web_only/multistart_files/figure-html/unnamed-chunk-5-1.png b/docs/dev/articles/web_only/multistart_files/figure-html/unnamed-chunk-5-1.png
new file mode 100644
index 00000000..d72722f0
--- /dev/null
+++ b/docs/dev/articles/web_only/multistart_files/figure-html/unnamed-chunk-5-1.png
Binary files differ
diff --git a/docs/dev/articles/web_only/multistart_files/figure-html/unnamed-chunk-6-1.png b/docs/dev/articles/web_only/multistart_files/figure-html/unnamed-chunk-6-1.png
new file mode 100644
index 00000000..f9b5aff2
--- /dev/null
+++ b/docs/dev/articles/web_only/multistart_files/figure-html/unnamed-chunk-6-1.png
Binary files differ

Contact - Imprint