diff options
author | Johannes Ranke <jranke@uni-bremen.de> | 2020-05-11 05:15:19 +0200 |
---|---|---|
committer | Johannes Ranke <jranke@uni-bremen.de> | 2020-05-11 05:18:32 +0200 |
commit | 234c9059a95e104917e488a6ddd2313234a96cdc (patch) | |
tree | f6e54098f79d94578434ef727b62f7cc5d5e79b7 /docs/articles/mkin.html | |
parent | d113cd79b178fdc91aecb894707ed356129dfb75 (diff) |
Avoid merge() and data.frame() in cost function
also for deSolve and eigenvalue based solutions. This noticeably increases
performance for these methods, see test.log and benchmark vignette.
Diffstat (limited to 'docs/articles/mkin.html')
-rw-r--r-- | docs/articles/mkin.html | 113 |
1 files changed, 51 insertions, 62 deletions
diff --git a/docs/articles/mkin.html b/docs/articles/mkin.html index 42eb6c0a..b828b7dc 100644 --- a/docs/articles/mkin.html +++ b/docs/articles/mkin.html @@ -6,19 +6,19 @@ <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Introduction to mkin • mkin</title> -<!-- jquery --><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script><!-- Bootstrap --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha256-916EbMg70RQy9LHiGkXzG8hSg9EdNy97GazNG/aiY1w=" crossorigin="anonymous"> -<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script><!-- Font Awesome icons --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.7.1/css/all.min.css" integrity="sha256-nAmazAk6vS34Xqo0BSrTb+abbtFlgsFK7NKSi6o7Y78=" crossorigin="anonymous"> -<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.7.1/css/v4-shims.min.css" integrity="sha256-6qHlizsOWFskGlwVOKuns+D1nB6ssZrHQrNj1wGplHc=" crossorigin="anonymous"> -<!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script><!-- headroom.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.9.4/headroom.min.js" integrity="sha256-DJFC1kqIhelURkuza0AvYal5RxMtpzLjFhsnVIeuk+U=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.9.4/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script><!-- pkgdown --><link href="../pkgdown.css" rel="stylesheet"> +<!-- jquery --><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script><!-- Bootstrap --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha256-bZLfwXAP04zRMK2BjiO8iu9pf4FbLqX6zitd+tIvLhE=" crossorigin="anonymous"> +<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha256-nuL8/2cJ5NDSSwnKD8VqreErSWHtnEP9E7AySL+1ev4=" crossorigin="anonymous"></script><!-- bootstrap-toc --><link rel="stylesheet" href="../bootstrap-toc.css"> +<script src="../bootstrap-toc.js"></script><!-- Font Awesome icons --><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css" integrity="sha256-mmgLkCYLUQbXn0B1SRqzHar6dCnv9oZFPEC1g1cwlkk=" crossorigin="anonymous"> +<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/v4-shims.min.css" integrity="sha256-wZjR52fzng1pJHwx4aV2AO3yyTOXrcDW7jBpJtTwVxw=" crossorigin="anonymous"> +<!-- clipboard.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script><!-- headroom.js --><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js" integrity="sha256-AsUX4SJE1+yuDu5+mAVzJbuYNPHj/WroHuZ8Ir/CkE0=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script><!-- pkgdown --><link href="../pkgdown.css" rel="stylesheet"> <script src="../pkgdown.js"></script><meta property="og:title" content="Introduction to mkin"> -<meta property="og:description" content=""> -<meta name="twitter:card" content="summary"> +<meta property="og:description" content="mkin"> <!-- mathjax --><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script><!--[if lt IE 9]> <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script> <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> <![endif]--> </head> -<body> +<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"> @@ -31,7 +31,7 @@ </button> <span class="navbar-brand"> <a class="navbar-link" href="../index.html">mkin</a> - <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.9.49.6</span> + <span class="version label label-default" data-toggle="tooltip" data-placement="bottom" title="Released version">0.9.50</span> </span> </div> @@ -74,7 +74,14 @@ <a href="../news/index.html">News</a> </li> </ul> -<ul class="nav navbar-nav navbar-right"></ul> +<ul class="nav navbar-nav navbar-right"> +<li> + <a href="http://github.com/jranke/mkin/"> + <span class="fab fa fab fa-github fa-lg"></span> + + </a> +</li> + </ul> </div> <!--/.nav-collapse --> </div> @@ -87,12 +94,12 @@ </header><div class="row"> <div class="col-md-9 contents"> <div class="page-header toc-ignore"> - <h1>Introduction to mkin</h1> + <h1 data-toc-skip>Introduction to mkin</h1> <h4 class="author">Johannes Ranke</h4> - <h4 class="date">2019-11-01</h4> - + <h4 class="date">2020-05-11</h4> + <small class="dont-index">Source: <a href="http://github.com/jranke/mkin/blob/master/vignettes/mkin.Rmd"><code>vignettes/mkin.Rmd</code></a></small> <div class="hidden name"><code>mkin.Rmd</code></div> </div> @@ -104,34 +111,34 @@ <h1 class="hasAnchor"> <a href="#abstract" class="anchor"></a>Abstract</h1> <p>In the regulatory evaluation of chemical substances like plant protection products (pesticides), biocides and other chemicals, degradation data play an important role. For the evaluation of pesticide degradation experiments, detailed guidance has been developed, based on nonlinear optimisation. The <code>R</code> add-on package <code>mkin</code> implements fitting some of the models recommended in this guidance from within R and calculates some statistical measures for data series within one or more compartments, for parent and metabolites.</p> -<div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><a class="sourceLine" id="cb1-1" title="1"><span class="kw"><a href="https://rdrr.io/r/base/library.html">library</a></span>(<span class="st">"mkin"</span>, <span class="dt">quietly =</span> <span class="ot">TRUE</span>)</a> -<a class="sourceLine" id="cb1-2" title="2"><span class="co"># Define the kinetic model</span></a> -<a class="sourceLine" id="cb1-3" title="3">m_SFO_SFO_SFO <-<span class="st"> </span><span class="kw"><a href="../reference/mkinmod.html">mkinmod</a></span>(<span class="dt">parent =</span> <span class="kw"><a href="../reference/mkinsub.html">mkinsub</a></span>(<span class="st">"SFO"</span>, <span class="st">"M1"</span>),</a> -<a class="sourceLine" id="cb1-4" title="4"> <span class="dt">M1 =</span> <span class="kw"><a href="../reference/mkinsub.html">mkinsub</a></span>(<span class="st">"SFO"</span>, <span class="st">"M2"</span>),</a> -<a class="sourceLine" id="cb1-5" title="5"> <span class="dt">M2 =</span> <span class="kw"><a href="../reference/mkinsub.html">mkinsub</a></span>(<span class="st">"SFO"</span>),</a> -<a class="sourceLine" id="cb1-6" title="6"> <span class="dt">use_of_ff =</span> <span class="st">"max"</span>, <span class="dt">quiet =</span> <span class="ot">TRUE</span>)</a> -<a class="sourceLine" id="cb1-7" title="7"></a> -<a class="sourceLine" id="cb1-8" title="8"></a> -<a class="sourceLine" id="cb1-9" title="9"><span class="co"># Produce model predictions using some arbitrary parameters</span></a> -<a class="sourceLine" id="cb1-10" title="10">sampling_times =<span class="st"> </span><span class="kw"><a href="https://rdrr.io/r/base/c.html">c</a></span>(<span class="dv">0</span>, <span class="dv">1</span>, <span class="dv">3</span>, <span class="dv">7</span>, <span class="dv">14</span>, <span class="dv">28</span>, <span class="dv">60</span>, <span class="dv">90</span>, <span class="dv">120</span>)</a> -<a class="sourceLine" id="cb1-11" title="11">d_SFO_SFO_SFO <-<span class="st"> </span><span class="kw"><a href="../reference/mkinpredict.html">mkinpredict</a></span>(m_SFO_SFO_SFO,</a> -<a class="sourceLine" id="cb1-12" title="12"> <span class="kw"><a href="https://rdrr.io/r/base/c.html">c</a></span>(<span class="dt">k_parent =</span> <span class="fl">0.03</span>,</a> -<a class="sourceLine" id="cb1-13" title="13"> <span class="dt">f_parent_to_M1 =</span> <span class="fl">0.5</span>, <span class="dt">k_M1 =</span> <span class="kw"><a href="https://rdrr.io/r/base/Log.html">log</a></span>(<span class="dv">2</span>)<span class="op">/</span><span class="dv">100</span>,</a> -<a class="sourceLine" id="cb1-14" title="14"> <span class="dt">f_M1_to_M2 =</span> <span class="fl">0.9</span>, <span class="dt">k_M2 =</span> <span class="kw"><a href="https://rdrr.io/r/base/Log.html">log</a></span>(<span class="dv">2</span>)<span class="op">/</span><span class="dv">50</span>),</a> -<a class="sourceLine" id="cb1-15" title="15"> <span class="kw"><a href="https://rdrr.io/r/base/c.html">c</a></span>(<span class="dt">parent =</span> <span class="dv">100</span>, <span class="dt">M1 =</span> <span class="dv">0</span>, <span class="dt">M2 =</span> <span class="dv">0</span>),</a> -<a class="sourceLine" id="cb1-16" title="16"> sampling_times)</a> -<a class="sourceLine" id="cb1-17" title="17"></a> -<a class="sourceLine" id="cb1-18" title="18"><span class="co"># Generate a dataset by adding normally distributed errors with</span></a> -<a class="sourceLine" id="cb1-19" title="19"><span class="co"># standard deviation 3, for two replicates at each sampling time</span></a> -<a class="sourceLine" id="cb1-20" title="20">d_SFO_SFO_SFO_err <-<span class="st"> </span><span class="kw"><a href="../reference/add_err.html">add_err</a></span>(d_SFO_SFO_SFO, <span class="dt">reps =</span> <span class="dv">2</span>,</a> -<a class="sourceLine" id="cb1-21" title="21"> <span class="dt">sdfunc =</span> <span class="cf">function</span>(x) <span class="dv">3</span>,</a> -<a class="sourceLine" id="cb1-22" title="22"> <span class="dt">n =</span> <span class="dv">1</span>, <span class="dt">seed =</span> <span class="dv">123456789</span> )</a> -<a class="sourceLine" id="cb1-23" title="23"></a> -<a class="sourceLine" id="cb1-24" title="24"><span class="co"># Fit the model to the dataset</span></a> -<a class="sourceLine" id="cb1-25" title="25">f_SFO_SFO_SFO <-<span class="st"> </span><span class="kw"><a href="../reference/mkinfit.html">mkinfit</a></span>(m_SFO_SFO_SFO, d_SFO_SFO_SFO_err[[<span class="dv">1</span>]], <span class="dt">quiet =</span> <span class="ot">TRUE</span>)</a> -<a class="sourceLine" id="cb1-26" title="26"></a> -<a class="sourceLine" id="cb1-27" title="27"><span class="co"># Plot the results separately for parent and metabolites</span></a> -<a class="sourceLine" id="cb1-28" title="28"><span class="kw"><a href="../reference/plot.mkinfit.html">plot_sep</a></span>(f_SFO_SFO_SFO, <span class="dt">lpos =</span> <span class="kw"><a href="https://rdrr.io/r/base/c.html">c</a></span>(<span class="st">"topright"</span>, <span class="st">"bottomright"</span>, <span class="st">"bottomright"</span>))</a></code></pre></div> +<div class="sourceCode" id="cb1"><html><body><pre class="r"><span class="fu"><a href="https://rdrr.io/r/base/library.html">library</a></span>(<span class="st">"mkin"</span>, <span class="kw">quietly</span> <span class="kw">=</span> <span class="fl">TRUE</span>) +<span class="co"># Define the kinetic model</span> +<span class="no">m_SFO_SFO_SFO</span> <span class="kw"><-</span> <span class="fu"><a href="../reference/mkinmod.html">mkinmod</a></span>(<span class="kw">parent</span> <span class="kw">=</span> <span class="fu"><a href="../reference/mkinsub.html">mkinsub</a></span>(<span class="st">"SFO"</span>, <span class="st">"M1"</span>), + <span class="kw">M1</span> <span class="kw">=</span> <span class="fu"><a href="../reference/mkinsub.html">mkinsub</a></span>(<span class="st">"SFO"</span>, <span class="st">"M2"</span>), + <span class="kw">M2</span> <span class="kw">=</span> <span class="fu"><a href="../reference/mkinsub.html">mkinsub</a></span>(<span class="st">"SFO"</span>), + <span class="kw">use_of_ff</span> <span class="kw">=</span> <span class="st">"max"</span>, <span class="kw">quiet</span> <span class="kw">=</span> <span class="fl">TRUE</span>) + + +<span class="co"># Produce model predictions using some arbitrary parameters</span> +<span class="no">sampling_times</span> <span class="kw">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span>(<span class="fl">0</span>, <span class="fl">1</span>, <span class="fl">3</span>, <span class="fl">7</span>, <span class="fl">14</span>, <span class="fl">28</span>, <span class="fl">60</span>, <span class="fl">90</span>, <span class="fl">120</span>) +<span class="no">d_SFO_SFO_SFO</span> <span class="kw"><-</span> <span class="fu"><a href="../reference/mkinpredict.html">mkinpredict</a></span>(<span class="no">m_SFO_SFO_SFO</span>, + <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span>(<span class="kw">k_parent</span> <span class="kw">=</span> <span class="fl">0.03</span>, + <span class="kw">f_parent_to_M1</span> <span class="kw">=</span> <span class="fl">0.5</span>, <span class="kw">k_M1</span> <span class="kw">=</span> <span class="fu"><a href="https://rdrr.io/r/base/Log.html">log</a></span>(<span class="fl">2</span>)/<span class="fl">100</span>, + <span class="kw">f_M1_to_M2</span> <span class="kw">=</span> <span class="fl">0.9</span>, <span class="kw">k_M2</span> <span class="kw">=</span> <span class="fu"><a href="https://rdrr.io/r/base/Log.html">log</a></span>(<span class="fl">2</span>)/<span class="fl">50</span>), + <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span>(<span class="kw">parent</span> <span class="kw">=</span> <span class="fl">100</span>, <span class="kw">M1</span> <span class="kw">=</span> <span class="fl">0</span>, <span class="kw">M2</span> <span class="kw">=</span> <span class="fl">0</span>), + <span class="no">sampling_times</span>) + +<span class="co"># Generate a dataset by adding normally distributed errors with</span> +<span class="co"># standard deviation 3, for two replicates at each sampling time</span> +<span class="no">d_SFO_SFO_SFO_err</span> <span class="kw"><-</span> <span class="fu"><a href="../reference/add_err.html">add_err</a></span>(<span class="no">d_SFO_SFO_SFO</span>, <span class="kw">reps</span> <span class="kw">=</span> <span class="fl">2</span>, + <span class="kw">sdfunc</span> <span class="kw">=</span> <span class="kw">function</span>(<span class="no">x</span>) <span class="fl">3</span>, + <span class="kw">n</span> <span class="kw">=</span> <span class="fl">1</span>, <span class="kw">seed</span> <span class="kw">=</span> <span class="fl">123456789</span> ) + +<span class="co"># Fit the model to the dataset</span> +<span class="no">f_SFO_SFO_SFO</span> <span class="kw"><-</span> <span class="fu"><a href="../reference/mkinfit.html">mkinfit</a></span>(<span class="no">m_SFO_SFO_SFO</span>, <span class="no">d_SFO_SFO_SFO_err</span><span class="kw">[[</span><span class="fl">1</span>]], <span class="kw">quiet</span> <span class="kw">=</span> <span class="fl">TRUE</span>) + +<span class="co"># Plot the results separately for parent and metabolites</span> +<span class="fu"><a href="../reference/plot.mkinfit.html">plot_sep</a></span>(<span class="no">f_SFO_SFO_SFO</span>, <span class="kw">lpos</span> <span class="kw">=</span> <span class="fu"><a href="https://rdrr.io/r/base/c.html">c</a></span>(<span class="st">"topright"</span>, <span class="st">"bottomright"</span>, <span class="st">"bottomright"</span>))</pre></body></html></div> <p><img src="mkin_files/figure-html/unnamed-chunk-2-1.png" width="768"></p> </div> <div id="background" class="section level1"> @@ -222,29 +229,11 @@ </div> </div> - <div class="col-md-3 hidden-xs hidden-sm" id="sidebar"> + <div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar"> - <div id="tocnav"> - <h2 class="hasAnchor"> -<a href="#tocnav" class="anchor"></a>Contents</h2> - <ul class="nav nav-pills nav-stacked"> -<li><a href="#abstract">Abstract</a></li> - <li> -<a href="#background">Background</a><ul class="nav nav-pills nav-stacked"> -<li><a href="#derived-software-tools">Derived software tools</a></li> - <li><a href="#recent-developments">Recent developments</a></li> - </ul> -</li> - <li> -<a href="#internal-parameter-transformations">Internal parameter transformations</a><ul class="nav nav-pills nav-stacked"> -<li><a href="#confidence-intervals-based-on-transformed-parameters">Confidence intervals based on transformed parameters</a></li> - <li><a href="#parameter-t-test-based-on-untransformed-parameters">Parameter t-test based on untransformed parameters</a></li> - </ul> -</li> - <li><a href="#references">References</a></li> - </ul> + <nav id="toc" data-toggle="toc"><h2 data-toc-skip>Contents</h2> + </nav> </div> - </div> </div> @@ -255,7 +244,7 @@ </div> <div class="pkgdown"> - <p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.4.1.</p> + <p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.5.1.</p> </div> </footer> |