aboutsummaryrefslogblamecommitdiff
path: root/docs/dev/reference/nlme.mmkin.html
blob: 3fa4d97bbc6e820a3ff4e81b84405ad519b30297 (plain) (tree)











































































                                                                                                                                                                                                             
                                                                                                                                           














































                                                                                                                             
                                            

















                                                         
                                                                                                                                                 









                                                                              
                                                     














                                                                                                                                                                                                                                                                                                                   

                                                  
                                                                                                                                                                                     

                                                  
                                                                                                                                                                                                   
















































































                                                                                               




                                                                                                                                                                                                                                                                                  

                                                                                            
                                                                                                    

                                                                                            









                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       













                                                                                                  

                                                      

                     
                                                                     

                          

                                                           
                                                                                                                                                                                                           
                                                                                                                                                                                                                                                                 


                                                         

                                   

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         











                                                                                                  

                                



                                  
                                  
                                                                                                                                                                                                                                                                                                                                                                                         




                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              




                                                                                                                                                                                                                                                                                                                                                                

                                                                                                                            
 
                                                                                                                                                                                                                                                                                                                          
                                                                                                                                                                                 
                                                                                                              
                                                    
                                                                                                                                                                                                                                                                                                                                
                                                                                                                                                                                    
                                                                                                              
                                                                                                   
                                              
                                                                                                                                                                                                                                                                                                    

                                                                                                                                                                                                                                                                                                                                                                                               
                   
                                                       

                                                                        
                                                                        
                                                          

                                                                                         


                                                                   
                          




                                                                                    
                                                                                    
                                                          

                                                                                         


                                                                   



                                                                                                                                                                                                                 
                                                                                                                 
                                                                                    
                                                                                                                

                                                                                                                                                        






                                          

                                                                                                                                                                                        



                              


                                                          
                               
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         

                                                                                                       






                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         













                                                                                                  














                                                                     
                                                     
                                                                                                                                                                                                                                                                                                                                                 


                                                                                                                                                                                                                                                                                                                                  
                                                                                                                                                                           












                                                                                                  














                                                                                                      
                                                                                                                                                    



                                                                                                               















                                                                 
                                                                                











               
<!-- Generated by pkgdown: do not edit by hand -->
<!DOCTYPE html>
<html lang="en">
  <head>
  <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>Create an nlme model for an mmkin row object — nlme.mmkin • mkin</title>


<!-- 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="Create an nlme model for an mmkin row object — nlme.mmkin" />
<meta property="og:description" content="This functions sets up a nonlinear mixed effects model for an mmkin row
object. An mmkin row object is essentially a list of mkinfit objects that
have been obtained by fitting the same model to a list of datasets." />


<meta name="robots" content="noindex">

<!-- 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 data-spy="scroll" data-target="#toc">
    <div class="container template-reference-topic">
      <header>
      <div class="navbar navbar-default navbar-fixed-top" role="navigation">
  <div class="container">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </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">0.9.50.4</span>
      </span>
    </div>

    <div id="navbar" class="navbar-collapse collapse">
      <ul class="nav navbar-nav">
        <li>
  <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">
    Articles
     
    <span class="caret"></span>
  </a>
  <ul class="dropdown-menu" role="menu">
    <li>
      <a href="../articles/mkin.html">Introduction to mkin</a>
    </li>
    <li>
      <a href="../articles/FOCUS_D.html">Example evaluation of FOCUS Example Dataset D</a>
    </li>
    <li>
      <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>
    </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/twa.html">Calculation of time weighted average concentrations with mkin</a>
    </li>
    <li>
      <a href="../articles/web_only/NAFTA_examples.html">Example evaluation of NAFTA SOP Attachment examples</a>
    </li>
    <li>
      <a href="../articles/web_only/benchmarks.html">Some benchmark timings</a>
    </li>
  </ul>
</li>
<li>
  <a href="../news/index.html">News</a>
</li>
      </ul>
      <ul class="nav navbar-nav navbar-right">
        <li>
  <a href="https://github.com/jranke/mkin/">
    <span class="fab fa fab fa-github fa-lg"></span>
     
  </a>
</li>
      </ul>
      
    </div><!--/.nav-collapse -->
  </div><!--/.container -->
</div><!--/.navbar -->

      

      </header>

<div class="row">
  <div class="col-md-9 contents">
    <div class="page-header">
    <h1>Create an nlme model for an mmkin row object</h1>
    <small class="dont-index">Source: <a href='https://github.com/jranke/mkin/blob/master/R/nlme.mmkin.R'><code>R/nlme.mmkin.R</code></a></small>
    <div class="hidden name"><code>nlme.mmkin.Rd</code></div>
    </div>

    <div class="ref-description">
    <p>This functions sets up a nonlinear mixed effects model for an mmkin row
object. An mmkin row object is essentially a list of mkinfit objects that
have been obtained by fitting the same model to a list of datasets.</p>
    </div>

    <pre class="usage"><span class='co'># S3 method for mmkin</span>
<span class='fu'>nlme</span><span class='op'>(</span>
  <span class='va'>model</span>,
  data <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/sys.parent.html'>sys.frame</a></span><span class='op'>(</span><span class='fu'><a href='https://rdrr.io/r/base/sys.parent.html'>sys.parent</a></span><span class='op'>(</span><span class='op'>)</span><span class='op'>)</span>,
  <span class='va'>fixed</span>,
  random <span class='op'>=</span> <span class='va'>fixed</span>,
  <span class='va'>groups</span>,
  <span class='va'>start</span>,
  correlation <span class='op'>=</span> <span class='cn'>NULL</span>,
  weights <span class='op'>=</span> <span class='cn'>NULL</span>,
  <span class='va'>subset</span>,
  method <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'>"ML"</span>, <span class='st'>"REML"</span><span class='op'>)</span>,
  na.action <span class='op'>=</span> <span class='va'>na.fail</span>,
  <span class='va'>naPattern</span>,
  control <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/list.html'>list</a></span><span class='op'>(</span><span class='op'>)</span>,
  verbose <span class='op'>=</span> <span class='cn'>FALSE</span>
<span class='op'>)</span>

<span class='co'># S3 method for nlme.mmkin</span>
<span class='fu'><a href='https://rdrr.io/r/base/print.html'>print</a></span><span class='op'>(</span><span class='va'>x</span>, <span class='va'>...</span><span class='op'>)</span>

<span class='co'># S3 method for nlme.mmkin</span>
<span class='fu'><a href='https://rdrr.io/r/stats/update.html'>update</a></span><span class='op'>(</span><span class='va'>object</span>, <span class='va'>...</span><span class='op'>)</span></pre>

    <h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
    <table class="ref-arguments">
    <colgroup><col class="name" /><col class="desc" /></colgroup>
    <tr>
      <th>model</th>
      <td><p>An <code><a href='mmkin.html'>mmkin</a></code> row object.</p></td>
    </tr>
    <tr>
      <th>data</th>
      <td><p>Ignored, data are taken from the mmkin model</p></td>
    </tr>
    <tr>
      <th>fixed</th>
      <td><p>Ignored, all degradation parameters fitted in the
mmkin model are used as fixed parameters</p></td>
    </tr>
    <tr>
      <th>random</th>
      <td><p>If not specified, all fixed effects are complemented
with uncorrelated random effects</p></td>
    </tr>
    <tr>
      <th>groups</th>
      <td><p>See the documentation of nlme</p></td>
    </tr>
    <tr>
      <th>start</th>
      <td><p>If not specified, mean values of the fitted degradation
parameters taken from the mmkin object are used</p></td>
    </tr>
    <tr>
      <th>correlation</th>
      <td><p>See the documentation of nlme</p></td>
    </tr>
    <tr>
      <th>weights</th>
      <td><p>passed to nlme</p></td>
    </tr>
    <tr>
      <th>subset</th>
      <td><p>passed to nlme</p></td>
    </tr>
    <tr>
      <th>method</th>
      <td><p>passed to nlme</p></td>
    </tr>
    <tr>
      <th>na.action</th>
      <td><p>passed to nlme</p></td>
    </tr>
    <tr>
      <th>naPattern</th>
      <td><p>passed to nlme</p></td>
    </tr>
    <tr>
      <th>control</th>
      <td><p>passed to nlme</p></td>
    </tr>
    <tr>
      <th>verbose</th>
      <td><p>passed to nlme</p></td>
    </tr>
    <tr>
      <th>x</th>
      <td><p>An nlme.mmkin object to print</p></td>
    </tr>
    <tr>
      <th>...</th>
      <td><p>Update specifications passed to update.nlme</p></td>
    </tr>
    <tr>
      <th>object</th>
      <td><p>An nlme.mmkin object to update</p></td>
    </tr>
    </table>

    <h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2>

    <p>Upon success, a fitted nlme.mmkin object, which is an nlme object
with additional elements</p>
    <h2 class="hasAnchor" id="note"><a class="anchor" href="#note"></a>Note</h2>

    <p>As the object inherits from <a href='https://rdrr.io/pkg/nlme/man/nlme.html'>nlme::nlme</a>, there is a wealth of
methods that will automatically work on 'nlme.mmkin' objects, such as
<code><a href='https://rdrr.io/pkg/nlme/man/intervals.html'>nlme::intervals()</a></code>, <code><a href='https://rdrr.io/pkg/nlme/man/anova.lme.html'>nlme::anova.lme()</a></code> and <code><a href='https://rdrr.io/pkg/nlme/man/coef.lme.html'>nlme::coef.lme()</a></code>.</p>
    <h2 class="hasAnchor" id="see-also"><a class="anchor" href="#see-also"></a>See also</h2>

    <div class='dont-index'><p><code><a href='nlme_function.html'>nlme_function</a></code></p></div>

    <h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
    <pre class="examples"><div class='input'><span class='va'>ds</span> <span class='op'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/r/base/lapply.html'>lapply</a></span><span class='op'>(</span><span class='va'>experimental_data_for_UBA_2019</span><span class='op'>[</span><span class='fl'>6</span><span class='op'>:</span><span class='fl'>10</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='fu'><a href='https://rdrr.io/r/base/subset.html'>subset</a></span><span class='op'>(</span><span class='va'>x</span><span class='op'>$</span><span class='va'>data</span><span class='op'>[</span><span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span><span class='op'>(</span><span class='st'>"name"</span>, <span class='st'>"time"</span>, <span class='st'>"value"</span><span class='op'>)</span><span class='op'>]</span>, <span class='va'>name</span> <span class='op'>==</span> <span class='st'>"parent"</span><span class='op'>)</span><span class='op'>)</span>
<span class='va'>f</span> <span class='op'>&lt;-</span> <span class='fu'><a href='mmkin.html'>mmkin</a></span><span class='op'>(</span><span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span><span class='op'>(</span><span class='st'>"SFO"</span>, <span class='st'>"DFOP"</span><span class='op'>)</span>, <span class='va'>ds</span>, quiet <span class='op'>=</span> <span class='cn'>TRUE</span>, cores <span class='op'>=</span> <span class='fl'>1</span><span class='op'>)</span>
</div><div class='output co'>#&gt; <span class='warning'>Warning: Shapiro-Wilk test for standardized residuals: p =  0.0195</span></div><div class='output co'>#&gt; <span class='warning'>Warning: Shapiro-Wilk test for standardized residuals: p =  0.00985</span></div><div class='output co'>#&gt; <span class='warning'>Warning: Shapiro-Wilk test for standardized residuals: p =  0.011</span></div><div class='input'><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_nlme_sfo</span> <span class='op'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/pkg/nlme/man/nlme.html'>nlme</a></span><span class='op'>(</span><span class='va'>f</span><span class='op'>[</span><span class='st'>"SFO"</span>, <span class='op'>]</span><span class='op'>)</span>
<span class='va'>f_nlme_dfop</span> <span class='op'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/pkg/nlme/man/nlme.html'>nlme</a></span><span class='op'>(</span><span class='va'>f</span><span class='op'>[</span><span class='st'>"DFOP"</span>, <span class='op'>]</span><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_nlme_sfo</span>, <span class='va'>f_nlme_dfop</span><span class='op'>)</span>
</div><div class='output co'>#&gt;             df      AIC
#&gt; f_nlme_sfo   5 625.0539
#&gt; f_nlme_dfop  9 495.1270</div><div class='input'><span class='fu'><a href='https://rdrr.io/r/base/print.html'>print</a></span><span class='op'>(</span><span class='va'>f_nlme_dfop</span><span class='op'>)</span>
</div><div class='output co'>#&gt; Kinetic nonlinear mixed-effects model fit by maximum likelihood
#&gt; 
#&gt; Structural model:
#&gt; d_parent/dt = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) * exp(-k2 *
#&gt;            time)) / (g * exp(-k1 * time) + (1 - g) * exp(-k2 * time)))
#&gt;            * parent
#&gt; 
#&gt; Data:
#&gt; 90 observations of 1 variable(s) grouped in 5 datasets
#&gt; 
#&gt; Log-likelihood: -238.5635
#&gt; 
#&gt; Fixed effects:
#&gt;  list(parent_0 ~ 1, log_k1 ~ 1, log_k2 ~ 1, g_ilr ~ 1) 
#&gt;    parent_0      log_k1      log_k2       g_ilr 
#&gt; 94.17015133 -1.80015306 -4.14738870  0.02290935 
#&gt; 
#&gt; Random effects:
#&gt;  Formula: list(parent_0 ~ 1, log_k1 ~ 1, log_k2 ~ 1, g_ilr ~ 1)
#&gt;  Level: ds
#&gt;  Structure: Diagonal
#&gt;         parent_0    log_k1  log_k2     g_ilr Residual
#&gt; StdDev: 2.488249 0.8447273 1.32965 0.3289311 2.321364
#&gt; </div><div class='input'><span class='fu'><a href='https://rdrr.io/r/graphics/plot.default.html'>plot</a></span><span class='op'>(</span><span class='va'>f_nlme_dfop</span><span class='op'>)</span>
</div><div class='img'><img src='nlme.mmkin-1.png' alt='' width='700' height='433' /></div><div class='input'><span class='fu'><a href='endpoints.html'>endpoints</a></span><span class='op'>(</span><span class='va'>f_nlme_dfop</span><span class='op'>)</span>
</div><div class='output co'>#&gt; $distimes
#&gt;            DT50     DT90 DT50back  DT50_k1  DT50_k2
#&gt; parent 10.79857 100.7937 30.34193 4.193938 43.85443
#&gt; </div><div class='input'>
<span class='co'># \dontrun{</span>
  <span class='va'>f_nlme_2</span> <span class='op'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/pkg/nlme/man/nlme.html'>nlme</a></span><span class='op'>(</span><span class='va'>f</span><span class='op'>[</span><span class='st'>"SFO"</span>, <span class='op'>]</span>, start <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span><span class='op'>(</span>parent_0 <span class='op'>=</span> <span class='fl'>100</span>, log_k_parent <span class='op'>=</span> <span class='fl'>0.1</span><span class='op'>)</span><span class='op'>)</span>
  <span class='fu'><a href='https://rdrr.io/r/stats/update.html'>update</a></span><span class='op'>(</span><span class='va'>f_nlme_2</span>, random <span class='op'>=</span> <span class='va'>parent_0</span> <span class='op'>~</span> <span class='fl'>1</span><span class='op'>)</span>
</div><div class='output co'>#&gt; Kinetic nonlinear mixed-effects model fit by maximum likelihood
#&gt; 
#&gt; Structural model:
#&gt; d_parent/dt = - k_parent * parent
#&gt; 
#&gt; Data:
#&gt;  observations of 0 variable(s) grouped in 0 datasets
#&gt; 
#&gt; Log-likelihood: -404.3729
#&gt; 
#&gt; Fixed effects:
#&gt;  list(parent_0 ~ 1, log_k_parent ~ 1) 
#&gt;     parent_0 log_k_parent 
#&gt;    75.933480    -3.555983 
#&gt; 
#&gt; Random effects:
#&gt;  Formula: parent_0 ~ 1 | ds
#&gt;            parent_0 Residual
#&gt; StdDev: 0.002416792 21.63027
#&gt; </div><div class='input'>  <span class='va'>ds_2</span> <span class='op'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/r/base/lapply.html'>lapply</a></span><span class='op'>(</span><span class='va'>experimental_data_for_UBA_2019</span><span class='op'>[</span><span class='fl'>6</span><span class='op'>:</span><span class='fl'>10</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='va'>x</span><span class='op'>$</span><span class='va'>data</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'>"name"</span>, <span class='st'>"time"</span>, <span class='st'>"value"</span><span class='op'>)</span><span class='op'>]</span><span class='op'>)</span>
  <span class='va'>m_sfo_sfo</span> <span class='op'>&lt;-</span> <span class='fu'><a href='mkinmod.html'>mkinmod</a></span><span class='op'>(</span>parent <span class='op'>=</span> <span class='fu'><a href='mkinsub.html'>mkinsub</a></span><span class='op'>(</span><span class='st'>"SFO"</span>, <span class='st'>"A1"</span><span class='op'>)</span>,
    A1 <span class='op'>=</span> <span class='fu'><a href='mkinsub.html'>mkinsub</a></span><span class='op'>(</span><span class='st'>"SFO"</span><span class='op'>)</span>, use_of_ff <span class='op'>=</span> <span class='st'>"min"</span>, quiet <span class='op'>=</span> <span class='cn'>TRUE</span><span class='op'>)</span>
  <span class='va'>m_sfo_sfo_ff</span> <span class='op'>&lt;-</span> <span class='fu'><a href='mkinmod.html'>mkinmod</a></span><span class='op'>(</span>parent <span class='op'>=</span> <span class='fu'><a href='mkinsub.html'>mkinsub</a></span><span class='op'>(</span><span class='st'>"SFO"</span>, <span class='st'>"A1"</span><span class='op'>)</span>,
    A1 <span class='op'>=</span> <span class='fu'><a href='mkinsub.html'>mkinsub</a></span><span class='op'>(</span><span class='st'>"SFO"</span><span class='op'>)</span>, use_of_ff <span class='op'>=</span> <span class='st'>"max"</span>, quiet <span class='op'>=</span> <span class='cn'>TRUE</span><span class='op'>)</span>
  <span class='va'>m_dfop_sfo</span> <span class='op'>&lt;-</span> <span class='fu'><a href='mkinmod.html'>mkinmod</a></span><span class='op'>(</span>parent <span class='op'>=</span> <span class='fu'><a href='mkinsub.html'>mkinsub</a></span><span class='op'>(</span><span class='st'>"DFOP"</span>, <span class='st'>"A1"</span><span class='op'>)</span>,
    A1 <span class='op'>=</span> <span class='fu'><a href='mkinsub.html'>mkinsub</a></span><span class='op'>(</span><span class='st'>"SFO"</span><span class='op'>)</span>, quiet <span class='op'>=</span> <span class='cn'>TRUE</span><span class='op'>)</span>

  <span class='va'>f_2</span> <span class='op'>&lt;-</span> <span class='fu'><a href='mmkin.html'>mmkin</a></span><span class='op'>(</span><span class='fu'><a href='https://rdrr.io/r/base/list.html'>list</a></span><span class='op'>(</span><span class='st'>"SFO-SFO"</span> <span class='op'>=</span> <span class='va'>m_sfo_sfo</span>,
   <span class='st'>"SFO-SFO-ff"</span> <span class='op'>=</span> <span class='va'>m_sfo_sfo_ff</span>,
   <span class='st'>"DFOP-SFO"</span> <span class='op'>=</span> <span class='va'>m_dfop_sfo</span><span class='op'>)</span>,
    <span class='va'>ds_2</span>, quiet <span class='op'>=</span> <span class='cn'>TRUE</span><span class='op'>)</span>

  <span class='va'>f_nlme_sfo_sfo</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_2</span><span class='op'>[</span><span class='st'>"SFO-SFO"</span>, <span class='op'>]</span><span class='op'>)</span>
  <span class='fu'><a href='https://rdrr.io/r/graphics/plot.default.html'>plot</a></span><span class='op'>(</span><span class='va'>f_nlme_sfo_sfo</span><span class='op'>)</span>
</div><div class='img'><img src='nlme.mmkin-2.png' alt='' width='700' height='433' /></div><div class='input'>
  <span class='co'># With formation fractions</span>
  <span class='va'>f_nlme_sfo_sfo_ff</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_2</span><span class='op'>[</span><span class='st'>"SFO-SFO-ff"</span>, <span class='op'>]</span><span class='op'>)</span>
  <span class='fu'><a href='https://rdrr.io/r/graphics/plot.default.html'>plot</a></span><span class='op'>(</span><span class='va'>f_nlme_sfo_sfo_ff</span><span class='op'>)</span>
</div><div class='img'><img src='nlme.mmkin-3.png' alt='' width='700' height='433' /></div><div class='input'>
  <span class='co'># For the following fit we need to increase pnlsMaxIter and the tolerance</span>
  <span class='co'># to get convergence</span>
  <span class='va'>f_nlme_dfop_sfo</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_2</span><span class='op'>[</span><span class='st'>"DFOP-SFO"</span>, <span class='op'>]</span>,
    control <span class='op'>=</span> <span class='fu'><a href='https://rdrr.io/r/base/list.html'>list</a></span><span class='op'>(</span>pnlsMaxIter <span class='op'>=</span> <span class='fl'>120</span>, tolerance <span class='op'>=</span> <span class='fl'>5e-4</span><span class='op'>)</span>, verbose <span class='op'>=</span> <span class='cn'>TRUE</span><span class='op'>)</span>
</div><div class='output co'>#&gt; 
#&gt; **Iteration 1
#&gt; LME step: Loglik: -404.9582, nlminb iterations: 1
#&gt; reStruct  parameters:
#&gt;        ds1        ds2        ds3        ds4        ds5        ds6 
#&gt; -0.4114355  0.9798697  1.6990037  0.7293315  0.3354323  1.7113046 
#&gt;  Beginning PNLS step: ..  completed fit_nlme() step.
#&gt; PNLS step: RSS =  630.3644 
#&gt;  fixed effects: 93.82269  -5.455991  -0.6788957  -1.862196  -4.199671  0.05532828  
#&gt;  iterations: 120 
#&gt; Convergence crit. (must all become &lt;= tolerance = 0.0005):
#&gt;     fixed  reStruct 
#&gt; 0.7885368 0.5822683 
#&gt; 
#&gt; **Iteration 2
#&gt; LME step: Loglik: -407.7755, nlminb iterations: 11
#&gt; reStruct  parameters:
#&gt;          ds1          ds2          ds3          ds4          ds5          ds6 
#&gt; -0.371224133  0.003056179  1.789939402  0.724671158  0.301602977  1.754200729 
#&gt;  Beginning PNLS step: ..  completed fit_nlme() step.
#&gt; PNLS step: RSS =  630.3633 
#&gt;  fixed effects: 93.82269  -5.455992  -0.6788958  -1.862196  -4.199671  0.05532831  
#&gt;  iterations: 120 
#&gt; Convergence crit. (must all become &lt;= tolerance = 0.0005):
#&gt;        fixed     reStruct 
#&gt; 4.789774e-07 2.200661e-05 </div><div class='input'>
  <span class='fu'><a href='https://rdrr.io/r/graphics/plot.default.html'>plot</a></span><span class='op'>(</span><span class='va'>f_nlme_dfop_sfo</span><span class='op'>)</span>
</div><div class='img'><img src='nlme.mmkin-4.png' alt='' width='700' height='433' /></div><div class='input'>
  <span class='fu'><a href='https://rdrr.io/r/stats/anova.html'>anova</a></span><span class='op'>(</span><span class='va'>f_nlme_dfop_sfo</span>, <span class='va'>f_nlme_sfo_sfo</span><span class='op'>)</span>
</div><div class='output co'>#&gt;                 Model df       AIC       BIC    logLik   Test  L.Ratio p-value
#&gt; f_nlme_dfop_sfo     1 13  843.8547  884.6201 -408.9273                        
#&gt; f_nlme_sfo_sfo      2  9 1085.1821 1113.4043 -533.5910 1 vs 2 249.3274  &lt;.0001</div><div class='input'>
  <span class='fu'><a href='endpoints.html'>endpoints</a></span><span class='op'>(</span><span class='va'>f_nlme_sfo_sfo</span><span class='op'>)</span>
</div><div class='output co'>#&gt; $ff
#&gt; parent_sink   parent_A1     A1_sink 
#&gt;   0.5912432   0.4087568   1.0000000 
#&gt; 
#&gt; $distimes
#&gt;            DT50     DT90
#&gt; parent 19.13518  63.5657
#&gt; A1     66.02155 219.3189
#&gt; </div><div class='input'>  <span class='fu'><a href='endpoints.html'>endpoints</a></span><span class='op'>(</span><span class='va'>f_nlme_dfop_sfo</span><span class='op'>)</span>
</div><div class='output co'>#&gt; $ff
#&gt;   parent_A1 parent_sink 
#&gt;   0.2768574   0.7231426 
#&gt; 
#&gt; $distimes
#&gt;             DT50     DT90 DT50back  DT50_k1  DT50_k2
#&gt; parent  11.07091 104.6320 31.49738 4.462384 46.20825
#&gt; A1     162.30536 539.1667       NA       NA       NA
#&gt; </div><div class='input'>
  <span class='kw'>if</span> <span class='op'>(</span><span class='fu'><a href='https://rdrr.io/r/base/length.html'>length</a></span><span class='op'>(</span><span class='fu'>findFunction</span><span class='op'>(</span><span class='st'>"varConstProp"</span><span class='op'>)</span><span class='op'>)</span> <span class='op'>&gt;</span> <span class='fl'>0</span><span class='op'>)</span> <span class='op'>{</span> <span class='co'># tc error model for nlme available</span>
    <span class='co'># Attempts to fit metabolite kinetics with the tc error model are possible,</span>
    <span class='co'># but need tweeking of control values and sometimes do not converge</span>

    <span class='va'>f_tc</span> <span class='op'>&lt;-</span> <span class='fu'><a href='mmkin.html'>mmkin</a></span><span class='op'>(</span><span class='fu'><a href='https://rdrr.io/r/base/c.html'>c</a></span><span class='op'>(</span><span class='st'>"SFO"</span>, <span class='st'>"DFOP"</span><span class='op'>)</span>, <span class='va'>ds</span>, quiet <span class='op'>=</span> <span class='cn'>TRUE</span>, error_model <span class='op'>=</span> <span class='st'>"tc"</span><span class='op'>)</span>
    <span class='va'>f_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_tc</span><span class='op'>[</span><span class='st'>"SFO"</span>, <span class='op'>]</span><span class='op'>)</span>
    <span class='va'>f_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_tc</span><span class='op'>[</span><span class='st'>"DFOP"</span>, <span class='op'>]</span><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_nlme_sfo</span>, <span class='va'>f_nlme_sfo_tc</span>, <span class='va'>f_nlme_dfop</span>, <span class='va'>f_nlme_dfop_tc</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'>f_nlme_dfop_tc</span><span class='op'>)</span>
  <span class='op'>}</span>
</div><div class='output co'>#&gt; Kinetic nonlinear mixed-effects model fit by maximum likelihood
#&gt; 
#&gt; Structural model:
#&gt; d_parent/dt = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) * exp(-k2 *
#&gt;            time)) / (g * exp(-k1 * time) + (1 - g) * exp(-k2 * time)))
#&gt;            * parent
#&gt; 
#&gt; Data:
#&gt; 90 observations of 1 variable(s) grouped in 5 datasets
#&gt; 
#&gt; Log-likelihood: -238.4298
#&gt; 
#&gt; Fixed effects:
#&gt;  list(parent_0 ~ 1, log_k1 ~ 1, log_k2 ~ 1, g_ilr ~ 1) 
#&gt;    parent_0      log_k1      log_k2       g_ilr 
#&gt; 94.04774463 -1.82339924 -4.16715509  0.04020161 
#&gt; 
#&gt; Random effects:
#&gt;  Formula: list(parent_0 ~ 1, log_k1 ~ 1, log_k2 ~ 1, g_ilr ~ 1)
#&gt;  Level: ds
#&gt;  Structure: Diagonal
#&gt;         parent_0    log_k1   log_k2     g_ilr Residual
#&gt; StdDev: 2.473883 0.8499901 1.337187 0.3294411        1
#&gt; 
#&gt; Variance function:
#&gt;  Structure: Constant plus proportion of variance covariate
#&gt;  Formula: ~fitted(.) 
#&gt;  Parameter estimates:
#&gt;      const       prop 
#&gt; 2.23222625 0.01262414 </div><div class='input'>
  <span class='va'>f_2_obs</span> <span class='op'>&lt;-</span> <span class='fu'><a href='mmkin.html'>mmkin</a></span><span class='op'>(</span><span class='fu'><a href='https://rdrr.io/r/base/list.html'>list</a></span><span class='op'>(</span><span class='st'>"SFO-SFO"</span> <span class='op'>=</span> <span class='va'>m_sfo_sfo</span>,
   <span class='st'>"DFOP-SFO"</span> <span class='op'>=</span> <span class='va'>m_dfop_sfo</span><span class='op'>)</span>,
    <span class='va'>ds_2</span>, quiet <span class='op'>=</span> <span class='cn'>TRUE</span>, error_model <span class='op'>=</span> <span class='st'>"obs"</span><span class='op'>)</span>
  <span class='va'>f_nlme_sfo_sfo_obs</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_2_obs</span><span class='op'>[</span><span class='st'>"SFO-SFO"</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'>f_nlme_sfo_sfo_obs</span><span class='op'>)</span>
</div><div class='output co'>#&gt; Kinetic nonlinear mixed-effects model fit by maximum likelihood
#&gt; 
#&gt; Structural model:
#&gt; d_parent/dt = - k_parent_sink * parent - k_parent_A1 * parent
#&gt; d_A1/dt = + k_parent_A1 * parent - k_A1_sink * A1
#&gt; 
#&gt; Data:
#&gt; 170 observations of 2 variable(s) grouped in 5 datasets
#&gt; 
#&gt; Log-likelihood: -472.976
#&gt; 
#&gt; Fixed effects:
#&gt;  list(parent_0 ~ 1, log_k_parent_sink ~ 1, log_k_parent_A1 ~ 1,      log_k_A1_sink ~ 1) 
#&gt;          parent_0 log_k_parent_sink   log_k_parent_A1     log_k_A1_sink 
#&gt;         87.975536         -3.669816         -4.164127         -4.645073 
#&gt; 
#&gt; Random effects:
#&gt;  Formula: list(parent_0 ~ 1, log_k_parent_sink ~ 1, log_k_parent_A1 ~ 1,      log_k_A1_sink ~ 1)
#&gt;  Level: ds
#&gt;  Structure: Diagonal
#&gt;         parent_0 log_k_parent_sink log_k_parent_A1 log_k_A1_sink Residual
#&gt; StdDev: 3.992214           1.77702        1.054733     0.4821383 6.482585
#&gt; 
#&gt; Variance function:
#&gt;  Structure: Different standard deviations per stratum
#&gt;  Formula: ~1 | name 
#&gt;  Parameter estimates:
#&gt;    parent        A1 
#&gt; 1.0000000 0.2050003 </div><div class='input'>  <span class='co'># The same with DFOP-SFO does not converge, apparently the variances of</span>
  <span class='co'># parent and A1 are too similar in this case, so that the model is</span>
  <span class='co'># overparameterised</span>
  <span class='co'>#f_nlme_dfop_sfo_obs &lt;- nlme(f_2_obs["DFOP-SFO", ], control = list(maxIter = 100))</span>
<span class='co'># }</span>
</div></pre>
  </div>
  <div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">
    <nav id="toc" data-toggle="toc" class="sticky-top">
      <h2 data-toc-skip>Contents</h2>
    </nav>
  </div>
</div>


      <footer>
      <div class="copyright">
  <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>
</div>

      </footer>
   </div>

  


  </body>
</html>


Contact - Imprint