aboutsummaryrefslogblamecommitdiff
path: root/inst/web/add_err.html
blob: da3a85b736b94b9dc6971be52e13562ab24297b6 (plain) (tree)
1
2
3
4
5



                          
                                        






























                                                                                      
                                                    


































































































































































                                                                                                                                                               
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
<title>add_err. mkin 0.9.43.9000</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.43.9000</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