diff options
author | Johannes Ranke <jranke@uni-bremen.de> | 2022-11-01 14:16:21 +0100 |
---|---|---|
committer | Johannes Ranke <jranke@uni-bremen.de> | 2022-11-01 14:16:21 +0100 |
commit | 630e657f1794ea441afc9ff10663309fec5e847e (patch) | |
tree | 6f09ad8413f0a8c23f0b21e5067b4fccb183056e /docs/dev/articles | |
parent | a787e5266628f859fd70454c5419721efa494887 (diff) |
Update online docs
Diffstat (limited to 'docs/dev/articles')
-rw-r--r-- | docs/dev/articles/index.html | 2 | ||||
-rw-r--r-- | docs/dev/articles/web_only/benchmarks.html | 38 | ||||
-rw-r--r-- | docs/dev/articles/web_only/compiled_models.html | 168 | ||||
-rw-r--r-- | docs/dev/articles/web_only/multistart.html | 16 |
4 files changed, 133 insertions, 91 deletions
diff --git a/docs/dev/articles/index.html b/docs/dev/articles/index.html index 551e9c98..45ba1c77 100644 --- a/docs/dev/articles/index.html +++ b/docs/dev/articles/index.html @@ -17,7 +17,7 @@ </button> <span class="navbar-brand"> <a class="navbar-link" href="../index.html">mkin</a> - <span class="version label label-info" data-toggle="tooltip" data-placement="bottom" title="In-development version">1.1.2</span> + <span class="version label label-info" data-toggle="tooltip" data-placement="bottom" title="In-development version">1.2.0</span> </span> </div> diff --git a/docs/dev/articles/web_only/benchmarks.html b/docs/dev/articles/web_only/benchmarks.html index e5bc5a21..2aa2f45a 100644 --- a/docs/dev/articles/web_only/benchmarks.html +++ b/docs/dev/articles/web_only/benchmarks.html @@ -34,7 +34,7 @@ </button> <span class="navbar-brand"> <a class="navbar-link" href="../../index.html">mkin</a> - <span class="version label label-info" data-toggle="tooltip" data-placement="bottom" title="In-development version">1.1.2</span> + <span class="version label label-info" data-toggle="tooltip" data-placement="bottom" title="In-development version">1.2.0</span> </span> </div> @@ -63,12 +63,15 @@ <a href="../../articles/web_only/dimethenamid_2018.html">Example evaluations of dimethenamid data from 2018 with nonlinear mixed-effects models</a> </li> <li> - <a href="../../articles/web_only/FOCUS_Z.html">Example evaluation of FOCUS Example Dataset Z</a> + <a href="../../articles/web_only/multistart.html">Short demo of the multistart method</a> </li> <li> <a href="../../articles/web_only/compiled_models.html">Performance benefit by using compiled model definitions in mkin</a> </li> <li> + <a href="../../articles/web_only/FOCUS_Z.html">Example evaluation of FOCUS Example Dataset Z</a> + </li> + <li> <a href="../../articles/twa.html">Calculation of time weighted average concentrations with mkin</a> </li> <li> @@ -106,7 +109,7 @@ <h1 data-toc-skip>Benchmark timings for mkin</h1> <h4 data-toc-skip class="author">Johannes Ranke</h4> - <h4 data-toc-skip class="date">Last change 14 July 2022 (rebuilt 2022-09-16)</h4> + <h4 data-toc-skip class="date">Last change 14 July 2022 (rebuilt 2022-11-01)</h4> <small class="dont-index">Source: <a href="https://github.com/jranke/mkin/blob/HEAD/vignettes/web_only/benchmarks.rmd" class="external-link"><code>vignettes/web_only/benchmarks.rmd</code></a></small> <div class="hidden name"><code>benchmarks.rmd</code></div> @@ -340,6 +343,14 @@ <td align="right">1.957</td> <td align="right">3.633</td> </tr> +<tr class="even"> +<td align="left">Linux</td> +<td align="left">Ryzen 7 1700</td> +<td align="left">4.2.2</td> +<td align="left">1.2.0</td> +<td align="right">2.020</td> +<td align="right">3.608</td> +</tr> </tbody> </table> </div> @@ -511,6 +522,15 @@ <td align="right">6.147</td> <td align="right">2.803</td> </tr> +<tr class="even"> +<td align="left">Linux</td> +<td align="left">Ryzen 7 1700</td> +<td align="left">4.2.2</td> +<td align="left">1.2.0</td> +<td align="right">1.579</td> +<td align="right">5.973</td> +<td align="right">2.839</td> +</tr> </tbody> </table> </div> @@ -736,6 +756,18 @@ <td align="right">1.961</td> <td align="right">2.852</td> </tr> +<tr class="even"> +<td align="left">Linux</td> +<td align="left">Ryzen 7 1700</td> +<td align="left">4.2.2</td> +<td align="left">1.2.0</td> +<td align="right">0.920</td> +<td align="right">1.295</td> +<td align="right">1.518</td> +<td align="right">3.060</td> +<td align="right">1.895</td> +<td align="right">2.740</td> +</tr> </tbody> </table> </div> diff --git a/docs/dev/articles/web_only/compiled_models.html b/docs/dev/articles/web_only/compiled_models.html index 49a579fc..ade86bc5 100644 --- a/docs/dev/articles/web_only/compiled_models.html +++ b/docs/dev/articles/web_only/compiled_models.html @@ -20,6 +20,8 @@ <![endif]--> </head> <body data-spy="scroll" data-target="#toc"> + + <div class="container template-article"> <header><div class="navbar navbar-default navbar-fixed-top" role="navigation"> <div class="container"> @@ -32,7 +34,7 @@ </button> <span class="navbar-brand"> <a class="navbar-link" href="../../index.html">mkin</a> - <span class="version label label-info" data-toggle="tooltip" data-placement="bottom" title="In-development version">1.0.3.9000</span> + <span class="version label label-info" data-toggle="tooltip" data-placement="bottom" title="In-development version">1.2.0</span> </span> </div> @@ -42,7 +44,7 @@ <a href="../../reference/index.html">Functions and data</a> </li> <li class="dropdown"> - <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"> + <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false"> Articles <span class="caret"></span> @@ -58,12 +60,18 @@ <a href="../../articles/FOCUS_L.html">Example evaluation of FOCUS Laboratory Data L1 to L3</a> </li> <li> - <a href="../../articles/web_only/FOCUS_Z.html">Example evaluation of FOCUS Example Dataset Z</a> + <a href="../../articles/web_only/dimethenamid_2018.html">Example evaluations of dimethenamid data from 2018 with nonlinear mixed-effects models</a> + </li> + <li> + <a href="../../articles/web_only/multistart.html">Short demo of the multistart method</a> </li> <li> <a href="../../articles/web_only/compiled_models.html">Performance benefit by using compiled model definitions in mkin</a> </li> <li> + <a href="../../articles/web_only/FOCUS_Z.html">Example evaluation of FOCUS Example Dataset Z</a> + </li> + <li> <a href="../../articles/twa.html">Calculation of time weighted average concentrations with mkin</a> </li> <li> @@ -80,7 +88,7 @@ </ul> <ul class="nav navbar-nav navbar-right"> <li> - <a href="https://github.com/jranke/mkin/"> + <a href="https://github.com/jranke/mkin/" class="external-link"> <span class="fab fa-github fa-lg"></span> </a> @@ -95,108 +103,108 @@ - </header><script src="compiled_models_files/header-attrs-2.6/header-attrs.js"></script><script src="compiled_models_files/accessible-code-block-0.0.1/empty-anchor.js"></script><div class="row"> + </header><script src="compiled_models_files/accessible-code-block-0.0.1/empty-anchor.js"></script><div class="row"> <div class="col-md-9 contents"> <div class="page-header toc-ignore"> <h1 data-toc-skip>Performance benefit by using compiled model definitions in mkin</h1> - <h4 class="author">Johannes Ranke</h4> + <h4 data-toc-skip class="author">Johannes Ranke</h4> - <h4 class="date">2021-02-15</h4> + <h4 data-toc-skip class="date">2022-11-01</h4> - <small class="dont-index">Source: <a href="https://github.com/jranke/mkin/blob/master/vignettes/web_only/compiled_models.rmd"><code>vignettes/web_only/compiled_models.rmd</code></a></small> + <small class="dont-index">Source: <a href="https://github.com/jranke/mkin/blob/HEAD/vignettes/web_only/compiled_models.rmd" class="external-link"><code>vignettes/web_only/compiled_models.rmd</code></a></small> <div class="hidden name"><code>compiled_models.rmd</code></div> </div> -<div id="how-to-benefit-from-compiled-models" class="section level2"> -<h2 class="hasAnchor"> -<a href="#how-to-benefit-from-compiled-models" class="anchor"></a>How to benefit from compiled models</h2> +<div class="section level2"> +<h2 id="how-to-benefit-from-compiled-models">How to benefit from compiled models<a class="anchor" aria-label="anchor" href="#how-to-benefit-from-compiled-models"></a> +</h2> <p>When using an mkin version equal to or greater than 0.9-36 and a C compiler is available, you will see a message that the model is being compiled from autogenerated C code when defining a model using mkinmod. Starting from version 0.9.49.9, the <code><a href="../../reference/mkinmod.html">mkinmod()</a></code> function checks for presence of a compiler using</p> <div class="sourceCode" id="cb1"><pre class="downlit sourceCode r"> -<code class="sourceCode R"><span class="fu">pkgbuild</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/pkgbuild/man/has_compiler.html">has_compiler</a></span><span class="op">(</span><span class="op">)</span></code></pre></div> -<p>In previous versions, it used <code><a href="https://rdrr.io/r/base/Sys.which.html">Sys.which("gcc")</a></code> for this check.</p> +<code class="sourceCode R"><span><span class="fu">pkgbuild</span><span class="fu">::</span><span class="fu"><a href="https://rdrr.io/pkg/pkgbuild/man/has_compiler.html" class="external-link">has_compiler</a></span><span class="op">(</span><span class="op">)</span></span></code></pre></div> +<p>In previous versions, it used <code>Sys.which("gcc")</code> for this check.</p> <p>On Linux, you need to have the essential build tools like make and gcc or clang installed. On Debian based linux distributions, these will be pulled in by installing the build-essential package.</p> <p>On MacOS, which I do not use personally, I have had reports that a compiler is available by default.</p> <p>On Windows, you need to install Rtools and have the path to its bin directory in your PATH variable. You do not need to modify the PATH variable when installing Rtools. Instead, I would recommend to put the line</p> <div class="sourceCode" id="cb2"><pre class="downlit sourceCode r"> -<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/base/Sys.setenv.html">Sys.setenv</a></span><span class="op">(</span>PATH <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/paste.html">paste</a></span><span class="op">(</span><span class="st">"C:/Rtools/bin"</span>, <span class="fu"><a href="https://rdrr.io/r/base/Sys.getenv.html">Sys.getenv</a></span><span class="op">(</span><span class="st">"PATH"</span><span class="op">)</span>, sep<span class="op">=</span><span class="st">";"</span><span class="op">)</span><span class="op">)</span></code></pre></div> +<code class="sourceCode R"><span><span class="fu"><a href="https://rdrr.io/r/base/Sys.setenv.html" class="external-link">Sys.setenv</a></span><span class="op">(</span>PATH <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/paste.html" class="external-link">paste</a></span><span class="op">(</span><span class="st">"C:/Rtools/bin"</span>, <span class="fu"><a href="https://rdrr.io/r/base/Sys.getenv.html" class="external-link">Sys.getenv</a></span><span class="op">(</span><span class="st">"PATH"</span><span class="op">)</span>, sep<span class="op">=</span><span class="st">";"</span><span class="op">)</span><span class="op">)</span></span></code></pre></div> <p>into your .Rprofile startup file. This is just a text file with some R code that is executed when your R session starts. It has to be named .Rprofile and has to be located in your home directory, which will generally be your Documents folder. You can check the location of the home directory used by R by issuing</p> <div class="sourceCode" id="cb3"><pre class="downlit sourceCode r"> -<code class="sourceCode R"><span class="fu"><a href="https://rdrr.io/r/base/Sys.getenv.html">Sys.getenv</a></span><span class="op">(</span><span class="st">"HOME"</span><span class="op">)</span></code></pre></div> +<code class="sourceCode R"><span><span class="fu"><a href="https://rdrr.io/r/base/Sys.getenv.html" class="external-link">Sys.getenv</a></span><span class="op">(</span><span class="st">"HOME"</span><span class="op">)</span></span></code></pre></div> </div> -<div id="comparison-with-other-solution-methods" class="section level2"> -<h2 class="hasAnchor"> -<a href="#comparison-with-other-solution-methods" class="anchor"></a>Comparison with other solution methods</h2> +<div class="section level2"> +<h2 id="comparison-with-other-solution-methods">Comparison with other solution methods<a class="anchor" aria-label="anchor" href="#comparison-with-other-solution-methods"></a> +</h2> <p>First, we build a simple degradation model for a parent compound with one metabolite, and we remove zero values from the dataset.</p> <div class="sourceCode" id="cb4"><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="st"><a href="https://pkgdown.jrwb.de/mkin/">"mkin"</a></span>, quietly <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span> -<span class="va">SFO_SFO</span> <span class="op"><-</span> <span class="fu"><a href="../../reference/mkinmod.html">mkinmod</a></span><span class="op">(</span> - parent <span class="op">=</span> <span class="fu"><a href="../../reference/mkinmod.html">mkinsub</a></span><span class="op">(</span><span class="st">"SFO"</span>, <span class="st">"m1"</span><span class="op">)</span>, - m1 <span class="op">=</span> <span class="fu"><a href="../../reference/mkinmod.html">mkinsub</a></span><span class="op">(</span><span class="st">"SFO"</span><span class="op">)</span><span class="op">)</span></code></pre></div> -<pre><code>## Temporary DLL for differentials generated and loaded</code></pre> +<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="st"><a href="https://pkgdown.jrwb.de/mkin/">"mkin"</a></span>, quietly <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span> +<span><span class="va">SFO_SFO</span> <span class="op"><-</span> <span class="fu"><a href="../../reference/mkinmod.html">mkinmod</a></span><span class="op">(</span></span> +<span> parent <span class="op">=</span> <span class="fu"><a href="../../reference/mkinmod.html">mkinsub</a></span><span class="op">(</span><span class="st">"SFO"</span>, <span class="st">"m1"</span><span class="op">)</span>,</span> +<span> m1 <span class="op">=</span> <span class="fu"><a href="../../reference/mkinmod.html">mkinsub</a></span><span class="op">(</span><span class="st">"SFO"</span><span class="op">)</span><span class="op">)</span></span></code></pre></div> +<pre><code><span><span class="co">## Temporary DLL for differentials generated and loaded</span></span></code></pre> <div class="sourceCode" id="cb6"><pre class="downlit sourceCode r"> -<code class="sourceCode R"><span class="va">FOCUS_D</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/pkg/saemix/man/subset.html">subset</a></span><span class="op">(</span><span class="va">FOCUS_2006_D</span>, <span class="va">value</span> <span class="op">!=</span> <span class="fl">0</span><span class="op">)</span></code></pre></div> +<code class="sourceCode R"><span><span class="va">FOCUS_D</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/subset.html" class="external-link">subset</a></span><span class="op">(</span><span class="va">FOCUS_2006_D</span>, <span class="va">value</span> <span class="op">!=</span> <span class="fl">0</span><span class="op">)</span></span></code></pre></div> <p>We can compare the performance of the Eigenvalue based solution against the compiled version and the R implementation of the differential equations using the benchmark package. In the output of below code, the warnings about zero being removed from the FOCUS D dataset are suppressed. Since mkin version 0.9.49.11, an analytical solution is also implemented, which is included in the tests below.</p> <div class="sourceCode" id="cb7"><pre class="downlit sourceCode r"> -<code class="sourceCode R"><span class="kw">if</span> <span class="op">(</span><span class="kw"><a href="https://rdrr.io/r/base/library.html">require</a></span><span class="op">(</span><span class="va"><a href="http://rbenchmark.googlecode.com">rbenchmark</a></span><span class="op">)</span><span class="op">)</span> <span class="op">{</span> - <span class="va">b.1</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/pkg/rbenchmark/man/benchmark.html">benchmark</a></span><span class="op">(</span> - <span class="st">"deSolve, not compiled"</span> <span class="op">=</span> <span class="fu"><a href="../../reference/mkinfit.html">mkinfit</a></span><span class="op">(</span><span class="va">SFO_SFO</span>, <span class="va">FOCUS_D</span>, - solution_type <span class="op">=</span> <span class="st">"deSolve"</span>, - use_compiled <span class="op">=</span> <span class="cn">FALSE</span>, quiet <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span>, - <span class="st">"Eigenvalue based"</span> <span class="op">=</span> <span class="fu"><a href="../../reference/mkinfit.html">mkinfit</a></span><span class="op">(</span><span class="va">SFO_SFO</span>, <span class="va">FOCUS_D</span>, - solution_type <span class="op">=</span> <span class="st">"eigen"</span>, quiet <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span>, - <span class="st">"deSolve, compiled"</span> <span class="op">=</span> <span class="fu"><a href="../../reference/mkinfit.html">mkinfit</a></span><span class="op">(</span><span class="va">SFO_SFO</span>, <span class="va">FOCUS_D</span>, - solution_type <span class="op">=</span> <span class="st">"deSolve"</span>, quiet <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span>, - <span class="st">"analytical"</span> <span class="op">=</span> <span class="fu"><a href="../../reference/mkinfit.html">mkinfit</a></span><span class="op">(</span><span class="va">SFO_SFO</span>, <span class="va">FOCUS_D</span>, - solution_type <span class="op">=</span> <span class="st">"analytical"</span>, - use_compiled <span class="op">=</span> <span class="cn">FALSE</span>, quiet <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span>, - replications <span class="op">=</span> <span class="fl">1</span>, order <span class="op">=</span> <span class="st">"relative"</span>, - columns <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">"test"</span>, <span class="st">"replications"</span>, <span class="st">"relative"</span>, <span class="st">"elapsed"</span><span class="op">)</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">b.1</span><span class="op">)</span> -<span class="op">}</span> <span class="kw">else</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="st">"R package rbenchmark is not available"</span><span class="op">)</span> -<span class="op">}</span></code></pre></div> -<pre><code>## test replications relative elapsed -## 4 analytical 1 1.000 0.182 -## 3 deSolve, compiled 1 1.824 0.332 -## 2 Eigenvalue based 1 2.082 0.379 -## 1 deSolve, not compiled 1 46.181 8.405</code></pre> +<code class="sourceCode R"><span><span class="kw">if</span> <span class="op">(</span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">require</a></span><span class="op">(</span><span class="va"><a href="http://rbenchmark.googlecode.com" class="external-link">rbenchmark</a></span><span class="op">)</span><span class="op">)</span> <span class="op">{</span></span> +<span> <span class="va">b.1</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/pkg/rbenchmark/man/benchmark.html" class="external-link">benchmark</a></span><span class="op">(</span></span> +<span> <span class="st">"deSolve, not compiled"</span> <span class="op">=</span> <span class="fu"><a href="../../reference/mkinfit.html">mkinfit</a></span><span class="op">(</span><span class="va">SFO_SFO</span>, <span class="va">FOCUS_D</span>,</span> +<span> solution_type <span class="op">=</span> <span class="st">"deSolve"</span>,</span> +<span> use_compiled <span class="op">=</span> <span class="cn">FALSE</span>, quiet <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span>,</span> +<span> <span class="st">"Eigenvalue based"</span> <span class="op">=</span> <span class="fu"><a href="../../reference/mkinfit.html">mkinfit</a></span><span class="op">(</span><span class="va">SFO_SFO</span>, <span class="va">FOCUS_D</span>,</span> +<span> solution_type <span class="op">=</span> <span class="st">"eigen"</span>, quiet <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span>,</span> +<span> <span class="st">"deSolve, compiled"</span> <span class="op">=</span> <span class="fu"><a href="../../reference/mkinfit.html">mkinfit</a></span><span class="op">(</span><span class="va">SFO_SFO</span>, <span class="va">FOCUS_D</span>,</span> +<span> solution_type <span class="op">=</span> <span class="st">"deSolve"</span>, quiet <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span>,</span> +<span> <span class="st">"analytical"</span> <span class="op">=</span> <span class="fu"><a href="../../reference/mkinfit.html">mkinfit</a></span><span class="op">(</span><span class="va">SFO_SFO</span>, <span class="va">FOCUS_D</span>,</span> +<span> solution_type <span class="op">=</span> <span class="st">"analytical"</span>,</span> +<span> use_compiled <span class="op">=</span> <span class="cn">FALSE</span>, quiet <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span>,</span> +<span> replications <span class="op">=</span> <span class="fl">1</span>, order <span class="op">=</span> <span class="st">"relative"</span>,</span> +<span> columns <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="st">"test"</span>, <span class="st">"replications"</span>, <span class="st">"relative"</span>, <span class="st">"elapsed"</span><span class="op">)</span><span class="op">)</span></span> +<span> <span class="fu"><a href="https://rdrr.io/r/base/print.html" class="external-link">print</a></span><span class="op">(</span><span class="va">b.1</span><span class="op">)</span></span> +<span><span class="op">}</span> <span class="kw">else</span> <span class="op">{</span></span> +<span> <span class="fu"><a href="https://rdrr.io/r/base/print.html" class="external-link">print</a></span><span class="op">(</span><span class="st">"R package rbenchmark is not available"</span><span class="op">)</span></span> +<span><span class="op">}</span></span></code></pre></div> +<pre><code><span><span class="co">## test replications relative elapsed</span></span> +<span><span class="co">## 4 analytical 1 1.000 0.186</span></span> +<span><span class="co">## 3 deSolve, compiled 1 1.656 0.308</span></span> +<span><span class="co">## 2 Eigenvalue based 1 2.102 0.391</span></span> +<span><span class="co">## 1 deSolve, not compiled 1 38.968 7.248</span></span></code></pre> <p>We see that using the compiled model is by more than a factor of 10 faster than using deSolve without compiled code.</p> </div> -<div id="model-without-analytical-solution" class="section level2"> -<h2 class="hasAnchor"> -<a href="#model-without-analytical-solution" class="anchor"></a>Model without analytical solution</h2> +<div class="section level2"> +<h2 id="model-without-analytical-solution">Model without analytical solution<a class="anchor" aria-label="anchor" href="#model-without-analytical-solution"></a> +</h2> <p>This evaluation is also taken from the example section of mkinfit. No analytical solution is available for this system, and now Eigenvalue based solution is possible, so only deSolve using with or without compiled code is available.</p> <div class="sourceCode" id="cb9"><pre class="downlit sourceCode r"> -<code class="sourceCode R"><span class="kw">if</span> <span class="op">(</span><span class="kw"><a href="https://rdrr.io/r/base/library.html">require</a></span><span class="op">(</span><span class="va"><a href="http://rbenchmark.googlecode.com">rbenchmark</a></span><span class="op">)</span><span class="op">)</span> <span class="op">{</span> - <span class="va">FOMC_SFO</span> <span class="op"><-</span> <span class="fu"><a href="../../reference/mkinmod.html">mkinmod</a></span><span class="op">(</span> - parent <span class="op">=</span> <span class="fu"><a href="../../reference/mkinmod.html">mkinsub</a></span><span class="op">(</span><span class="st">"FOMC"</span>, <span class="st">"m1"</span><span class="op">)</span>, - m1 <span class="op">=</span> <span class="fu"><a href="../../reference/mkinmod.html">mkinsub</a></span><span class="op">(</span> <span class="st">"SFO"</span><span class="op">)</span><span class="op">)</span> - - <span class="va">b.2</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/pkg/rbenchmark/man/benchmark.html">benchmark</a></span><span class="op">(</span> - <span class="st">"deSolve, not compiled"</span> <span class="op">=</span> <span class="fu"><a href="../../reference/mkinfit.html">mkinfit</a></span><span class="op">(</span><span class="va">FOMC_SFO</span>, <span class="va">FOCUS_D</span>, - use_compiled <span class="op">=</span> <span class="cn">FALSE</span>, quiet <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span>, - <span class="st">"deSolve, compiled"</span> <span class="op">=</span> <span class="fu"><a href="../../reference/mkinfit.html">mkinfit</a></span><span class="op">(</span><span class="va">FOMC_SFO</span>, <span class="va">FOCUS_D</span>, quiet <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span>, - replications <span class="op">=</span> <span class="fl">1</span>, order <span class="op">=</span> <span class="st">"relative"</span>, - columns <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">"test"</span>, <span class="st">"replications"</span>, <span class="st">"relative"</span>, <span class="st">"elapsed"</span><span class="op">)</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">b.2</span><span class="op">)</span> - <span class="va">factor_FOMC_SFO</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/Round.html">round</a></span><span class="op">(</span><span class="va">b.2</span><span class="op">[</span><span class="st">"1"</span>, <span class="st">"relative"</span><span class="op">]</span><span class="op">)</span> -<span class="op">}</span> <span class="kw">else</span> <span class="op">{</span> - <span class="va">factor_FOMC_SFO</span> <span class="op"><-</span> <span class="cn">NA</span> - <span class="fu"><a href="https://rdrr.io/r/base/print.html">print</a></span><span class="op">(</span><span class="st">"R package benchmark is not available"</span><span class="op">)</span> -<span class="op">}</span></code></pre></div> -<pre><code>## Temporary DLL for differentials generated and loaded</code></pre> -<pre><code>## test replications relative elapsed -## 2 deSolve, compiled 1 1.000 0.541 -## 1 deSolve, not compiled 1 29.091 15.738</code></pre> +<code class="sourceCode R"><span><span class="kw">if</span> <span class="op">(</span><span class="kw"><a href="https://rdrr.io/r/base/library.html" class="external-link">require</a></span><span class="op">(</span><span class="va"><a href="http://rbenchmark.googlecode.com" class="external-link">rbenchmark</a></span><span class="op">)</span><span class="op">)</span> <span class="op">{</span></span> +<span> <span class="va">FOMC_SFO</span> <span class="op"><-</span> <span class="fu"><a href="../../reference/mkinmod.html">mkinmod</a></span><span class="op">(</span></span> +<span> parent <span class="op">=</span> <span class="fu"><a href="../../reference/mkinmod.html">mkinsub</a></span><span class="op">(</span><span class="st">"FOMC"</span>, <span class="st">"m1"</span><span class="op">)</span>,</span> +<span> m1 <span class="op">=</span> <span class="fu"><a href="../../reference/mkinmod.html">mkinsub</a></span><span class="op">(</span> <span class="st">"SFO"</span><span class="op">)</span><span class="op">)</span></span> +<span></span> +<span> <span class="va">b.2</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/pkg/rbenchmark/man/benchmark.html" class="external-link">benchmark</a></span><span class="op">(</span></span> +<span> <span class="st">"deSolve, not compiled"</span> <span class="op">=</span> <span class="fu"><a href="../../reference/mkinfit.html">mkinfit</a></span><span class="op">(</span><span class="va">FOMC_SFO</span>, <span class="va">FOCUS_D</span>,</span> +<span> use_compiled <span class="op">=</span> <span class="cn">FALSE</span>, quiet <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span>,</span> +<span> <span class="st">"deSolve, compiled"</span> <span class="op">=</span> <span class="fu"><a href="../../reference/mkinfit.html">mkinfit</a></span><span class="op">(</span><span class="va">FOMC_SFO</span>, <span class="va">FOCUS_D</span>, quiet <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span>,</span> +<span> replications <span class="op">=</span> <span class="fl">1</span>, order <span class="op">=</span> <span class="st">"relative"</span>,</span> +<span> columns <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="st">"test"</span>, <span class="st">"replications"</span>, <span class="st">"relative"</span>, <span class="st">"elapsed"</span><span class="op">)</span><span class="op">)</span></span> +<span> <span class="fu"><a href="https://rdrr.io/r/base/print.html" class="external-link">print</a></span><span class="op">(</span><span class="va">b.2</span><span class="op">)</span></span> +<span> <span class="va">factor_FOMC_SFO</span> <span class="op"><-</span> <span class="fu"><a href="https://rdrr.io/r/base/Round.html" class="external-link">round</a></span><span class="op">(</span><span class="va">b.2</span><span class="op">[</span><span class="st">"1"</span>, <span class="st">"relative"</span><span class="op">]</span><span class="op">)</span></span> +<span><span class="op">}</span> <span class="kw">else</span> <span class="op">{</span></span> +<span> <span class="va">factor_FOMC_SFO</span> <span class="op"><-</span> <span class="cn">NA</span></span> +<span> <span class="fu"><a href="https://rdrr.io/r/base/print.html" class="external-link">print</a></span><span class="op">(</span><span class="st">"R package benchmark is not available"</span><span class="op">)</span></span> +<span><span class="op">}</span></span></code></pre></div> +<pre><code><span><span class="co">## Temporary DLL for differentials generated and loaded</span></span></code></pre> +<pre><code><span><span class="co">## test replications relative elapsed</span></span> +<span><span class="co">## 2 deSolve, compiled 1 1.000 0.452</span></span> +<span><span class="co">## 1 deSolve, not compiled 1 29.431 13.303</span></span></code></pre> <p>Here we get a performance benefit of a factor of 29 using the version of the differential equation model compiled from C code!</p> -<p>This vignette was built with mkin 1.0.3.9000 on</p> -<pre><code>## R version 4.0.3 (2020-10-10) -## Platform: x86_64-pc-linux-gnu (64-bit) -## Running under: Debian GNU/Linux bullseye/sid</code></pre> -<pre><code>## CPU model: AMD Ryzen 7 1700 Eight-Core Processor</code></pre> +<p>This vignette was built with mkin 1.2.0 on</p> +<pre><code><span><span class="co">## R version 4.2.2 (2022-10-31)</span></span> +<span><span class="co">## Platform: x86_64-pc-linux-gnu (64-bit)</span></span> +<span><span class="co">## Running under: Debian GNU/Linux 11 (bullseye)</span></span></code></pre> +<pre><code><span><span class="co">## CPU model: AMD Ryzen 7 1700 Eight-Core Processor</span></span></code></pre> </div> </div> @@ -211,11 +219,13 @@ <footer><div class="copyright"> - <p>Developed by Johannes Ranke.</p> + <p></p> +<p>Developed by Johannes Ranke.</p> </div> <div class="pkgdown"> - <p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.6.1.</p> + <p></p> +<p>Site built with <a href="https://pkgdown.r-lib.org/" class="external-link">pkgdown</a> 2.0.6.</p> </div> </footer> @@ -224,5 +234,7 @@ + + </body> </html> diff --git a/docs/dev/articles/web_only/multistart.html b/docs/dev/articles/web_only/multistart.html index 0c08905a..50a57d1b 100644 --- a/docs/dev/articles/web_only/multistart.html +++ b/docs/dev/articles/web_only/multistart.html @@ -34,7 +34,7 @@ </button> <span class="navbar-brand"> <a class="navbar-link" href="../../index.html">mkin</a> - <span class="version label label-info" data-toggle="tooltip" data-placement="bottom" title="In-development version">1.1.2</span> + <span class="version label label-info" data-toggle="tooltip" data-placement="bottom" title="In-development version">1.2.0</span> </span> </div> @@ -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 26 September 2022 (rebuilt 2022-10-28)</h4> + <h4 data-toc-skip class="date">Last change 26 September 2022 (rebuilt 2022-11-01)</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> @@ -144,23 +144,21 @@ <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"><-</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"><-</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/illparms.html">illparms</a></span><span class="op">(</span><span class="va">f_saem_reduced</span><span class="op">)</span></span> +<span><span class="va">f_saem_reduced_multi</span> <span class="op"><-</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/parplot.html">parplot</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="cb8"><pre class="downlit sourceCode r"> +<div class="sourceCode" id="cb6"><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-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"> +<div class="sourceCode" id="cb7"><pre class="downlit sourceCode r"> <code class="sourceCode R"><span><span class="fu"><a href="../../reference/parplot.html">parplot</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"> +<div class="sourceCode" id="cb8"><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> |