aboutsummaryrefslogblamecommitdiff
path: root/inst/web/mkinpredict.html
blob: 3a6300d005fc22514911feb56aaa9f2c3d793090 (plain) (tree)

















































































































































































































































































































                                                                                                                                                                            
                        









                                                                                            
                        









                                                                                            
                        

























                                                                                                                                                       
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
<title>mkinpredict. mkin 0.9-41</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="
  Johannes Ranke
">

<link href="css/bootstrap.css" rel="stylesheet">
<link href="css/bootstrap-responsive.css" rel="stylesheet">
<link href="css/highlight.css" rel="stylesheet">
<link href="css/staticdocs.css" rel="stylesheet">

<!--[if lt IE 9]>
  <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->

<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    tex2jax: {
      inlineMath: [ ['$','$'], ["\\(","\\)"] ],
      processEscapes: true
    }
  });
</script>
<script type="text/javascript"
  src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
  </head>

  <body>
    <div class="navbar">
  <div class="navbar-inner">
    <div class="container">
      <a class="brand" href="#">mkin 0.9-41</a>
      <div class="nav">
        <ul class="nav">
          <li><a href="index.html"><i class="icon-home icon-white"></i> Index</a></li>
        </ul>
      </div>
    </div>
  </div>
</div>

    <div class="container">
      <header>
        
      </header>
      
      <h1>
  Produce predictions from a kinetic model using specifc parameters
</h1>

<div class="row">
  <div class="span8">
    <h2>Usage</h2>
    <pre><div>mkinpredict(mkinmod, odeparms, odeini, outtimes, solution_type&nbsp;=&nbsp;"deSolve",
	      use_compiled&nbsp;=&nbsp;"auto", method.ode&nbsp;=&nbsp;"lsoda", atol&nbsp;=&nbsp;1e-08, rtol&nbsp;=&nbsp;1e-10, map_output&nbsp;=&nbsp;TRUE, ...)</div></pre>
    
    <h2>Arguments</h2>
    <dl>
      <dt>mkinmod</dt>
      <dd>
    A kinetic model as produced by <code><a href='mkinmod.html'>mkinmod</a></code>.
  </dd>
      <dt>odeparms</dt>
      <dd>
    A numeric vector specifying the parameters used in the kinetic model, which
    is generally defined as a set of ordinary differential equations.
  </dd>
      <dt>odeini</dt>
      <dd>
    A numeric vectory containing the initial values of the state variables of
    the model. Note that the state variables can differ from the observed
    variables, for example in the case of the SFORB model.
  </dd>
      <dt>outtimes</dt>
      <dd>
    A numeric vector specifying the time points for which model predictions
    should be generated.
  </dd>
      <dt>solution_type</dt>
      <dd>
    The method that should be used for producing the predictions. This should
    generally be "analytical" if there is only one observed variable, and
    usually "deSolve" in the case of several observed variables. The third
    possibility "eigen" is faster but not applicable to some models e.g.
    using FOMC for the parent compound.
  </dd>
      <dt>method.ode</dt>
      <dd>
    The solution method passed via <code><a href='mkinpredict.html'>mkinpredict</a></code> to
    <code><a href='http://www.inside-r.org/packages/cran/deSolve/docs/ode'>ode</a></code> in case the solution type is "deSolve". The default
    "lsoda" is performant, but sometimes fails to converge.
  </dd>
      <dt>use_compiled</dt>
      <dd>
    If set to <code>FALSE</code>, no compiled version of the <code><a href='mkinmod.html'>mkinmod</a></code> 
    model is used, even if is present. 
  </dd>
      <dt>atol</dt>
      <dd>
    Absolute error tolerance, passed to <code><a href='http://www.inside-r.org/packages/cran/deSolve/docs/ode'>ode</a></code>. Default is 1e-8,
    lower than in <code><a href='http://www.inside-r.org/packages/cran/deSolve/docs/lsoda'>lsoda</a></code>.
  </dd>
      <dt>rtol</dt>
      <dd>
    Absolute error tolerance, passed to <code><a href='http://www.inside-r.org/packages/cran/deSolve/docs/ode'>ode</a></code>. Default is 1e-10,
    much lower than in <code><a href='http://www.inside-r.org/packages/cran/deSolve/docs/lsoda'>lsoda</a></code>.
  </dd>
      <dt>map_output</dt>
      <dd>
    Boolean to specify if the output should list values for the observed
    variables (default) or for all state variables (if set to FALSE). 
  </dd>
      <dt>...</dt>
      <dd>
    Further arguments passed to the ode solver in case such a solver is used.
  </dd>
    </dl>
    
    <div class="Description">
      <h2>Description</h2>

      <p>This function produces a time series for all the observed variables in a
  kinetic model as specified by <code><a href='mkinmod.html'>mkinmod</a></code>, using a specific set of
  kinetic parameters and initial values for the state variables.</p>
  
    </div>

    <div class="Value">
      <h2>Value</h2>

      <p><dl>
  A matrix in the same format as the output of <code><a href='http://www.inside-r.org/packages/cran/deSolve/docs/ode'>ode</a></code>.
</dl></p>
  
    </div>
    
    <h2 id="examples">Examples</h2>
    <pre class="examples"><div class='input'>  SFO &lt;- mkinmod(degradinol = list(type = &quot;SFO&quot;))
  # Compare solution types
  mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, 
	      solution_type = &quot;analytical&quot;)
</div>
<div class='output'>   time  degradinol
1     0 100.0000000
2     1  74.0818221
3     2  54.8811636
4     3  40.6569660
5     4  30.1194212
6     5  22.3130160
7     6  16.5298888
8     7  12.2456428
9     8   9.0717953
10    9   6.7205513
11   10   4.9787068
12   11   3.6883167
13   12   2.7323722
14   13   2.0241911
15   14   1.4995577
16   15   1.1108997
17   16   0.8229747
18   17   0.6096747
19   18   0.4516581
20   19   0.3345965
21   20   0.2478752
</div>
<div class='input'>  mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, 
	      solution_type = &quot;deSolve&quot;)
</div>
<div class='output'>   time  degradinol
1     0 100.0000000
2     1  74.0818221
3     2  54.8811636
4     3  40.6569660
5     4  30.1194212
6     5  22.3130160
7     6  16.5298888
8     7  12.2456428
9     8   9.0717953
10    9   6.7205513
11   10   4.9787068
12   11   3.6883167
13   12   2.7323722
14   13   2.0241911
15   14   1.4995577
16   15   1.1108996
17   16   0.8229747
18   17   0.6096747
19   18   0.4516581
20   19   0.3345965
21   20   0.2478752
</div>
<div class='input'>  mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, 
	      solution_type = &quot;deSolve&quot;, use_compiled = FALSE)
</div>
<div class='output'>   time  degradinol
1     0 100.0000000
2     1  74.0818221
3     2  54.8811636
4     3  40.6569660
5     4  30.1194212
6     5  22.3130160
7     6  16.5298888
8     7  12.2456428
9     8   9.0717953
10    9   6.7205513
11   10   4.9787068
12   11   3.6883167
13   12   2.7323722
14   13   2.0241911
15   14   1.4995577
16   15   1.1108996
17   16   0.8229747
18   17   0.6096747
19   18   0.4516581
20   19   0.3345965
21   20   0.2478752
</div>
<div class='input'>  mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, 
	      solution_type = &quot;eigen&quot;)
</div>
<div class='output'>   time  degradinol
1     0 100.0000000
2     1  74.0818221
3     2  54.8811636
4     3  40.6569660
5     4  30.1194212
6     5  22.3130160
7     6  16.5298888
8     7  12.2456428
9     8   9.0717953
10    9   6.7205513
11   10   4.9787068
12   11   3.6883167
13   12   2.7323722
14   13   2.0241911
15   14   1.4995577
16   15   1.1108997
17   16   0.8229747
18   17   0.6096747
19   18   0.4516581
20   19   0.3345965
21   20   0.2478752
</div>
<div class='input'>

  # Compare integration methods to analytical solution
  mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, 
	      solution_type = &quot;analytical&quot;)[21,]
</div>
<div class='output'>   time degradinol
21   20  0.2478752
</div>
<div class='input'>  mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, 
	      method = &quot;lsoda&quot;)[21,]
</div>
<div class='output'>   time degradinol
21   20  0.2478752
</div>
<div class='input'>  mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20,
	      method = &quot;ode45&quot;)[21,]
</div>
<div class='output'>   time degradinol
21   20  0.2478752
</div>
<div class='input'>  mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20,
	      method = &quot;rk4&quot;)[21,]
</div>
<div class='output'>   time degradinol
21   20  0.2480043
</div>
<div class='input'> # rk4 is not as precise here

  # The number of output times used to make a lot of difference until the
  # default for atol was adjusted
  mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 
	      seq(0, 20, by = 0.1))[201,]
</div>
<div class='output'>    time degradinol
201   20  0.2478752
</div>
<div class='input'>  mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 
	      seq(0, 20, by = 0.01))[2001,]
</div>
<div class='output'>     time degradinol
2001   20  0.2478752
</div>
<div class='input'>
  # Check compiled model versions - they are faster than the eigenvalue based solutions!
  SFO_SFO = mkinmod(parent = list(type = &quot;SFO&quot;, to = &quot;m1&quot;),
                    m1 = list(type = &quot;SFO&quot;))
</div>
<strong class='message'>Successfully compiled differential equation model from auto-generated C code.</strong>
<div class='input'>  system.time(
    print(mkinpredict(SFO_SFO, c(k_parent_m1 = 0.05, k_parent_sink = 0.1, k_m1_sink = 0.01),
                c(parent = 100, m1 = 0), seq(0, 20, by = 0.1),
                solution_type = &quot;eigen&quot;)[201,]))
</div>
<div class='output'>    time   parent       m1
201   20 4.978707 27.46227
</div>
<div class='output'>   user  system elapsed 
  0.008   0.024   0.004 
</div>
<div class='input'>  system.time(
    print(mkinpredict(SFO_SFO, c(k_parent_m1 = 0.05, k_parent_sink = 0.1, k_m1_sink = 0.01),
                c(parent = 100, m1 = 0), seq(0, 20, by = 0.1), 
                solution_type = &quot;deSolve&quot;)[201,]))
</div>
<div class='output'>    time   parent       m1
201   20 4.978707 27.46227
</div>
<div class='output'>   user  system elapsed 
  0.004   0.020   0.002 
</div>
<div class='input'>  system.time(
    print(mkinpredict(SFO_SFO, c(k_parent_m1 = 0.05, k_parent_sink = 0.1, k_m1_sink = 0.01),
                c(parent = 100, m1 = 0), seq(0, 20, by = 0.1), 
                solution_type = &quot;deSolve&quot;, use_compiled = FALSE)[201,]))
</div>
<div class='output'>    time   parent       m1
201   20 4.978707 27.46227
</div>
<div class='output'>   user  system elapsed 
  0.064   0.000   0.066 
</div></pre>
  </div>
  <div class="span4">
    <!-- <ul>
      <li>mkinpredict</li>
    </ul>
    <ul>
      <li> manip </li>
    </ul> -->
      
    
    <h2>Author</h2>
    
  Johannes Ranke

    
  </div>
</div>
      
      <footer>
      <p class="pull-right"><a href="#">Back to top</a></p>
<p>Built by <a href="https://github.com/hadley/staticdocs">staticdocs</a>. Styled with <a href="http://twitter.github.com/bootstrap">bootstrap</a>.</p>
      </footer>
    </div>
  </body>
</html>

Contact - Imprint