aboutsummaryrefslogtreecommitdiff
path: root/inst/web/add_err.html
blob: 1ab38bb8ff6ec9dca1638b0a377e17bcca4a4c8d (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
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
<title>add_err. mkin 0.9.44</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.44</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>
  Add normally distributed errors to simulated kinetic degradation data
</h1>

<div class="row">
  <div class="span8">
    <h2>Usage</h2>
    <pre><div>add_err(prediction, sdfunc, n&nbsp;=&nbsp;1000, LOD&nbsp;=&nbsp;0.1, reps&nbsp;=&nbsp;2,  digits&nbsp;=&nbsp;1, seed&nbsp;=&nbsp;NA)</div></pre>
    
    <h2>Arguments</h2>
    <dl>
      <dt>prediction</dt>
      <dd>
    A prediction from a kinetic model as produced by <code><a href='mkinpredict.html'>mkinpredict</a></code>.
  </dd>
      <dt>sdfunc</dt>
      <dd>
    A function taking the predicted value as its only argument and returning
    a standard deviation that should be used for generating the random error
    terms for this value.
  </dd>
      <dt>n</dt>
      <dd>
    The number of datasets to be generated.
  </dd>
      <dt>LOD</dt>
      <dd>
    The limit of detection (LOD). Values that are below the LOD after adding
    the random error will be set to NA.
  </dd>
      <dt>reps</dt>
      <dd>
    The number of replicates to be generated within the datasets.
  </dd>
      <dt>digits</dt>
      <dd>
    The number of digits to which the values will be rounded.
  </dd>
      <dt>seed</dt>
      <dd>
    The seed used for the generation of random numbers. If NA, the seed 
    is not set.
  </dd>
    </dl>
    
    <div class="Description">
      <h2>Description</h2>

      <p>Normally distributed errors are added to data predicted for a specific
  degradation model using <code><a href='mkinpredict.html'>mkinpredict</a></code>. The variance of the error
  may depend on the predicted value and is specified as a standard deviation.</p>
  
    </div>

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

      <p><dl>
  A list of datasets compatible with <code><a href='mmkin.html'>mmkin</a></code>, i.e.
  the components of the list are datasets compatible with 
  <code><a href='mkinfit.html'>mkinfit</a></code>.
</dl></p>
  
    </div>

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

      <p>Ranke J and Lehmann R (2015) To t-test or not to t-test, that is the question. XV Symposium on Pesticide Chemistry 2-4 September 2015, Piacenza, Italy
  http://chem.uft.uni-bremen.de/ranke/posters/piacenza_2015.pdf</p>
  
    </div>
    
    <h2 id="examples">Examples</h2>
    <pre class="examples"><div class='input'># The kinetic model
m_SFO_SFO &lt;- mkinmod(parent = mkinsub(&quot;SFO&quot;, &quot;M1&quot;),
                     M1 = mkinsub(&quot;SFO&quot;), use_of_ff = &quot;max&quot;)
</div>
<strong class='message'>Successfully compiled differential equation model from auto-generated C code.</strong>
<div class='input'>
# Generate a prediction for a specific set of parameters
sampling_times = c(0, 1, 3, 7, 14, 28, 60, 90, 120)

# This is the prediction used for the &quot;Type 2 datasets&quot; on the Piacenza poster
# from 2015
d_SFO_SFO &lt;- mkinpredict(m_SFO_SFO,
                         c(k_parent = 0.1, f_parent_to_M1 = 0.5,
                           k_M1 = log(2)/1000),
                         c(parent = 100, M1 = 0),
                         sampling_times)

# Add an error term with a constant (independent of the value) standard deviation
# of 10, and generate three datasets
d_SFO_SFO_err &lt;- add_err(d_SFO_SFO, function(x) 10, n = 3, seed = 123456789 )

# Name the datasets for nicer plotting
names(d_SFO_SFO_err) &lt;- paste(&quot;Dataset&quot;, 1:3)

# Name the model in the list of models (with only one member in this case)
# for nicer plotting later on.
# Be quiet and use the faster Levenberg-Marquardt algorithm, as the datasets
# are easy and examples are run often. Use only one core not to offend CRAN
# checks
f_SFO_SFO &lt;- mmkin(list(&quot;SFO-SFO&quot; = m_SFO_SFO), 
                   d_SFO_SFO_err, cores = 1,
                   quiet = TRUE, method.modFit = &quot;Marq&quot;)

plot(f_SFO_SFO)
</div>
<p><img src='add_err-4.png' alt='' width='540' height='400' /></p>
<div class='input'>
# We would like to inspect the fit for dataset 3 more closely
# Using double brackets makes the returned object an mkinfit object
# instead of a list of mkinfit objects, so plot.mkinfit is used
plot(f_SFO_SFO[[3]], show_residuals = TRUE)
</div>
<p><img src='add_err-6.png' alt='' width='540' height='400' /></p>
<div class='input'>
# If we use single brackets, we should give two indices (model and dataset),
# and plot.mmkin is used
plot(f_SFO_SFO[1, 3])
</div>
<p><img src='add_err-8.png' alt='' width='540' height='400' /></p>
<div class='input'></div></pre>
  </div>
  <div class="span4">
    <!-- <ul>
      <li>add_err</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