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
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
|
<!-- Generated by pkgdown: do not edit by hand -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>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.3.1/jquery.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<!-- Bootstrap -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha256-916EbMg70RQy9LHiGkXzG8hSg9EdNy97GazNG/aiY1w=" crossorigin="anonymous" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script>
<!-- Font Awesome icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha256-eZrrJcwDc/3uDhsdt61sL2oOBY362qM3lon1gyExkL0=" crossorigin="anonymous" />
<!-- clipboard.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" integrity="sha256-FiZwavyI2V6+EXO1U+xzLG3IKldpiTFf3153ea9zikQ=" crossorigin="anonymous"></script>
<!-- sticky kit -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/sticky-kit/1.1.3/sticky-kit.min.js" integrity="sha256-c4Rlo1ZozqTPE2RLuvbusY3+SU1pQaJC0TjuhygMipw=" 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 uses the Flexible Modelling Environment package
FME to create a function calculating the model cost, i.e. the
deviation between the kinetic model and the observed data. This model cost is
then minimised using the Port algorithm nlminb,
using the specified initial or fixed parameters and starting values.
Per default, parameters in the kinetic models are internally transformed in order
to better satisfy the assumption of a normal distribution of their estimators.
In each step of the optimsation, the kinetic model is solved using the
function mkinpredict. The variance of the residuals for each
observed variable can optionally be iteratively reweighted until convergence
using the argument reweight.method = "obs"." />
<meta name="twitter:card" content="summary" />
<!-- 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>
<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">0.9.47.6</span>
</span>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>
<a href="../reference/index.html">Functions and data</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
Articles
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="../articles/mkin.html">Introduction to mkin</a>
</li>
<li>
<a href="../articles/FOCUS_D.html">Example evaluation of FOCUS Example Dataset D</a>
</li>
<li>
<a href="../articles/FOCUS_L.html">Example evaluation of FOCUS Laboratory Data L1 to L3</a>
</li>
<li>
<a href="../articles/web_only/FOCUS_Z.html">Example evaluation of FOCUS Example Dataset Z</a>
</li>
<li>
<a href="../articles/web_only/compiled_models.html">Performance benefit by using compiled model definitions in mkin</a>
</li>
<li>
<a href="../articles/twa.html">Calculation of time weighted average concentrations with mkin</a>
</li>
</ul>
</li>
<li>
<a href="../news/index.html">News</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
</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>
<div class="hidden name"><code>mkinfit.Rd</code></div>
</div>
<div class="ref-description">
<p>This function uses the Flexible Modelling Environment package
<code>FME</code> to create a function calculating the model cost, i.e. the
deviation between the kinetic model and the observed data. This model cost is
then minimised using the Port algorithm <code><a href='https://www.rdocumentation.org/packages/stats/topics/nlminb'>nlminb</a></code>,
using the specified initial or fixed parameters and starting values.
Per default, parameters in the kinetic models are internally transformed in order
to better satisfy the assumption of a normal distribution of their estimators.
In each step of the optimsation, the kinetic model is solved using the
function <code><a href='mkinpredict.html'>mkinpredict</a></code>. The variance of the residuals for each
observed variable can optionally be iteratively reweighted until convergence
using the argument <code>reweight.method = "obs"</code>.</p>
</div>
<pre class="usage"><span class='fu'>mkinfit</span>(<span class='no'>mkinmod</span>, <span class='no'>observed</span>,
<span class='kw'>parms.ini</span> <span class='kw'>=</span> <span class='st'>"auto"</span>,
<span class='kw'>state.ini</span> <span class='kw'>=</span> <span class='st'>"auto"</span>,
<span class='kw'>fixed_parms</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>fixed_initials</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/names'>names</a></span>(<span class='no'>mkinmod</span>$<span class='no'>diffs</span>)[-<span class='fl'>1</span>],
<span class='kw'>from_max_mean</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>,
<span class='kw'>solution_type</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/c'>c</a></span>(<span class='st'>"auto"</span>, <span class='st'>"analytical"</span>, <span class='st'>"eigen"</span>, <span class='st'>"deSolve"</span>),
<span class='kw'>method.ode</span> <span class='kw'>=</span> <span class='st'>"lsoda"</span>,
<span class='kw'>use_compiled</span> <span class='kw'>=</span> <span class='st'>"auto"</span>,
<span class='kw'>method.modFit</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/c'>c</a></span>(<span class='st'>"Port"</span>, <span class='st'>"Marq"</span>, <span class='st'>"SANN"</span>, <span class='st'>"Nelder-Mead"</span>, <span class='st'>"BFGS"</span>, <span class='st'>"CG"</span>, <span class='st'>"L-BFGS-B"</span>),
<span class='kw'>maxit.modFit</span> <span class='kw'>=</span> <span class='st'>"auto"</span>,
<span class='kw'>control.modFit</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/list'>list</a></span>(),
<span class='kw'>transform_rates</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>,
<span class='kw'>transform_fractions</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>,
<span class='kw'>plot</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>, <span class='kw'>quiet</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>, <span class='kw'>err</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
<span class='kw'>weight</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/c'>c</a></span>(<span class='st'>"none"</span>, <span class='st'>"manual"</span>, <span class='st'>"std"</span>, <span class='st'>"mean"</span>, <span class='st'>"tc"</span>),
<span class='kw'>tc</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/c'>c</a></span>(<span class='kw'>sigma_low</span> <span class='kw'>=</span> <span class='fl'>0.5</span>, <span class='kw'>rsd_high</span> <span class='kw'>=</span> <span class='fl'>0.07</span>),
<span class='kw'>scaleVar</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>,
<span class='kw'>atol</span> <span class='kw'>=</span> <span class='fl'>1e-8</span>, <span class='kw'>rtol</span> <span class='kw'>=</span> <span class='fl'>1e-10</span>, <span class='kw'>n.outtimes</span> <span class='kw'>=</span> <span class='fl'>100</span>,
<span class='kw'>reweight.method</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
<span class='kw'>reweight.tol</span> <span class='kw'>=</span> <span class='fl'>1e-8</span>, <span class='kw'>reweight.max.iter</span> <span class='kw'>=</span> <span class='fl'>10</span>,
<span class='kw'>trace_parms</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>, <span class='no'>...</span>)</pre>
<h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
<table class="ref-arguments">
<colgroup><col class="name" /><col class="desc" /></colgroup>
<tr>
<th>mkinmod</th>
<td><p>A list of class <code><a href='mkinmod.html'>mkinmod</a></code>, containing the kinetic model to be
fitted to the data, or one of the shorthand names ("SFO", "FOMC", "DFOP",
"HS", "SFORB"). 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></td>
</tr>
<tr>
<th>observed</th>
<td><p>The observed data. It has to be in the long format as described in
<code>modFit</code>, i.e. 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. Optionally, a further column
can contain weights for each data point. Its name must be passed as a
further argument named <code>err</code> which is then passed on to
<code>modFit</code>.</p></td>
</tr>
<tr>
<th>parms.ini</th>
<td><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></td>
</tr>
<tr>
<th>state.ini</th>
<td><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 <code><a href='mkinmod.html'>mkinmod</a></code>). 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></td>
</tr>
<tr>
<th>fixed_parms</th>
<td><p>The names of parameters that should not be optimised but rather kept at the
values specified in <code>parms.ini</code>.</p></td>
</tr>
<tr>
<th>fixed_initials</th>
<td><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></td>
</tr>
<tr>
<th>from_max_mean</th>
<td><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></td>
</tr>
<tr>
<th>solution_type</th>
<td><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 ode solver from package
<code>deSolve</code> is used. If set to "analytical", an analytical
solution of the model is used. This is only implemented for simple
degradation experiments with only one state variable, i.e. with no
metabolites. The default is "auto", which uses "analytical" if possible,
otherwise "eigen" if the model can be expressed using eigenvalues and
eigenvectors, and finally "deSolve" for the remaining models (time
dependence of degradation rates and metabolites). This argument is passed
on to the helper function <code><a href='mkinpredict.html'>mkinpredict</a></code>.</p></td>
</tr>
<tr>
<th>method.ode</th>
<td><p>The solution method passed via <code><a href='mkinpredict.html'>mkinpredict</a></code> to
<code>ode</code> in case the solution type is "deSolve". The default
"lsoda" is performant, but sometimes fails to converge.</p></td>
</tr>
<tr>
<th>use_compiled</th>
<td><p>If set to <code>FALSE</code>, no compiled version of the <code><a href='mkinmod.html'>mkinmod</a></code>
model is used, in the calls to <code><a href='mkinpredict.html'>mkinpredict</a></code> even if
a compiled verion is present.</p></td>
</tr>
<tr>
<th>method.modFit</th>
<td><p>The optimisation method passed to <code>modFit</code>.</p>
<p>In order to optimally deal with problems where local minima occur, the
"Port" algorithm is now used per default as it is less prone to get trapped
in local minima and depends less on starting values for parameters than
the Levenberg Marquardt variant selected by "Marq". However, "Port" needs
more iterations.</p>
<p>The former default "Marq" is the Levenberg Marquardt algorithm
<code>nls.lm</code> from the package <code>minpack.lm</code> and usually needs
the least number of iterations.</p>
<p>The "Pseudo" algorithm is not included because it needs finite parameter bounds
which are currently not supported.</p>
<p>The "Newton" algorithm is not included because its number of iterations
can not be controlled by <code>control.modFit</code> and it does not appear
to provide advantages over the other algorithms.</p></td>
</tr>
<tr>
<th>maxit.modFit</th>
<td><p>Maximum number of iterations in the optimisation. If not "auto", this will
be passed to the method called by <code>modFit</code>, overriding
what may be specified in the next argument <code>control.modFit</code>.</p></td>
</tr>
<tr>
<th>control.modFit</th>
<td><p>Additional arguments passed to the optimisation method used by
<code>modFit</code>.</p></td>
</tr>
<tr>
<th>transform_rates</th>
<td><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></td>
</tr>
<tr>
<th>transform_fractions</th>
<td><p>Boolean specifying if formation fractions constants 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 and HS
models are also transformed, as they can also be seen as compositional
data. The transformation used for these transformations is the
<code><a href='ilr.html'>ilr</a></code> transformation.</p></td>
</tr>
<tr>
<th>plot</th>
<td><p>Should the observed values and the numerical solutions be plotted at each
stage of the optimisation?</p></td>
</tr>
<tr>
<th>quiet</th>
<td><p>Suppress printing out the current model cost after each improvement?</p></td>
</tr>
<tr>
<th>err </th>
<td><p>either <code>NULL</code>, or the name of the column with the
<em>error</em> estimates, used to weigh the residuals (see details of
<code>modCost</code>); if <code>NULL</code>, then the residuals are not weighed.</p></td>
</tr>
<tr>
<th>weight</th>
<td><p>only if <code>err</code>=<code>NULL</code>: how to weight the residuals, one of "none",
"std", "mean", see details of <code>modCost</code>, or "tc" for the
two component error model. The option "manual" is available for
the case that <code>err</code>!=<code>NULL</code>, but it is not necessary to specify it.</p></td>
</tr>
<tr>
<th>tc</th>
<td><p>The two components of the error model as used for (initial)
weighting</p></td>
</tr>
<tr>
<th>scaleVar</th>
<td><p>Will be passed to <code>modCost</code>. Default is not to scale Variables
according to the number of observations.</p></td>
</tr>
<tr>
<th>atol</th>
<td><p>Absolute error tolerance, passed to <code>ode</code>. Default is 1e-8,
lower than in <code>lsoda</code>.</p></td>
</tr>
<tr>
<th>rtol</th>
<td><p>Absolute error tolerance, passed to <code>ode</code>. Default is 1e-10,
much lower than in <code>lsoda</code>.</p></td>
</tr>
<tr>
<th>n.outtimes</th>
<td><p>The length of the dataseries that is produced by the model prediction
function <code><a href='mkinpredict.html'>mkinpredict</a></code>. This impacts the accuracy of
the numerical solver if that is used (see <code>solution_type</code> argument.
The default value is 100.</p></td>
</tr>
<tr>
<th>reweight.method</th>
<td><p>The method used for iteratively reweighting residuals, also known
as iteratively reweighted least squares (IRLS). Default is NULL,
i.e. no iterative weighting.
The first reweighting method is called "obs", meaning that each
observed variable is assumed to have its own variance. This variance
is estimated from the fit (mean squared residuals) and used for weighting
the residuals in each iteration until convergence of this estimate up to
<code>reweight.tol</code> or up to the maximum number of iterations
specified by <code>reweight.max.iter</code>.
The second reweighting method is called "tc" (two-component error model).
When using this method, the two components of an error model similar to
the one described by
Rocke and Lorenzato (1995) are estimated from the fit and the resulting
variances are used for weighting the residuals in each iteration until
convergence of these components or up to the maximum number of iterations
specified. Note that this method 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></td>
</tr>
<tr>
<th>reweight.tol</th>
<td><p>Tolerance for convergence criterion for the variance components
in IRLS fits.</p></td>
</tr>
<tr>
<th>reweight.max.iter</th>
<td><p>Maximum iterations in IRLS fits.</p></td>
</tr>
<tr>
<th>trace_parms</th>
<td><p>Should a trace of the parameter values be listed?</p></td>
</tr>
<tr>
<th>…</th>
<td><p>Further arguments that will be passed to <code>modFit</code>.</p></td>
</tr>
</table>
<h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2>
<p>A list with "mkinfit" and "modFit" in the class attribute.
A summary can be obtained by <code><a href='summary.mkinfit.html'>summary.mkinfit</a></code>.</p>
<h2 class="hasAnchor" id="see-also"><a class="anchor" href="#see-also"></a>See also</h2>
<div class='dont-index'><p>Plotting methods <code><a href='plot.mkinfit.html'>plot.mkinfit</a></code> and
<code><a href='mkinparplot.html'>mkinparplot</a></code>.</p>
<p>Comparisons of models fitted to the same data can be made using <code><a href='https://www.rdocumentation.org/packages/stats/topics/AIC'>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>
<h2 class="hasAnchor" id="note"><a class="anchor" href="#note"></a>Note</h2>
<p>The implementation of iteratively reweighted least squares is inspired by the
work of the KinGUII team at Bayer Crop Science (Walter Schmitt and Zhenglei
Gao). A similar implemention can also be found in CAKE 2.0, which is the
other GUI derivative of mkin, sponsored by Syngenta.</p>
<h2 class="hasAnchor" id="note"><a class="anchor" href="#note"></a>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>
<h2 class="hasAnchor" id="source"><a class="anchor" href="#source"></a>Source</h2>
<p>Rocke, David M. und Lorenzato, Stefan (1995) A two-component model for
measurement error in analytical chemistry. Technometrics 37(2), 176-184.</p>
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
<pre class="examples"><div class='input'><span class='co'># Use shorthand notation for parent only degradation</span>
<span class='no'>fit</span> <span class='kw'><-</span> <span class='fu'>mkinfit</span>(<span class='st'>"FOMC"</span>, <span class='no'>FOCUS_2006_C</span>, <span class='kw'>quiet</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>)</div><div class='output co'>#> <span class='error'>Error in mkinfit("FOMC", FOCUS_2006_C, quiet = TRUE): konnte Funktion "mkinfit" nicht finden</span></div><div class='input'><span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/summary'>summary</a></span>(<span class='no'>fit</span>)</div><div class='output co'>#> <span class='error'>Error in summary(fit): Objekt 'fit' nicht gefunden</span></div><div class='input'>
<span class='co'># One parent compound, one metabolite, both single first order.</span>
<span class='co'># Use mkinsub for convenience in model formulation. Pathway to sink included per default.</span>
<span class='no'>SFO_SFO</span> <span class='kw'><-</span> <span class='fu'><a href='mkinmod.html'>mkinmod</a></span>(
<span class='kw'>parent</span> <span class='kw'>=</span> <span class='fu'><a href='mkinsub.html'>mkinsub</a></span>(<span class='st'>"SFO"</span>, <span class='st'>"m1"</span>),
<span class='kw'>m1</span> <span class='kw'>=</span> <span class='fu'><a href='mkinsub.html'>mkinsub</a></span>(<span class='st'>"SFO"</span>))</div><div class='output co'>#> <span class='error'>Error in mkinmod(parent = mkinsub("SFO", "m1"), m1 = mkinsub("SFO")): konnte Funktion "mkinmod" nicht finden</span></div><div class='input'><span class='co'># Fit the model to the FOCUS example dataset D using defaults</span>
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/print'>print</a></span>(<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/system.time'>system.time</a></span>(<span class='no'>fit</span> <span class='kw'><-</span> <span class='fu'>mkinfit</span>(<span class='no'>SFO_SFO</span>, <span class='no'>FOCUS_2006_D</span>,
<span class='kw'>solution_type</span> <span class='kw'>=</span> <span class='st'>"eigen"</span>, <span class='kw'>quiet</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>)))</div><div class='output co'>#> <span class='error'>Error in mkinfit(SFO_SFO, FOCUS_2006_D, solution_type = "eigen", quiet = TRUE): konnte Funktion "mkinfit" nicht finden</span></div><div class='output co'>#> <span class='message'>Timing stopped at: 0 0 0</span></div><div class='input'><span class='fu'><a href='https://www.rdocumentation.org/packages/stats/topics/coef'>coef</a></span>(<span class='no'>fit</span>)</div><div class='output co'>#> <span class='error'>Error in coef(fit): Objekt 'fit' nicht gefunden</span></div><div class='input'><span class='fu'><a href='endpoints.html'>endpoints</a></span>(<span class='no'>fit</span>)</div><div class='output co'>#> <span class='error'>Error in endpoints(fit): konnte Funktion "endpoints" nicht finden</span></div><div class='input'><span class='co'># deSolve is slower when no C compiler (gcc) was available during model generation</span>
<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/print'>print</a></span>(<span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/system.time'>system.time</a></span>(<span class='no'>fit.deSolve</span> <span class='kw'><-</span> <span class='fu'>mkinfit</span>(<span class='no'>SFO_SFO</span>, <span class='no'>FOCUS_2006_D</span>,
<span class='kw'>solution_type</span> <span class='kw'>=</span> <span class='st'>"deSolve"</span>)))</div><div class='output co'>#> <span class='error'>Error in mkinfit(SFO_SFO, FOCUS_2006_D, solution_type = "deSolve"): konnte Funktion "mkinfit" nicht finden</span></div><div class='output co'>#> <span class='message'>Timing stopped at: 0 0 0</span></div><div class='input'><span class='fu'><a href='https://www.rdocumentation.org/packages/stats/topics/coef'>coef</a></span>(<span class='no'>fit.deSolve</span>)</div><div class='output co'>#> <span class='error'>Error in coef(fit.deSolve): Objekt 'fit.deSolve' nicht gefunden</span></div><div class='input'><span class='fu'><a href='endpoints.html'>endpoints</a></span>(<span class='no'>fit.deSolve</span>)</div><div class='output co'>#> <span class='error'>Error in endpoints(fit.deSolve): konnte Funktion "endpoints" nicht finden</span></div><div class='input'>
# Use stepwise fitting, using optimised parameters from parent only fit, FOMC
</div><div class='input'><span class='no'>FOMC_SFO</span> <span class='kw'><-</span> <span class='fu'><a href='mkinmod.html'>mkinmod</a></span>(
<span class='kw'>parent</span> <span class='kw'>=</span> <span class='fu'><a href='mkinsub.html'>mkinsub</a></span>(<span class='st'>"FOMC"</span>, <span class='st'>"m1"</span>),
<span class='kw'>m1</span> <span class='kw'>=</span> <span class='fu'><a href='mkinsub.html'>mkinsub</a></span>(<span class='st'>"SFO"</span>))</div><div class='output co'>#> <span class='error'>Error in mkinmod(parent = mkinsub("FOMC", "m1"), m1 = mkinsub("SFO")): konnte Funktion "mkinmod" nicht finden</span></div><div class='input'><span class='co'># Fit the model to the FOCUS example dataset D using defaults</span>
<span class='no'>fit.FOMC_SFO</span> <span class='kw'><-</span> <span class='fu'>mkinfit</span>(<span class='no'>FOMC_SFO</span>, <span class='no'>FOCUS_2006_D</span>, <span class='kw'>quiet</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>)</div><div class='output co'>#> <span class='error'>Error in mkinfit(FOMC_SFO, FOCUS_2006_D, quiet = TRUE): konnte Funktion "mkinfit" nicht finden</span></div><div class='input'><span class='co'># Use starting parameters from parent only FOMC fit</span>
<span class='no'>fit.FOMC</span> <span class='kw'>=</span> <span class='fu'>mkinfit</span>(<span class='st'>"FOMC"</span>, <span class='no'>FOCUS_2006_D</span>, <span class='kw'>quiet</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>)</div><div class='output co'>#> <span class='error'>Error in mkinfit("FOMC", FOCUS_2006_D, quiet = TRUE): konnte Funktion "mkinfit" nicht finden</span></div><div class='input'><span class='no'>fit.FOMC_SFO</span> <span class='kw'><-</span> <span class='fu'>mkinfit</span>(<span class='no'>FOMC_SFO</span>, <span class='no'>FOCUS_2006_D</span>, <span class='kw'>quiet</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>,
<span class='kw'>parms.ini</span> <span class='kw'>=</span> <span class='no'>fit.FOMC</span>$<span class='no'>bparms.ode</span>)</div><div class='output co'>#> <span class='error'>Error in mkinfit(FOMC_SFO, FOCUS_2006_D, quiet = TRUE, parms.ini = fit.FOMC$bparms.ode): konnte Funktion "mkinfit" nicht finden</span></div><div class='input'>
<span class='co'># Use stepwise fitting, using optimised parameters from parent only fit, SFORB</span>
<span class='no'>SFORB_SFO</span> <span class='kw'><-</span> <span class='fu'><a href='mkinmod.html'>mkinmod</a></span>(
<span class='kw'>parent</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/list'>list</a></span>(<span class='kw'>type</span> <span class='kw'>=</span> <span class='st'>"SFORB"</span>, <span class='kw'>to</span> <span class='kw'>=</span> <span class='st'>"m1"</span>, <span class='kw'>sink</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>),
<span class='kw'>m1</span> <span class='kw'>=</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/list'>list</a></span>(<span class='kw'>type</span> <span class='kw'>=</span> <span class='st'>"SFO"</span>))</div><div class='output co'>#> <span class='error'>Error in mkinmod(parent = list(type = "SFORB", to = "m1", sink = TRUE), m1 = list(type = "SFO")): konnte Funktion "mkinmod" nicht finden</span></div><div class='input'><span class='co'># Fit the model to the FOCUS example dataset D using defaults</span>
<span class='no'>fit.SFORB_SFO</span> <span class='kw'><-</span> <span class='fu'>mkinfit</span>(<span class='no'>SFORB_SFO</span>, <span class='no'>FOCUS_2006_D</span>, <span class='kw'>quiet</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>)</div><div class='output co'>#> <span class='error'>Error in mkinfit(SFORB_SFO, FOCUS_2006_D, quiet = TRUE): konnte Funktion "mkinfit" nicht finden</span></div><div class='input'><span class='no'>fit.SFORB_SFO.deSolve</span> <span class='kw'><-</span> <span class='fu'>mkinfit</span>(<span class='no'>SFORB_SFO</span>, <span class='no'>FOCUS_2006_D</span>, <span class='kw'>solution_type</span> <span class='kw'>=</span> <span class='st'>"deSolve"</span>,
<span class='kw'>quiet</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>)</div><div class='output co'>#> <span class='error'>Error in mkinfit(SFORB_SFO, FOCUS_2006_D, solution_type = "deSolve", quiet = TRUE): konnte Funktion "mkinfit" nicht finden</span></div><div class='input'><span class='co'># Use starting parameters from parent only SFORB fit (not really needed in this case)</span>
<span class='no'>fit.SFORB</span> <span class='kw'>=</span> <span class='fu'>mkinfit</span>(<span class='st'>"SFORB"</span>, <span class='no'>FOCUS_2006_D</span>, <span class='kw'>quiet</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>)</div><div class='output co'>#> <span class='error'>Error in mkinfit("SFORB", FOCUS_2006_D, quiet = TRUE): konnte Funktion "mkinfit" nicht finden</span></div><div class='input'><span class='no'>fit.SFORB_SFO</span> <span class='kw'><-</span> <span class='fu'>mkinfit</span>(<span class='no'>SFORB_SFO</span>, <span class='no'>FOCUS_2006_D</span>, <span class='kw'>parms.ini</span> <span class='kw'>=</span> <span class='no'>fit.SFORB</span>$<span class='no'>bparms.ode</span>, <span class='kw'>quiet</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>)</div><div class='output co'>#> <span class='error'>Error in mkinfit(SFORB_SFO, FOCUS_2006_D, parms.ini = fit.SFORB$bparms.ode, quiet = TRUE): konnte Funktion "mkinfit" nicht finden</span></div><div class='input'>
</div><div class='input'><span class='co'># Weighted fits, including IRLS</span>
<span class='no'>SFO_SFO.ff</span> <span class='kw'><-</span> <span class='fu'><a href='mkinmod.html'>mkinmod</a></span>(<span class='kw'>parent</span> <span class='kw'>=</span> <span class='fu'><a href='mkinsub.html'>mkinsub</a></span>(<span class='st'>"SFO"</span>, <span class='st'>"m1"</span>),
<span class='kw'>m1</span> <span class='kw'>=</span> <span class='fu'><a href='mkinsub.html'>mkinsub</a></span>(<span class='st'>"SFO"</span>), <span class='kw'>use_of_ff</span> <span class='kw'>=</span> <span class='st'>"max"</span>)</div><div class='output co'>#> <span class='error'>Error in mkinmod(parent = mkinsub("SFO", "m1"), m1 = mkinsub("SFO"), use_of_ff = "max"): konnte Funktion "mkinmod" nicht finden</span></div><div class='input'><span class='no'>f.noweight</span> <span class='kw'><-</span> <span class='fu'>mkinfit</span>(<span class='no'>SFO_SFO.ff</span>, <span class='no'>FOCUS_2006_D</span>, <span class='kw'>quiet</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>)</div><div class='output co'>#> <span class='error'>Error in mkinfit(SFO_SFO.ff, FOCUS_2006_D, quiet = TRUE): konnte Funktion "mkinfit" nicht finden</span></div><div class='input'><span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/summary'>summary</a></span>(<span class='no'>f.noweight</span>)</div><div class='output co'>#> <span class='error'>Error in summary(f.noweight): Objekt 'f.noweight' nicht gefunden</span></div><div class='input'><span class='no'>f.irls</span> <span class='kw'><-</span> <span class='fu'>mkinfit</span>(<span class='no'>SFO_SFO.ff</span>, <span class='no'>FOCUS_2006_D</span>, <span class='kw'>reweight.method</span> <span class='kw'>=</span> <span class='st'>"obs"</span>, <span class='kw'>quiet</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>)</div><div class='output co'>#> <span class='error'>Error in mkinfit(SFO_SFO.ff, FOCUS_2006_D, reweight.method = "obs", quiet = TRUE): konnte Funktion "mkinfit" nicht finden</span></div><div class='input'><span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/summary'>summary</a></span>(<span class='no'>f.irls</span>)</div><div class='output co'>#> <span class='error'>Error in summary(f.irls): Objekt 'f.irls' nicht gefunden</span></div><div class='input'><span class='no'>f.w.mean</span> <span class='kw'><-</span> <span class='fu'>mkinfit</span>(<span class='no'>SFO_SFO.ff</span>, <span class='no'>FOCUS_2006_D</span>, <span class='kw'>weight</span> <span class='kw'>=</span> <span class='st'>"mean"</span>, <span class='kw'>quiet</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>)</div><div class='output co'>#> <span class='error'>Error in mkinfit(SFO_SFO.ff, FOCUS_2006_D, weight = "mean", quiet = TRUE): konnte Funktion "mkinfit" nicht finden</span></div><div class='input'><span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/summary'>summary</a></span>(<span class='no'>f.w.mean</span>)</div><div class='output co'>#> <span class='error'>Error in summary(f.w.mean): Objekt 'f.w.mean' nicht gefunden</span></div><div class='input'><span class='no'>f.w.value</span> <span class='kw'><-</span> <span class='fu'>mkinfit</span>(<span class='no'>SFO_SFO.ff</span>, <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/subset'>subset</a></span>(<span class='no'>FOCUS_2006_D</span>, <span class='no'>value</span> <span class='kw'>!=</span> <span class='fl'>0</span>), <span class='kw'>err</span> <span class='kw'>=</span> <span class='st'>"value"</span>,
<span class='kw'>quiet</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>)</div><div class='output co'>#> <span class='error'>Error in mkinfit(SFO_SFO.ff, subset(FOCUS_2006_D, value != 0), err = "value", quiet = TRUE): konnte Funktion "mkinfit" nicht finden</span></div><div class='input'><span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/summary'>summary</a></span>(<span class='no'>f.w.value</span>)</div><div class='output co'>#> <span class='error'>Error in summary(f.w.value): Objekt 'f.w.value' nicht gefunden</span></div><div class='input'>
</div><div class='input'><span class='co'># Manual weighting</span>
<span class='no'>dw</span> <span class='kw'><-</span> <span class='no'>FOCUS_2006_D</span>
<span class='no'>errors</span> <span class='kw'><-</span> <span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/c'>c</a></span>(<span class='kw'>parent</span> <span class='kw'>=</span> <span class='fl'>2</span>, <span class='kw'>m1</span> <span class='kw'>=</span> <span class='fl'>1</span>)
<span class='no'>dw</span>$<span class='no'>err.man</span> <span class='kw'><-</span> <span class='no'>errors</span>[<span class='no'>FOCUS_2006_D</span>$<span class='no'>name</span>]
<span class='no'>f.w.man</span> <span class='kw'><-</span> <span class='fu'>mkinfit</span>(<span class='no'>SFO_SFO.ff</span>, <span class='no'>dw</span>, <span class='kw'>err</span> <span class='kw'>=</span> <span class='st'>"err.man"</span>, <span class='kw'>quiet</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>)</div><div class='output co'>#> <span class='error'>Error in mkinfit(SFO_SFO.ff, dw, err = "err.man", quiet = TRUE): konnte Funktion "mkinfit" nicht finden</span></div><div class='input'><span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/summary'>summary</a></span>(<span class='no'>f.w.man</span>)</div><div class='output co'>#> <span class='error'>Error in summary(f.w.man): Objekt 'f.w.man' nicht gefunden</span></div><div class='input'><span class='no'>f.w.man.irls</span> <span class='kw'><-</span> <span class='fu'>mkinfit</span>(<span class='no'>SFO_SFO.ff</span>, <span class='no'>dw</span>, <span class='kw'>err</span> <span class='kw'>=</span> <span class='st'>"err.man"</span>, <span class='kw'>quiet</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>,
<span class='kw'>reweight.method</span> <span class='kw'>=</span> <span class='st'>"obs"</span>)</div><div class='output co'>#> <span class='error'>Error in mkinfit(SFO_SFO.ff, dw, err = "err.man", quiet = TRUE, reweight.method = "obs"): konnte Funktion "mkinfit" nicht finden</span></div><div class='input'><span class='fu'><a href='https://www.rdocumentation.org/packages/base/topics/summary'>summary</a></span>(<span class='no'>f.w.man.irls</span>)</div><div class='output co'>#> <span class='error'>Error in summary(f.w.man.irls): Objekt 'f.w.man.irls' nicht gefunden</span></div></pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<h2>Contents</h2>
<ul class="nav nav-pills nav-stacked">
<li><a href="#arguments">Arguments</a></li>
<li><a href="#value">Value</a></li>
<li><a href="#see-also">See also</a></li>
<li><a href="#note">Note</a></li>
<li><a href="#note">Note</a></li>
<li><a href="#source">Source</a></li>
<li><a href="#examples">Examples</a></li>
</ul>
<h2>Author</h2>
<p>Johannes Ranke</p>
</div>
</div>
<footer>
<div class="copyright">
<p>Developed by Johannes Ranke.</p>
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
</div>
</footer>
</div>
</body>
</html>
|