aboutsummaryrefslogblamecommitdiff
path: root/docs/reference/mkinfit.html
blob: 62e4bd8da3efa50c2b72eaa6b94d86054fd13919 (plain) (tree)
1
2
3
4
5
6
7
8
9
               
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
                                                             
                                                                      

                                                                           
                                                                         
                                                                                                                                                                                                                                                                                                                                                                                                                                          
                                                                               
                                                              
 
                                                    
                                                                                    
                               
                                                                                                                               


                                      
                                                            
                                                                                                                                     
             
          
 
                                                      
                                     
                                                          
     
                     
                                                                                                                           


                               
                                            







                                                                                                 

                                                                                                                                                      
                                                                                            
         
                                                                                                                             
         
        

                                                                                                   
                                                                                                      

                                                                                                                
        


                                                                                              
         
            

                                       
                                                                  
                                             

      
                                       
                           
 
      
 
                                
                                 
                                                                         
                                                                                                                                                               
                                                          
          
 
                                 
                                                                                 
                                                                                                                                                  
                                                                      
                                                                                                            
                                                                           
                                                                                    

                                                                         
          
 
                        

























                                                                                                                                                                                                                                                                                                                                                                                                       
          
 


                                                                                 

                                                                       
                                                
 
                                                                   





                                                                          
                   
 
                                                           


                                                                               
                                                                           

                                                                      
                     
 
                                                                  
                                                                          
                                                                                             

                                                                          
                             
 
                                                           
                                                                        
                       
 
                                                               
                                                                             
                      
 
                                                         
                                                                         
                                                  
 
                                                         

                                                                          
                                                  
 
                                                       
                                                                         
                                                                                                                                  


                                                                          
                                                             
 


                                                                                                                                                               
 


                                                                                                                                             
 
                                                                                                                                                           
 
                                                          



                                                                          
                                                         
 
                                                


                                                                        
                                                                                   
 

                                                              
 


                                                                                                                                                            
 

                                                                                                                                                            
 
                                                         
                         
                                                                             
                 
                                                                          


                                                                         
                                                       
 
                                                   

                                                                          

                                                                         
                                                                                 
                                                       
                                                                       

                                                                     
                                                                      


                                                                        
                                                                          

                                                                     
                  
 

                                                              
 
                                                          
 
                                                                 
 
                                                                       
 

                                                                                                                  
 

                    

                                                    

                      

                                                                                  

                   
                                                                   

                                                                     

                         


                                                                                         
                                                                                                               
     


                                                                                                                                                                                                                                                              
                                                                  
                                                                                                                                                                                
                                                                    


                                                      
                         
          
 
                           


                                                                                                                                                                                                                                                                                                                    


                                                                                                        




                                                                                                                         
                                                                                                                   
































                                                                                                                                    


                                                                                                                  





























                                                                                                                                        






                                                                                                                                                                                                                                                                                                                                                                                    
                                                                                                                  


                                                                                                                                                                                                                                                                                                                
                                                                                        


                                                                                                                                                                                                                                                                                                                                                                                       







                                                                                                                                                


                                                                                                                                                                                                                                                                                                                                                                                         







                                                                                                                                                
                                                                                                                                                                             


                                                                                                                                         
                                                                                                                                                                                     





                                                                                        















                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
                                                                                                 

                                                                                                 





                                                                                                                                                                                                                                                   
                                                                                                                  



                                                                                                                                                                                                                                                                                                                                                                                                 





                                                                                                                               

                                                                                                                                                                                                                                                                                                     

                                                                                                                                                              


                                                                                                        






                                                                                                                               
                                                                                                                    


                                                                                                           
                                                                                                                                            
































                                                                                                                                    
                                                                                                                        





                                                                                                                                    


                                                                                                                                    
                                                                                                                                    
                                                                                                                                    
                                                                                                 


                                                                                                 
                                                                                                 
                                                                                                 




                                                                                                                                        
                                                                                                                            
                                                                                                                            
                                                                                                                            

















                                                                                                                            




                                                                                                                                                                                                                                                                                                                                                                                         
                   
        
                                                                 
                                                                                      
      
 
                                            

                     
                                                                                                             
      
 
                     
 
  
 
  
 
                
 
<!DOCTYPE html>
<!-- Generated by pkgdown: do not edit by hand --><html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><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>Fit a kinetic model to data with one or more state variables — mkinfit • 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="Fit a kinetic model to data with one or more state variables — mkinfit"><meta property="og:description" content="This function maximises the likelihood of the observed data using the Port
algorithm stats::nlminb(), and the specified initial or fixed
parameters and starting values.  In each step of the optimisation, the
kinetic model is solved using the function mkinpredict(), except
if an analytical solution is implemented, in which case the model is solved
using the degradation function in the mkinmod object. The
parameters of the selected error model are fitted simultaneously with the
degradation model parameters, as both of them are arguments of the
likelihood function."><!-- 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-default" data-toggle="tooltip" data-placement="bottom" title="Released version">1.2.0</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" data-bs-toggle="dropdown" 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/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>
      <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">Benchmark timings for mkin</a>
    </li>
    <li>
      <a href="../articles/web_only/saem_benchmarks.html">Benchmark timings for saem.mmkin</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/" class="external-link">
    <span class="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>Fit a kinetic model to data with one or more state variables</h1>
    <small class="dont-index">Source: <a href="https://github.com/jranke/mkin/blob/HEAD/R/mkinfit.R" class="external-link"><code>R/mkinfit.R</code></a></small>
    <div class="hidden name"><code>mkinfit.Rd</code></div>
    </div>

    <div class="ref-description">
    <p>This function maximises the likelihood of the observed data using the Port
algorithm <code><a href="https://rdrr.io/r/stats/nlminb.html" class="external-link">stats::nlminb()</a></code>, and the specified initial or fixed
parameters and starting values.  In each step of the optimisation, the
kinetic model is solved using the function <code><a href="mkinpredict.html">mkinpredict()</a></code>, except
if an analytical solution is implemented, in which case the model is solved
using the degradation function in the <a href="mkinmod.html">mkinmod</a> object. The
parameters of the selected error model are fitted simultaneously with the
degradation model parameters, as both of them are arguments of the
likelihood function.</p>
    </div>

    <div id="ref-usage">
    <div class="sourceCode"><pre class="sourceCode r"><code><span><span class="fu">mkinfit</span><span class="op">(</span></span>
<span>  <span class="va">mkinmod</span>,</span>
<span>  <span class="va">observed</span>,</span>
<span>  parms.ini <span class="op">=</span> <span class="st">"auto"</span>,</span>
<span>  state.ini <span class="op">=</span> <span class="st">"auto"</span>,</span>
<span>  err.ini <span class="op">=</span> <span class="st">"auto"</span>,</span>
<span>  fixed_parms <span class="op">=</span> <span class="cn">NULL</span>,</span>
<span>  fixed_initials <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/names.html" class="external-link">names</a></span><span class="op">(</span><span class="va">mkinmod</span><span class="op">$</span><span class="va">diffs</span><span class="op">)</span><span class="op">[</span><span class="op">-</span><span class="fl">1</span><span class="op">]</span>,</span>
<span>  from_max_mean <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  solution_type <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">"auto"</span>, <span class="st">"analytical"</span>, <span class="st">"eigen"</span>, <span class="st">"deSolve"</span><span class="op">)</span>,</span>
<span>  method.ode <span class="op">=</span> <span class="st">"lsoda"</span>,</span>
<span>  use_compiled <span class="op">=</span> <span class="st">"auto"</span>,</span>
<span>  control <span class="op">=</span> <span class="fu"><a href="https://rdrr.io/r/base/list.html" class="external-link">list</a></span><span class="op">(</span>eval.max <span class="op">=</span> <span class="fl">300</span>, iter.max <span class="op">=</span> <span class="fl">200</span><span class="op">)</span>,</span>
<span>  transform_rates <span class="op">=</span> <span class="cn">TRUE</span>,</span>
<span>  transform_fractions <span class="op">=</span> <span class="cn">TRUE</span>,</span>
<span>  quiet <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  atol <span class="op">=</span> <span class="fl">1e-08</span>,</span>
<span>  rtol <span class="op">=</span> <span class="fl">1e-10</span>,</span>
<span>  error_model <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">"const"</span>, <span class="st">"obs"</span>, <span class="st">"tc"</span><span class="op">)</span>,</span>
<span>  error_model_algorithm <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">"auto"</span>, <span class="st">"d_3"</span>, <span class="st">"direct"</span>, <span class="st">"twostep"</span>, <span class="st">"threestep"</span>, <span class="st">"fourstep"</span>,</span>
<span>    <span class="st">"IRLS"</span>, <span class="st">"OLS"</span><span class="op">)</span>,</span>
<span>  reweight.tol <span class="op">=</span> <span class="fl">1e-08</span>,</span>
<span>  reweight.max.iter <span class="op">=</span> <span class="fl">10</span>,</span>
<span>  trace_parms <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  test_residuals <span class="op">=</span> <span class="cn">FALSE</span>,</span>
<span>  <span class="va">...</span></span>
<span><span class="op">)</span></span></code></pre></div>
    </div>

    <div id="arguments">
    <h2>Arguments</h2>
    <dl><dt>mkinmod</dt>
<dd><p>A list of class <a href="mkinmod.html">mkinmod</a>, containing the kinetic
model to be fitted to the data, or one of the shorthand names ("SFO",
"FOMC", "DFOP", "HS", "SFORB", "IORE"). If a shorthand name is given, a
parent only degradation model is generated for the variable with the
highest value in <code>observed</code>.</p></dd>


<dt>observed</dt>
<dd><p>A dataframe with the observed data.  The first column called
"name" must contain the name of the observed variable for each data point.
The second column must contain the times of observation, named "time".
The third column must be named "value" and contain the observed values.
Zero values in the "value" column will be removed, with a warning, in
order to avoid problems with fitting the two-component error model. This
is not expected to be a problem, because in general, values of zero are
not observed in degradation data, because there is a lower limit of
detection.</p></dd>


<dt>parms.ini</dt>
<dd><p>A named vector of initial values for the parameters,
including parameters to be optimised and potentially also fixed parameters
as indicated by <code>fixed_parms</code>.  If set to "auto", initial values for
rate constants are set to default values.  Using parameter names that are
not in the model gives an error.</p>
<p>It is possible to only specify a subset of the parameters that the model
needs. You can use the parameter lists "bparms.ode" from a previously
fitted model, which contains the differential equation parameters from
this model.  This works nicely if the models are nested. An example is
given below.</p></dd>


<dt>state.ini</dt>
<dd><p>A named vector of initial values for the state variables of
the model. In case the observed variables are represented by more than one
model variable, the names will differ from the names of the observed
variables (see <code>map</code> component of <a href="mkinmod.html">mkinmod</a>). The default
is to set the initial value of the first model variable to the mean of the
time zero values for the variable with the maximum observed value, and all
others to 0.  If this variable has no time zero observations, its initial
value is set to 100.</p></dd>


<dt>err.ini</dt>
<dd><p>A named vector of initial values for the error model
parameters to be optimised.  If set to "auto", initial values are set to
default values.  Otherwise, inital values for all error model parameters
must be given.</p></dd>


<dt>fixed_parms</dt>
<dd><p>The names of parameters that should not be optimised but
rather kept at the values specified in <code>parms.ini</code>. Alternatively,
a named numeric vector of parameters to be fixed, regardless of the values
in parms.ini.</p></dd>


<dt>fixed_initials</dt>
<dd><p>The names of model variables for which the initial
state at time 0 should be excluded from the optimisation. Defaults to all
state variables except for the first one.</p></dd>


<dt>from_max_mean</dt>
<dd><p>If this is set to TRUE, and the model has only one
observed variable, then data before the time of the maximum observed value
(after averaging for each sampling time) are discarded, and this time is
subtracted from all remaining time values, so the time of the maximum
observed mean value is the new time zero.</p></dd>


<dt>solution_type</dt>
<dd><p>If set to "eigen", the solution of the system of
differential equations is based on the spectral decomposition of the
coefficient matrix in cases that this is possible. If set to "deSolve", a
numerical <a href="https://rdrr.io/pkg/deSolve/man/ode.html" class="external-link">ode solver from package deSolve</a> is used. If
set to "analytical", an analytical solution of the model is used. This is
only implemented for relatively simple degradation models.  The default is
"auto", which uses "analytical" if possible, otherwise "deSolve" if a
compiler is present, and "eigen" if no compiler is present and the model
can be expressed using eigenvalues and eigenvectors.</p></dd>


<dt>method.ode</dt>
<dd><p>The solution method passed via <code><a href="mkinpredict.html">mkinpredict()</a></code>
to <code><a href="https://rdrr.io/pkg/deSolve/man/ode.html" class="external-link">deSolve::ode()</a></code> in case the solution type is "deSolve". The default
"lsoda" is performant, but sometimes fails to converge.</p></dd>


<dt>use_compiled</dt>
<dd><p>If set to <code>FALSE</code>, no compiled version of the
<a href="mkinmod.html">mkinmod</a> model is used in the calls to <code><a href="mkinpredict.html">mkinpredict()</a></code> even if a compiled
version is present.</p></dd>


<dt>control</dt>
<dd><p>A list of control arguments passed to <code><a href="https://rdrr.io/r/stats/nlminb.html" class="external-link">stats::nlminb()</a></code>.</p></dd>


<dt>transform_rates</dt>
<dd><p>Boolean specifying if kinetic rate constants should
be transformed in the model specification used in the fitting for better
compliance with the assumption of normal distribution of the estimator. If
TRUE, also alpha and beta parameters of the FOMC model are
log-transformed, as well as k1 and k2 rate constants for the DFOP and HS
models and the break point tb of the HS model.  If FALSE, zero is used as
a lower bound for the rates in the optimisation.</p></dd>


<dt>transform_fractions</dt>
<dd><p>Boolean specifying if formation fractions
should be transformed in the model specification used in the fitting for
better compliance with the assumption of normal distribution of the
estimator. The default (TRUE) is to do transformations. If TRUE,
the g parameter of the DFOP model is also transformed. Transformations
are described in <a href="transform_odeparms.html">transform_odeparms</a>.</p></dd>


<dt>quiet</dt>
<dd><p>Suppress printing out the current value of the negative
log-likelihood after each improvement?</p></dd>


<dt>atol</dt>
<dd><p>Absolute error tolerance, passed to <code><a href="https://rdrr.io/pkg/deSolve/man/ode.html" class="external-link">deSolve::ode()</a></code>. Default
is 1e-8, which is lower than the default in the <code><a href="https://rdrr.io/pkg/deSolve/man/lsoda.html" class="external-link">deSolve::lsoda()</a></code>
function which is used per default.</p></dd>


<dt>rtol</dt>
<dd><p>Absolute error tolerance, passed to <code><a href="https://rdrr.io/pkg/deSolve/man/ode.html" class="external-link">deSolve::ode()</a></code>. Default
is 1e-10, much lower than in <code><a href="https://rdrr.io/pkg/deSolve/man/lsoda.html" class="external-link">deSolve::lsoda()</a></code>.</p></dd>


<dt>error_model</dt>
<dd><p>If the error model is "const", a constant standard
deviation is assumed.</p>
<p>If the error model is "obs", each observed variable is assumed to have its
own variance.</p>
<p>If the error model is "tc" (two-component error model), a two component
error model similar to the one described by Rocke and Lorenzato (1995) is
used for setting up the likelihood function.  Note that this model
deviates from the model by Rocke and Lorenzato, as their model implies
that the errors follow a lognormal distribution for large values, not a
normal distribution as assumed by this method.</p></dd>


<dt>error_model_algorithm</dt>
<dd><p>If "auto", the selected algorithm depends on
the error model.  If the error model is "const", unweighted nonlinear
least squares fitting ("OLS") is selected. If the error model is "obs", or
"tc", the "d_3" algorithm is selected.</p>
<p>The algorithm "d_3" will directly minimize the negative log-likelihood
and independently also use the three step algorithm described below.
The fit with the higher likelihood is returned.</p>
<p>The algorithm "direct" will directly minimize the negative log-likelihood.</p>
<p>The algorithm "twostep" will minimize the negative log-likelihood after an
initial unweighted least squares optimisation step.</p>
<p>The algorithm "threestep" starts with unweighted least squares, then
optimizes only the error model using the degradation model parameters
found, and then minimizes the negative log-likelihood with free
degradation and error model parameters.</p>
<p>The algorithm "fourstep" starts with unweighted least squares, then
optimizes only the error model using the degradation model parameters
found, then optimizes the degradation model again with fixed error model
parameters, and finally minimizes the negative log-likelihood with free
degradation and error model parameters.</p>
<p>The algorithm "IRLS" (Iteratively Reweighted Least Squares) starts with
unweighted least squares, and then iterates optimization of the error
model parameters and subsequent optimization of the degradation model
using those error model parameters, until the error model parameters
converge.</p></dd>


<dt>reweight.tol</dt>
<dd><p>Tolerance for the convergence criterion calculated from
the error model parameters in IRLS fits.</p></dd>


<dt>reweight.max.iter</dt>
<dd><p>Maximum number of iterations in IRLS fits.</p></dd>


<dt>trace_parms</dt>
<dd><p>Should a trace of the parameter values be listed?</p></dd>


<dt>test_residuals</dt>
<dd><p>Should the residuals be tested for normal distribution?</p></dd>


<dt>...</dt>
<dd><p>Further arguments that will be passed on to
<code><a href="https://rdrr.io/pkg/deSolve/man/ode.html" class="external-link">deSolve::ode()</a></code>.</p></dd>

</dl></div>
    <div id="value">
    <h2>Value</h2>
    

<p>A list with "mkinfit" in the class attribute.</p>
    </div>
    <div id="details">
    <h2>Details</h2>
    <p>Per default, parameters in the kinetic models are internally transformed in
order to better satisfy the assumption of a normal distribution of their
estimators.</p>
    </div>
    <div id="note">
    <h2>Note</h2>
    <p>When using the "IORE" submodel for metabolites, fitting with
"transform_rates = TRUE" (the default) often leads to failures of the
numerical ODE solver. In this situation it may help to switch off the
internal rate transformation.</p>
    </div>
    <div id="references">
    <h2>References</h2>
    <p>Rocke DM and Lorenzato S (1995) A two-component model
for measurement error in analytical chemistry. <em>Technometrics</em> 37(2), 176-184.</p>
<p>Ranke J and Meinecke S (2019) Error Models for the Kinetic Evaluation of Chemical
Degradation Data. <em>Environments</em> 6(12) 124
<a href="https://doi.org/10.3390/environments6120124" class="external-link">doi:10.3390/environments6120124</a>
.</p>
    </div>
    <div id="see-also">
    <h2>See also</h2>
    <div class="dont-index"><p><a href="summary.mkinfit.html">summary.mkinfit</a>, <a href="plot.mkinfit.html">plot.mkinfit</a>, <a href="parms.html">parms</a> and <a href="https://rdrr.io/pkg/lmtest/man/lrtest.html" class="external-link">lrtest</a>.</p>
<p>Comparisons of models fitted to the same data can be made using
<code><a href="https://rdrr.io/r/stats/AIC.html" class="external-link">AIC</a></code> by virtue of the method <code><a href="logLik.mkinfit.html">logLik.mkinfit</a></code>.</p>
<p>Fitting of several models to several datasets in a single call to
<code><a href="mmkin.html">mmkin</a></code>.</p></div>
    </div>
    <div id="author">
    <h2>Author</h2>
    <p>Johannes Ranke</p>
    </div>

    <div id="ref-examples">
    <h2>Examples</h2>
    <div class="sourceCode"><pre class="sourceCode r"><code><span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co"># Use shorthand notation for parent only degradation</span></span></span>
<span class="r-in"><span><span class="va">fit</span> <span class="op">&lt;-</span> <span class="fu">mkinfit</span><span class="op">(</span><span class="st">"FOMC"</span>, <span class="va">FOCUS_2006_C</span>, quiet <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span></span>
<span class="r-in"><span><span class="fu"><a href="https://rdrr.io/r/base/summary.html" class="external-link">summary</a></span><span class="op">(</span><span class="va">fit</span><span class="op">)</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> mkin version used for fitting:    1.2.0 </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> R version used for fitting:       4.2.2 </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Date of fit:     Thu Nov 17 13:58:19 2022 </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Date of summary: Thu Nov 17 13:58:19 2022 </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Equations:</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> d_parent/dt = - (alpha/beta) * 1/((time/beta) + 1) * parent</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Model predictions using solution type analytical </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Fitted using 222 model solutions performed in 0.044 s</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Error model: Constant variance </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Error model algorithm: OLS </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Starting values for parameters to be optimised:</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>          value   type</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> parent_0  85.1  state</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> alpha      1.0 deparm</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> beta      10.0 deparm</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Starting values for the transformed parameters actually optimised:</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>               value lower upper</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> parent_0  85.100000  -Inf   Inf</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> log_alpha  0.000000  -Inf   Inf</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> log_beta   2.302585  -Inf   Inf</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Fixed parameter values:</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> None</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Results:</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span>        AIC      BIC    logLik</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   44.68652 45.47542 -18.34326</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Optimised, transformed parameters with symmetric confidence intervals:</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>           Estimate Std. Error    Lower   Upper</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> parent_0  85.87000     1.8070 81.23000 90.5200</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> log_alpha  0.05192     0.1353 -0.29580  0.3996</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> log_beta   0.65100     0.2287  0.06315  1.2390</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> sigma      1.85700     0.4378  0.73200  2.9830</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Parameter correlation:</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>             parent_0  log_alpha   log_beta     sigma</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> parent_0   1.000e+00 -1.565e-01 -3.142e-01 4.772e-08</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> log_alpha -1.565e-01  1.000e+00  9.564e-01 1.005e-07</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> log_beta  -3.142e-01  9.564e-01  1.000e+00 8.541e-08</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> sigma      4.772e-08  1.005e-07  8.541e-08 1.000e+00</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Backtransformed parameters:</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Confidence intervals for internally transformed parameters are asymmetric.</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> t-test (unrealistically) based on the assumption of normal distribution</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> for estimators of untransformed parameters.</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>          Estimate t value    Pr(&gt;t)   Lower  Upper</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> parent_0   85.870  47.530 3.893e-08 81.2300 90.520</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> alpha       1.053   7.393 3.562e-04  0.7439  1.491</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> beta        1.917   4.373 3.601e-03  1.0650  3.451</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> sigma       1.857   4.243 4.074e-03  0.7320  2.983</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> FOCUS Chi2 error levels in percent:</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>          err.min n.optim df</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> All data   6.657       3  6</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> parent     6.657       3  6</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Estimated disappearance times:</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>         DT50  DT90 DT50back</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> parent 1.785 15.15     4.56</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Data:</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>  time variable observed predicted residual</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>     0   parent     85.1    85.875  -0.7749</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>     1   parent     57.9    55.191   2.7091</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>     3   parent     29.9    31.845  -1.9452</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>     7   parent     14.6    17.012  -2.4124</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>    14   parent      9.7     9.241   0.4590</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>    28   parent      6.6     4.754   1.8460</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>    63   parent      4.0     2.102   1.8977</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>    91   parent      3.9     1.441   2.4590</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   119   parent      0.6     1.092  -0.4919</span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co"># One parent compound, one metabolite, both single first order.</span></span></span>
<span class="r-in"><span><span class="co"># We remove zero values from FOCUS dataset D in order to avoid warnings</span></span></span>
<span class="r-in"><span><span class="va">FOCUS_D</span> <span class="op">&lt;-</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></span>
<span class="r-in"><span><span class="co"># Use mkinsub for convenience in model formulation. Pathway to sink included per default.</span></span></span>
<span class="r-in"><span><span class="va">SFO_SFO</span> <span class="op">&lt;-</span> <span class="fu"><a href="mkinmod.html">mkinmod</a></span><span class="op">(</span></span></span>
<span class="r-in"><span>  parent <span class="op">=</span> <span class="fu"><a href="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>
<span class="r-in"><span>  m1 <span class="op">=</span> <span class="fu"><a href="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 class="r-msg co"><span class="r-pr">#&gt;</span> Temporary DLL for differentials generated and loaded</span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co"># Fit the model quietly to the FOCUS example dataset D using defaults</span></span></span>
<span class="r-in"><span><span class="va">fit</span> <span class="op">&lt;-</span> <span class="fu">mkinfit</span><span class="op">(</span><span class="va">SFO_SFO</span>, <span class="va">FOCUS_D</span>, quiet <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span></span></span>
<span class="r-in"><span><span class="fu"><a href="plot.mkinfit.html">plot_sep</a></span><span class="op">(</span><span class="va">fit</span><span class="op">)</span></span></span>
<span class="r-plt img"><img src="mkinfit-1.png" alt="" width="700" height="433"></span>
<span class="r-in"><span><span class="co"># As lower parent values appear to have lower variance, we try an alternative error model</span></span></span>
<span class="r-in"><span><span class="va">fit.tc</span> <span class="op">&lt;-</span> <span class="fu">mkinfit</span><span class="op">(</span><span class="va">SFO_SFO</span>, <span class="va">FOCUS_D</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></span>
<span class="r-in"><span><span class="co"># This avoids the warning, and the likelihood ratio test confirms it is preferable</span></span></span>
<span class="r-in"><span><span class="fu"><a href="https://rdrr.io/pkg/lmtest/man/lrtest.html" class="external-link">lrtest</a></span><span class="op">(</span><span class="va">fit.tc</span>, <span class="va">fit</span><span class="op">)</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Likelihood ratio test</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Model 1: SFO_SFO with error model tc and fixed parameter(s) m1_0</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Model 2: SFO_SFO with error model const and fixed parameter(s) m1_0</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   #Df  LogLik Df  Chisq Pr(&gt;Chisq)    </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1   6 -64.983                         </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 2   5 -97.224 -1 64.483  9.737e-16 ***</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> ---</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1</span>
<span class="r-in"><span><span class="co"># We can also allow for different variances of parent and metabolite as error model</span></span></span>
<span class="r-in"><span><span class="va">fit.obs</span> <span class="op">&lt;-</span> <span class="fu">mkinfit</span><span class="op">(</span><span class="va">SFO_SFO</span>, <span class="va">FOCUS_D</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></span>
<span class="r-in"><span><span class="co"># The two-component error model has significantly higher likelihood</span></span></span>
<span class="r-in"><span><span class="fu"><a href="https://rdrr.io/pkg/lmtest/man/lrtest.html" class="external-link">lrtest</a></span><span class="op">(</span><span class="va">fit.obs</span>, <span class="va">fit.tc</span><span class="op">)</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Likelihood ratio test</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Model 1: SFO_SFO with error model tc and fixed parameter(s) m1_0</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Model 2: SFO_SFO with error model obs and fixed parameter(s) m1_0</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   #Df  LogLik Df  Chisq Pr(&gt;Chisq)    </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1   6 -64.983                         </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 2   6 -96.936  0 63.907  &lt; 2.2e-16 ***</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> ---</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1</span>
<span class="r-in"><span><span class="fu"><a href="parms.html">parms</a></span><span class="op">(</span><span class="va">fit.tc</span><span class="op">)</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span>       parent_0       k_parent           k_m1 f_parent_to_m1      sigma_low </span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   1.007343e+02   1.005562e-01   5.166712e-03   5.083933e-01   3.049883e-03 </span>
<span class="r-out co"><span class="r-pr">#&gt;</span>       rsd_high </span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   7.928118e-02 </span>
<span class="r-in"><span><span class="fu"><a href="endpoints.html">endpoints</a></span><span class="op">(</span><span class="va">fit.tc</span><span class="op">)</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> $ff</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   parent_m1 parent_sink </span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   0.5083933   0.4916067 </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> $distimes</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>             DT50      DT90</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> parent   6.89313  22.89848</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> m1     134.15634 445.65772</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co"># We can show a quick (only one replication) benchmark for this case, as we</span></span></span>
<span class="r-in"><span><span class="co"># have several alternative solution methods for the model. We skip</span></span></span>
<span class="r-in"><span><span class="co"># uncompiled deSolve, as it is so slow. More benchmarks are found in the</span></span></span>
<span class="r-in"><span><span class="co"># benchmark vignette</span></span></span>
<span class="r-in"><span><span class="co"># \dontrun{</span></span></span>
<span class="r-in"><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="r-in"><span>  <span class="fu"><a href="https://rdrr.io/pkg/rbenchmark/man/benchmark.html" class="external-link">benchmark</a></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" class="external-link">c</a></span><span class="op">(</span><span class="st">"test"</span>, <span class="st">"relative"</span>, <span class="st">"elapsed"</span><span class="op">)</span>,</span></span>
<span class="r-in"><span>    deSolve_compiled <span class="op">=</span> <span class="fu">mkinfit</span><span class="op">(</span><span class="va">SFO_SFO</span>, <span class="va">FOCUS_D</span>, quiet <span class="op">=</span> <span class="cn">TRUE</span>, error_model <span class="op">=</span> <span class="st">"tc"</span>,</span></span>
<span class="r-in"><span>      solution_type <span class="op">=</span> <span class="st">"deSolve"</span>, use_compiled <span class="op">=</span> <span class="cn">TRUE</span><span class="op">)</span>,</span></span>
<span class="r-in"><span>    eigen <span class="op">=</span> <span class="fu">mkinfit</span><span class="op">(</span><span class="va">SFO_SFO</span>, <span class="va">FOCUS_D</span>, quiet <span class="op">=</span> <span class="cn">TRUE</span>, error_model <span class="op">=</span> <span class="st">"tc"</span>,</span></span>
<span class="r-in"><span>      solution_type <span class="op">=</span> <span class="st">"eigen"</span><span class="op">)</span>,</span></span>
<span class="r-in"><span>    analytical <span class="op">=</span> <span class="fu">mkinfit</span><span class="op">(</span><span class="va">SFO_SFO</span>, <span class="va">FOCUS_D</span>, quiet <span class="op">=</span> <span class="cn">TRUE</span>, error_model <span class="op">=</span> <span class="st">"tc"</span>,</span></span>
<span class="r-in"><span>      solution_type <span class="op">=</span> <span class="st">"analytical"</span><span class="op">)</span><span class="op">)</span></span></span>
<span class="r-in"><span><span class="op">}</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span>               test relative elapsed</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 3       analytical    1.000   0.570</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1 deSolve_compiled    1.682   0.959</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 2            eigen    2.609   1.487</span>
<span class="r-in"><span><span class="co"># }</span></span></span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co"># Use stepwise fitting, using optimised parameters from parent only fit, FOMC-SFO</span></span></span>
<span class="r-in"><span><span class="co"># \dontrun{</span></span></span>
<span class="r-in"><span><span class="va">FOMC_SFO</span> <span class="op">&lt;-</span> <span class="fu"><a href="mkinmod.html">mkinmod</a></span><span class="op">(</span></span></span>
<span class="r-in"><span>  parent <span class="op">=</span> <span class="fu"><a href="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>
<span class="r-in"><span>  m1 <span class="op">=</span> <span class="fu"><a href="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 class="r-msg co"><span class="r-pr">#&gt;</span> Temporary DLL for differentials generated and loaded</span>
<span class="r-in"><span><span class="va">fit.FOMC_SFO</span> <span class="op">&lt;-</span> <span class="fu">mkinfit</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>
<span class="r-in"><span><span class="co"># Again, we get a warning and try a more sophisticated error model</span></span></span>
<span class="r-in"><span><span class="va">fit.FOMC_SFO.tc</span> <span class="op">&lt;-</span> <span class="fu">mkinfit</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>, error_model <span class="op">=</span> <span class="st">"tc"</span><span class="op">)</span></span></span>
<span class="r-in"><span><span class="co"># This model has a higher likelihood, but not significantly so</span></span></span>
<span class="r-in"><span><span class="fu"><a href="https://rdrr.io/pkg/lmtest/man/lrtest.html" class="external-link">lrtest</a></span><span class="op">(</span><span class="va">fit.tc</span>, <span class="va">fit.FOMC_SFO.tc</span><span class="op">)</span></span></span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Likelihood ratio test</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Model 1: FOMC_SFO with error model tc and fixed parameter(s) m1_0</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Model 2: SFO_SFO with error model tc and fixed parameter(s) m1_0</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   #Df  LogLik Df  Chisq Pr(&gt;Chisq)</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 1   7 -64.829                     </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> 2   6 -64.983 -1 0.3075     0.5792</span>
<span class="r-in"><span><span class="co"># Also, the missing standard error for log_beta and the t-tests for alpha</span></span></span>
<span class="r-in"><span><span class="co"># and beta indicate overparameterisation</span></span></span>
<span class="r-in"><span><span class="fu"><a href="https://rdrr.io/r/base/summary.html" class="external-link">summary</a></span><span class="op">(</span><span class="va">fit.FOMC_SFO.tc</span>, data <span class="op">=</span> <span class="cn">FALSE</span><span class="op">)</span></span></span>
<span class="r-wrn co"><span class="r-pr">#&gt;</span> <span class="warning">Warning: </span>NaNs produced</span>
<span class="r-wrn co"><span class="r-pr">#&gt;</span> <span class="warning">Warning: </span>NaNs produced</span>
<span class="r-wrn co"><span class="r-pr">#&gt;</span> <span class="warning">Warning: </span>diag(.) had 0 or NA entries; non-finite result is doubtful</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> mkin version used for fitting:    1.2.0 </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> R version used for fitting:       4.2.2 </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Date of fit:     Thu Nov 17 13:58:30 2022 </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Date of summary: Thu Nov 17 13:58:30 2022 </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Equations:</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> d_parent/dt = - (alpha/beta) * 1/((time/beta) + 1) * parent</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> d_m1/dt = + f_parent_to_m1 * (alpha/beta) * 1/((time/beta) + 1) *</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>            parent - k_m1 * m1</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Model predictions using solution type deSolve </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Fitted using 3729 model solutions performed in 2.464 s</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Error model: Two-component variance function </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Error model algorithm: d_3 </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Direct fitting and three-step fitting yield approximately the same likelihood </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Starting values for parameters to be optimised:</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>                 value   type</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> parent_0       100.75  state</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> alpha            1.00 deparm</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> beta            10.00 deparm</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> k_m1             0.10 deparm</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> f_parent_to_m1   0.50 deparm</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> sigma_low        0.10  error</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> rsd_high         0.10  error</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Starting values for the transformed parameters actually optimised:</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>                      value lower upper</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> parent_0        100.750000  -Inf   Inf</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> log_k_m1         -2.302585  -Inf   Inf</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> f_parent_qlogis   0.000000  -Inf   Inf</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> log_alpha         0.000000  -Inf   Inf</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> log_beta          2.302585  -Inf   Inf</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> sigma_low         0.100000     0   Inf</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> rsd_high          0.100000     0   Inf</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Fixed parameter values:</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>      value  type</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> m1_0     0 state</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Results:</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span>       AIC      BIC    logLik</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>   143.658 155.1211 -64.82902</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Optimised, transformed parameters with symmetric confidence intervals:</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>                   Estimate Std. Error     Lower      Upper</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> parent_0        101.600000  2.6400000 96.240000 107.000000</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> log_k_m1         -5.284000  0.0929100 -5.474000  -5.095000</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> f_parent_qlogis   0.001426  0.0767000 -0.155000   0.157800</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> log_alpha         5.522000  0.0077320  5.506000   5.538000</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> log_beta          7.806000        NaN       NaN        NaN</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> sigma_low         0.002488  0.0002431  0.001992   0.002984</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> rsd_high          0.079210  0.0093280  0.060180   0.098230</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Parameter correlation:</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>                  parent_0  log_k_m1 f_parent_qlogis log_alpha log_beta</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> parent_0         1.000000 -0.095226        -0.76678   0.70544      NaN</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> log_k_m1        -0.095226  1.000000         0.51432  -0.14387      NaN</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> f_parent_qlogis -0.766780  0.514321         1.00000  -0.61396      NaN</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> log_alpha        0.705444 -0.143872        -0.61396   1.00000      NaN</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> log_beta              NaN       NaN             NaN       NaN        1</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> sigma_low        0.016073  0.001586         0.01548   5.87007      NaN</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> rsd_high         0.006626 -0.011700        -0.05357   0.04849      NaN</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>                 sigma_low  rsd_high</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> parent_0         0.016073  0.006626</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> log_k_m1         0.001586 -0.011700</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> f_parent_qlogis  0.015476 -0.053566</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> log_alpha        5.870075  0.048487</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> log_beta              NaN       NaN</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> sigma_low        1.000000 -0.652558</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> rsd_high        -0.652558  1.000000</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Backtransformed parameters:</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Confidence intervals for internally transformed parameters are asymmetric.</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> t-test (unrealistically) based on the assumption of normal distribution</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> for estimators of untransformed parameters.</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>                 Estimate t value    Pr(&gt;t)     Lower     Upper</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> parent_0       1.016e+02 32.7800 6.311e-26 9.624e+01 1.070e+02</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> k_m1           5.072e-03 10.1200 1.216e-11 4.196e-03 6.130e-03</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> f_parent_to_m1 5.004e-01 20.8300 4.317e-20 4.613e-01 5.394e-01</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> alpha          2.502e+02  0.5624 2.889e-01 2.463e+02 2.542e+02</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> beta           2.455e+03  0.5549 2.915e-01        NA        NA</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> sigma_low      2.488e-03  0.4843 3.158e-01 1.992e-03 2.984e-03</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> rsd_high       7.921e-02  8.4300 8.001e-10 6.018e-02 9.823e-02</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> FOCUS Chi2 error levels in percent:</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>          err.min n.optim df</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> All data   6.781       5 14</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> parent     7.141       3  6</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> m1         4.640       2  8</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Resulting formation fractions:</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>                 ff</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> parent_m1   0.5004</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> parent_sink 0.4996</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> </span>
<span class="r-out co"><span class="r-pr">#&gt;</span> Estimated disappearance times:</span>
<span class="r-out co"><span class="r-pr">#&gt;</span>           DT50  DT90 DT50back</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> parent   6.812  22.7    6.834</span>
<span class="r-out co"><span class="r-pr">#&gt;</span> m1     136.661 454.0       NA</span>
<span class="r-in"><span></span></span>
<span class="r-in"><span><span class="co"># We can easily use starting parameters from the parent only fit (only for illustration)</span></span></span>
<span class="r-in"><span><span class="va">fit.FOMC</span> <span class="op">=</span> <span class="fu">mkinfit</span><span class="op">(</span><span class="st">"FOMC"</span>, <span class="va">FOCUS_2006_D</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></span>
<span class="r-in"><span><span class="va">fit.FOMC_SFO</span> <span class="op">&lt;-</span> <span class="fu">mkinfit</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></span>
<span class="r-in"><span>  parms.ini <span class="op">=</span> <span class="va">fit.FOMC</span><span class="op">$</span><span class="va">bparms.ode</span>, error_model <span class="op">=</span> <span class="st">"tc"</span><span class="op">)</span></span></span>
<span class="r-in"><span><span class="co"># }</span></span></span>
</code></pre></div>
    </div>
  </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></p><p>Developed by Johannes Ranke.</p>
</div>

<div class="pkgdown">
  <p></p><p>Site built with <a href="https://pkgdown.r-lib.org/" class="external-link">pkgdown</a> 2.0.6.</p>
</div>

      </footer></div>

  


  

  </body></html>

Contact - Imprint