aboutsummaryrefslogtreecommitdiff
path: root/inst/web/mkinpredict.html
blob: 900ee26f47a103d73ffc29937bddb2056c383c52 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
<!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.004   0.028   0.005 
</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.020   0.000   0.003 
</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.092   0.000   0.092 
</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