aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2017-11-16 14:55:06 +0100
committerJohannes Ranke <jranke@uni-bremen.de>2017-11-16 14:55:06 +0100
commit76a0aae725f4d603b3c8e8442bb67081891986b4 (patch)
tree1d4f29bd618c00997a9c1247691d9ad45528724e
parent545d4bdfe1fc532f6d5d1718ee08444430d2976f (diff)
Add the code used for generating synthetic_data_for_UBA
Static documentation except articles rebuilt by pkgdown
-rw-r--r--DESCRIPTION4
-rw-r--r--NEWS.md4
-rw-r--r--R/add_err.R6
-rw-r--r--build.log7
-rw-r--r--docs/authors.html7
-rw-r--r--docs/index.html13
-rw-r--r--docs/news/index.html22
-rw-r--r--docs/reference/add_err.html13
-rw-r--r--docs/reference/index.html9
-rw-r--r--docs/reference/synthetic_data_for_UBA.html290
-rw-r--r--man/add_err.Rd5
-rw-r--r--man/synthetic_data_for_UBA.Rd82
12 files changed, 227 insertions, 235 deletions
diff --git a/DESCRIPTION b/DESCRIPTION
index a86eeadd..d6de2e12 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,8 +1,8 @@
Package: mkin
Type: Package
Title: Kinetic Evaluation of Chemical Degradation Data
-Version: 0.9.46.2
-Date: 2017-10-10
+Version: 0.9.46.3
+Date: 2017-11-16
Authors@R: c(person("Johannes", "Ranke", role = c("aut", "cre", "cph"),
email = "jranke@uni-bremen.de",
comment = c(ORCID = "0000-0003-4371-6538")),
diff --git a/NEWS.md b/NEWS.md
index 32c8356b..dab95926 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,3 +1,7 @@
+# mkin 0.9.46.3 (2017-11-16)
+
+- `synthetic_data_for_UBA`: Add the code used to generate the data in the interest of reproducibility
+
# mkin 0.9.46.2 (2017-10-10)
- Converted the vignette FOCUS_Z from tex/pdf to markdown/html
diff --git a/R/add_err.R b/R/add_err.R
index 4d998e94..3b98338d 100644
--- a/R/add_err.R
+++ b/R/add_err.R
@@ -1,4 +1,4 @@
-# Copyright (C) 2015-2016 Johannes Ranke
+# Copyright (C) 2015-2017 Johannes Ranke
# Contact: jranke@uni-bremen.de
# This file is part of the R package mkin
@@ -16,7 +16,7 @@
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>
-add_err = function(prediction, sdfunc,
+add_err = function(prediction, sdfunc, secondary = c("M1", "M2"),
n = 1000, LOD = 0.1, reps = 2,
digits = 1, seed = NA)
{
@@ -33,7 +33,7 @@ add_err = function(prediction, sdfunc,
d_rep = data.frame(lapply(d_long, rep, each = 2))
d_rep$value = rnorm(length(d_rep$value), d_rep$value, sdfunc(d_rep$value))
- d_rep[d_rep$time == 0 & d_rep$name %in% c("M1", "M2"), "value"] <- 0
+ d_rep[d_rep$time == 0 & d_rep$name %in% secondary, "value"] <- 0
# Set values below the LOD to NA
d_NA <- transform(d_rep, value = ifelse(value < LOD, NA, value))
diff --git a/build.log b/build.log
index 674097ea..a02e93ae 100644
--- a/build.log
+++ b/build.log
@@ -2,9 +2,4 @@
* preparing ‘mkin’:
* checking DESCRIPTION meta-information ... OK
* installing the package to build vignettes
-* creating vignettes ... OK
-* checking for LF line-endings in source and make files and shell scripts
-* checking for empty or unneeded directories
-* looking to see if a ‘data/datalist’ file should be added
-* building ‘mkin_0.9.46.2.tar.gz’
-
+* creating vignettes ... \ No newline at end of file
diff --git a/docs/authors.html b/docs/authors.html
index 5829abb8..7f3918c8 100644
--- a/docs/authors.html
+++ b/docs/authors.html
@@ -86,12 +86,7 @@
</ul>
<ul class="nav navbar-nav navbar-right">
- <li>
- <a href="http://github.com/jranke/mkin">
- <span class="fa fa-github fa-lg"></span>
-
- </a>
-</li>
+
</ul>
</div><!--/.nav-collapse -->
</div><!--/.container -->
diff --git a/docs/index.html b/docs/index.html
index 1b4d89a6..f228bbe2 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -62,14 +62,7 @@
<a href="news/index.html">News</a>
</li>
</ul>
-<ul class="nav navbar-nav navbar-right">
-<li>
- <a href="http://github.com/jranke/mkin">
- <span class="fa fa-github fa-lg"></span>
-
- </a>
-</li>
- </ul>
+<ul class="nav navbar-nav navbar-right"></ul>
</div>
<!--/.nav-collapse -->
</div>
@@ -113,7 +106,7 @@
<li>Highly flexible model specification using <a href="http://kinfit.r-forge.r-project.org/mkin_static/reference/mkinmod.html"><code>mkinmod</code></a>, including equilibrium reactions and using the single first-order reversible binding (SFORB) model, which will automatically create two latent state variables for the observed variable.</li>
<li>As of version 0.9-39, fitting of several models to several datasets, optionally in parallel, is supported, see for example <a href="http://kinfit.r-forge.r-project.org/mkin_static/reference/plot.mmkin.html"><code>plot.mmkin</code></a>.</li>
<li>Model solution (forward modelling) in the function <a href="http://kinfit.r-forge.r-project.org/mkin_static/reference/mkinpredict.html"><code>mkinpredict</code></a> is performed either using the analytical solution for the case of parent only degradation, an eigenvalue based solution if only simple first-order (SFO) or SFORB kinetics are used in the model, or using a numeric solver from the <code>deSolve</code> package (default is <code>lsoda</code>).</li>
-<li>If a C compiler is installed, the kinetic models are compiled from automatically generated C code, see<br><a href="http://kinfit.r-forge.r-project.org/mkin_static/articles/compiled_models.html">vignette <code>compiled_models</code></a>. The autogeneration of C code was inspired by the <a href="https://github.com/karlines/ccSolve"><code>ccSolve</code></a> package. Thanks to Karline Soetaert for her work on that.</li>
+<li>If a C compiler is installed, the kinetic models are compiled from automatically generated C code, see <a href="http://kinfit.r-forge.r-project.org/mkin_static/articles/compiled_models.html">vignette <code>compiled_models</code></a>. The autogeneration of C code was inspired by the <a href="https://github.com/karlines/ccSolve"><code>ccSolve</code></a> package. Thanks to Karline Soetaert for her work on that.</li>
<li>By default, kinetic rate constants and kinetic formation fractions are transformed internally using <a href="http://kinfit.r-forge.r-project.org/mkin_static/reference/transform_odeparms.html"><code>transform_odeparms</code></a> so their estimators can more reasonably be expected to follow a normal distribution. This has the side effect that no constraints are needed in the optimisation. Thanks to René Lehmann for the nice cooperation on this, especially the isometric logration transformation that is now used for the formation fractions.</li>
<li>A side effect of this is that when parameter estimates are backtransformed to match the model definition, confidence intervals calculated from standard errors are also backtransformed to the correct scale, and will not include meaningless values like negative rate constants or formation fractions adding up to more than 1, which can not occur in a single experiment with a single defined radiolabel position.</li>
<li>The usual one-sided t-test for significant difference from zero is nevertheless shown based on estimators for the untransformed parameters.</li>
@@ -158,8 +151,6 @@
<ul class="list-unstyled">
<li>Download from CRAN at <br><a href="https://cran.r-project.org/package=mkin">https://​cran.r-project.org/​package=mkin</a>
</li>
-<li>Browse source code at <br><a href="http://github.com/jranke/mkin">http://​github.com/​jranke/​mkin</a>
-</li>
<li>Report a bug at <br><a href="http://github.com/jranke/mkin/issues">http://​github.com/​jranke/​mkin/​issues</a>
</li>
</ul>
diff --git a/docs/news/index.html b/docs/news/index.html
index c3c66b9a..74b42514 100644
--- a/docs/news/index.html
+++ b/docs/news/index.html
@@ -86,12 +86,7 @@
</ul>
<ul class="nav navbar-nav navbar-right">
- <li>
- <a href="http://github.com/jranke/mkin">
- <span class="fa fa-github fa-lg"></span>
-
- </a>
-</li>
+
</ul>
</div><!--/.nav-collapse -->
</div><!--/.container -->
@@ -108,9 +103,17 @@
</div>
<div class="contents">
- <div id="mkin-0-9-46-2" class="section level1">
+ <div id="mkin-0-9-46-3-2017-11-16" class="section level1">
+<h1 class="hasAnchor">
+<a href="#mkin-0-9-46-3-2017-11-16" class="anchor"></a>mkin 0.9.46.3 (2017-11-16)</h1>
+<ul>
+<li>
+<code>synthetic_data_for_UBA</code>: Add the code used to generate the data in the interest of reproducibility</li>
+</ul>
+</div>
+ <div id="mkin-0-9-46-2-2017-10-10" class="section level1">
<h1 class="hasAnchor">
-<a href="#mkin-0-9-46-2" class="anchor"></a>mkin 0.9.46.2</h1>
+<a href="#mkin-0-9-46-2-2017-10-10" class="anchor"></a>mkin 0.9.46.2 (2017-10-10)</h1>
<ul>
<li><p>Converted the vignette FOCUS_Z from tex/pdf to markdown/html</p></li>
<li><p><code>DESCRIPTION</code>: Add ORCID</p></li>
@@ -575,7 +578,8 @@
<div id="tocnav">
<h2>Contents</h2>
<ul class="nav nav-pills nav-stacked">
- <li><a href="#mkin-0-9-46-2">0.9.46.2</a></li>
+ <li><a href="#mkin-0-9-46-3-2017-11-16">0.9.46.3</a></li>
+ <li><a href="#mkin-0-9-46-2-2017-10-10">0.9.46.2</a></li>
<li><a href="#mkin-0-9-46-1-2017-09-14">0.9.46.1</a></li>
<li><a href="#mkin-0-9-46-2017-07-24">0.9.46</a></li>
<li><a href="#mkin-0-9-45-2-2017-07-24">0.9.45.2</a></li>
diff --git a/docs/reference/add_err.html b/docs/reference/add_err.html
index 046eabf5..d56a8728 100644
--- a/docs/reference/add_err.html
+++ b/docs/reference/add_err.html
@@ -86,12 +86,7 @@
</ul>
<ul class="nav navbar-nav navbar-right">
- <li>
- <a href="http://github.com/jranke/mkin">
- <span class="fa fa-github fa-lg"></span>
-
- </a>
-</li>
+
</ul>
</div><!--/.nav-collapse -->
</div><!--/.container -->
@@ -112,7 +107,7 @@
may depend on the predicted value and is specified as a standard deviation.</p>
- <pre class="usage"><span class='fu'>add_err</span>(<span class='no'>prediction</span>, <span class='no'>sdfunc</span>,
+ <pre class="usage"><span class='fu'>add_err</span>(<span class='no'>prediction</span>, <span class='no'>sdfunc</span>, <span class='kw'>secondary</span> <span class='kw'>=</span> <span class='fu'>c</span>(<span class='st'>"M1"</span>, <span class='st'>"M2"</span>),
<span class='kw'>n</span> <span class='kw'>=</span> <span class='fl'>1000</span>, <span class='kw'>LOD</span> <span class='kw'>=</span> <span class='fl'>0.1</span>, <span class='kw'>reps</span> <span class='kw'>=</span> <span class='fl'>2</span>,
<span class='kw'>digits</span> <span class='kw'>=</span> <span class='fl'>1</span>, <span class='kw'>seed</span> <span class='kw'>=</span> <span class='fl'>NA</span>)</pre>
@@ -130,6 +125,10 @@
terms for this value.</p></td>
</tr>
<tr>
+ <th>secondary</th>
+ <td><p>The names of state variables that should have an initial value of zero</p></td>
+ </tr>
+ <tr>
<th>n</th>
<td><p>The number of datasets to be generated.</p></td>
</tr>
diff --git a/docs/reference/index.html b/docs/reference/index.html
index 511a6aaa..dbcd5ba0 100644
--- a/docs/reference/index.html
+++ b/docs/reference/index.html
@@ -86,12 +86,7 @@
</ul>
<ul class="nav navbar-nav navbar-right">
- <li>
- <a href="http://github.com/jranke/mkin">
- <span class="fa fa-github fa-lg"></span>
-
- </a>
-</li>
+
</ul>
</div><!--/.nav-collapse -->
</div><!--/.container -->
@@ -105,7 +100,7 @@
<div class="page-header">
<h1>
Reference
- <small>version&nbsp;0.9.46.2</small>
+ <small>version&nbsp;0.9.46.3</small>
</h1>
</div>
diff --git a/docs/reference/synthetic_data_for_UBA.html b/docs/reference/synthetic_data_for_UBA.html
index 173af92e..9ff18876 100644
--- a/docs/reference/synthetic_data_for_UBA.html
+++ b/docs/reference/synthetic_data_for_UBA.html
@@ -70,6 +70,9 @@
<a href="../articles/FOCUS_L.html">Example evaluation of FOCUS Laboratory Data L1 to L3</a>
</li>
<li>
+ <a href="../articles/FOCUS_Z.html">Example evaluation of FOCUS Example Dataset Z</a>
+ </li>
+ <li>
<a href="../articles/compiled_models.html">Performance benefit by using compiled model definitions in mkin</a>
</li>
<li>
@@ -83,12 +86,7 @@
</ul>
<ul class="nav navbar-nav navbar-right">
- <li>
- <a href="http://github.com/jranke/mkin">
- <span class="fa fa-github fa-lg"></span>
-
- </a>
-</li>
+
</ul>
</div><!--/.nav-collapse -->
</div><!--/.container -->
@@ -109,7 +107,7 @@
two sequential or two parallel metabolites.</p>
<p>Variance component 'a' is based on a normal distribution with standard deviation of 3,
Variance component 'b' is also based on a normal distribution, but with a standard deviation of 7.
- Variance component 'c' is based on the error model from Rocke and Lorenzato (1995), with the
+ Variance component 'c' is based on the error model from Rocke and Lorenzato (1995), with the
minimum standard deviation (for small y values) of 0.5, and a proportionality constant of 0.07
for the increase of the standard deviation with y.</p>
<p>Initial concentrations for metabolites and all values where adding the variance component resulted
@@ -133,184 +131,116 @@
<h2 class="hasAnchor" id="source"><a class="anchor" href="#source"></a>Source</h2>
<p>Ranke (2014) Prüfung und Validierung von Modellierungssoftware als Alternative
- zu ModelMaker 4.0, Umweltbundesamt Projektnummer 27452
- Rocke, David M. und Lorenzato, Stefan (1995) A two-component model for
+ zu ModelMaker 4.0, Umweltbundesamt Projektnummer 27452</p>
+<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='no'>m_synth_SFO_lin</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='mkinmod.html'>mkinmod</a></span>(<span class='kw'>parent</span> <span class='kw'>=</span> <span class='fu'>list</span>(<span class='kw'>type</span> <span class='kw'>=</span> <span class='st'>"SFO"</span>, <span class='kw'>to</span> <span class='kw'>=</span> <span class='st'>"M1"</span>),
- <span class='kw'>M1</span> <span class='kw'>=</span> <span class='fu'>list</span>(<span class='kw'>type</span> <span class='kw'>=</span> <span class='st'>"SFO"</span>, <span class='kw'>to</span> <span class='kw'>=</span> <span class='st'>"M2"</span>),
- <span class='kw'>M2</span> <span class='kw'>=</span> <span class='fu'>list</span>(<span class='kw'>type</span> <span class='kw'>=</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'>#&gt; <span class='message'>Successfully compiled differential equation model from auto-generated C code.</span></div><div class='input'>
-
-<span class='no'>m_synth_SFO_par</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='mkinmod.html'>mkinmod</a></span>(<span class='kw'>parent</span> <span class='kw'>=</span> <span class='fu'>list</span>(<span class='kw'>type</span> <span class='kw'>=</span> <span class='st'>"SFO"</span>, <span class='kw'>to</span> <span class='kw'>=</span> <span class='fu'>c</span>(<span class='st'>"M1"</span>, <span class='st'>"M2"</span>),
- <span class='kw'>sink</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>),
- <span class='kw'>M1</span> <span class='kw'>=</span> <span class='fu'>list</span>(<span class='kw'>type</span> <span class='kw'>=</span> <span class='st'>"SFO"</span>),
- <span class='kw'>M2</span> <span class='kw'>=</span> <span class='fu'>list</span>(<span class='kw'>type</span> <span class='kw'>=</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'>#&gt; <span class='message'>Successfully compiled differential equation model from auto-generated C code.</span></div><div class='input'>
-<span class='no'>m_synth_DFOP_lin</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='mkinmod.html'>mkinmod</a></span>(<span class='kw'>parent</span> <span class='kw'>=</span> <span class='fu'>list</span>(<span class='kw'>type</span> <span class='kw'>=</span> <span class='st'>"DFOP"</span>, <span class='kw'>to</span> <span class='kw'>=</span> <span class='st'>"M1"</span>),
- <span class='kw'>M1</span> <span class='kw'>=</span> <span class='fu'>list</span>(<span class='kw'>type</span> <span class='kw'>=</span> <span class='st'>"SFO"</span>, <span class='kw'>to</span> <span class='kw'>=</span> <span class='st'>"M2"</span>),
- <span class='kw'>M2</span> <span class='kw'>=</span> <span class='fu'>list</span>(<span class='kw'>type</span> <span class='kw'>=</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'>#&gt; <span class='message'>Successfully compiled differential equation model from auto-generated C code.</span></div><div class='input'>
-<span class='no'>m_synth_DFOP_par</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='mkinmod.html'>mkinmod</a></span>(<span class='kw'>parent</span> <span class='kw'>=</span> <span class='fu'>list</span>(<span class='kw'>type</span> <span class='kw'>=</span> <span class='st'>"DFOP"</span>, <span class='kw'>to</span> <span class='kw'>=</span> <span class='fu'>c</span>(<span class='st'>"M1"</span>, <span class='st'>"M2"</span>),
- <span class='kw'>sink</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>),
- <span class='kw'>M1</span> <span class='kw'>=</span> <span class='fu'>list</span>(<span class='kw'>type</span> <span class='kw'>=</span> <span class='st'>"SFO"</span>),
- <span class='kw'>M2</span> <span class='kw'>=</span> <span class='fu'>list</span>(<span class='kw'>type</span> <span class='kw'>=</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'>#&gt; <span class='message'>Successfully compiled differential equation model from auto-generated C code.</span></div><div class='input'>
-<span class='no'>fit</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='mkinfit.html'>mkinfit</a></span>(<span class='no'>m_synth_SFO_lin</span>, <span class='no'>synthetic_data_for_UBA_2014</span><span class='kw'>[[</span><span class='fl'>1</span>]]$<span class='no'>data</span>, <span class='kw'>quiet</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>)
-<span class='fu'><a href='plot.mkinfit.html'>plot_sep</a></span>(<span class='no'>fit</span>)</div><img src='synthetic_data_for_UBA_2014-10.png' alt='' width='540' height='400' /><div class='input'><span class='fu'>summary</span>(<span class='no'>fit</span>)</div><div class='output co'>#&gt; mkin version: 0.9.46
-#&gt; R version: 3.4.1
-#&gt; Date of fit: Sat Jul 29 15:15:33 2017
-#&gt; Date of summary: Sat Jul 29 15:15:34 2017
-#&gt;
-#&gt; Equations:
-#&gt; d_parent/dt = - k_parent * parent
-#&gt; d_M1/dt = + f_parent_to_M1 * k_parent * parent - k_M1 * M1
-#&gt; d_M2/dt = + f_M1_to_M2 * k_M1 * M1 - k_M2 * M2
-#&gt;
-#&gt; Model predictions using solution type deSolve
-#&gt;
-#&gt; Fitted with method Port using 381 model solutions performed in 2.241 s
-#&gt;
-#&gt; Weighting: none
-#&gt;
-#&gt; Starting values for parameters to be optimised:
-#&gt; value type
-#&gt; parent_0 101.3500 state
-#&gt; k_parent 0.1000 deparm
-#&gt; k_M1 0.1001 deparm
-#&gt; k_M2 0.1002 deparm
-#&gt; f_parent_to_M1 0.5000 deparm
-#&gt; f_M1_to_M2 0.5000 deparm
-#&gt;
-#&gt; Starting values for the transformed parameters actually optimised:
-#&gt; value lower upper
-#&gt; parent_0 101.350000 -Inf Inf
-#&gt; log_k_parent -2.302585 -Inf Inf
-#&gt; log_k_M1 -2.301586 -Inf Inf
-#&gt; log_k_M2 -2.300587 -Inf Inf
-#&gt; f_parent_ilr_1 0.000000 -Inf Inf
-#&gt; f_M1_ilr_1 0.000000 -Inf Inf
-#&gt;
-#&gt; Fixed parameter values:
-#&gt; value type
-#&gt; M1_0 0 state
-#&gt; M2_0 0 state
-#&gt;
-#&gt; Optimised, transformed parameters with symmetric confidence intervals:
-#&gt; Estimate Std. Error Lower Upper
-#&gt; parent_0 102.1000 1.71400 98.5800 105.5000
-#&gt; log_k_parent -0.3020 0.04294 -0.3894 -0.2147
-#&gt; log_k_M1 -1.2070 0.07599 -1.3610 -1.0520
-#&gt; log_k_M2 -3.9010 0.06952 -4.0420 -3.7590
-#&gt; f_parent_ilr_1 0.8492 0.18090 0.4812 1.2170
-#&gt; f_M1_ilr_1 0.6780 0.18860 0.2943 1.0620
-#&gt;
-#&gt; Parameter correlation:
-#&gt; parent_0 log_k_parent log_k_M1 log_k_M2 f_parent_ilr_1
-#&gt; parent_0 1.00000 0.40213 -0.1693 0.02912 -0.4726
-#&gt; log_k_parent 0.40213 1.00000 -0.4210 0.07241 -0.5837
-#&gt; log_k_M1 -0.16931 -0.42103 1.0000 -0.37657 0.7438
-#&gt; log_k_M2 0.02912 0.07241 -0.3766 1.00000 -0.2518
-#&gt; f_parent_ilr_1 -0.47263 -0.58367 0.7438 -0.25177 1.0000
-#&gt; f_M1_ilr_1 0.17148 0.42643 -0.8054 0.52647 -0.8602
-#&gt; f_M1_ilr_1
-#&gt; parent_0 0.1715
-#&gt; log_k_parent 0.4264
-#&gt; log_k_M1 -0.8054
-#&gt; log_k_M2 0.5265
-#&gt; f_parent_ilr_1 -0.8602
-#&gt; f_M1_ilr_1 1.0000
-#&gt;
-#&gt; Residual standard error: 2.471 on 33 degrees of freedom
-#&gt;
-#&gt; Backtransformed parameters:
-#&gt; Confidence intervals for internally transformed parameters are asymmetric.
-#&gt; t-test (unrealistically) based on the assumption of normal distribution
-#&gt; for estimators of untransformed parameters.
-#&gt; Estimate t value Pr(&gt;t) Lower Upper
-#&gt; parent_0 102.10000 59.55 1.815e-35 98.58000 105.5000
-#&gt; k_parent 0.73930 23.29 2.337e-22 0.67750 0.8068
-#&gt; k_M1 0.29920 13.16 5.552e-15 0.25630 0.3492
-#&gt; k_M2 0.02023 14.38 4.497e-16 0.01756 0.0233
-#&gt; f_parent_to_M1 0.76870 16.90 4.093e-18 0.66380 0.8483
-#&gt; f_M1_to_M2 0.72290 13.53 2.557e-15 0.60260 0.8178
-#&gt;
-#&gt; Chi2 error levels in percent:
-#&gt; err.min n.optim df
-#&gt; All data 8.454 6 17
-#&gt; parent 8.660 2 6
-#&gt; M1 10.583 2 5
-#&gt; M2 3.586 2 6
-#&gt;
-#&gt; Resulting formation fractions:
-#&gt; ff
-#&gt; parent_M1 0.7687
-#&gt; parent_sink 0.2313
-#&gt; M1_M2 0.7229
-#&gt; M1_sink 0.2771
-#&gt;
-#&gt; Estimated disappearance times:
-#&gt; DT50 DT90
-#&gt; parent 0.9376 3.114
-#&gt; M1 2.3170 7.697
-#&gt; M2 34.2689 113.839
-#&gt;
-#&gt; Data:
-#&gt; time variable observed predicted residual
-#&gt; 0 parent 101.5 1.021e+02 -0.56248
-#&gt; 0 parent 101.2 1.021e+02 -0.86248
-#&gt; 1 parent 53.9 4.873e+01 5.17118
-#&gt; 1 parent 47.5 4.873e+01 -1.22882
-#&gt; 3 parent 10.4 1.111e+01 -0.70773
-#&gt; 3 parent 7.6 1.111e+01 -3.50773
-#&gt; 7 parent 1.1 5.772e-01 0.52283
-#&gt; 7 parent 0.3 5.772e-01 -0.27717
-#&gt; 14 parent NA 3.264e-03 NA
-#&gt; 14 parent 3.5 3.264e-03 3.49674
-#&gt; 28 parent NA 1.045e-07 NA
-#&gt; 28 parent 3.2 1.045e-07 3.20000
-#&gt; 60 parent NA -1.054e-10 NA
-#&gt; 60 parent NA -1.054e-10 NA
-#&gt; 90 parent 0.6 -1.875e-11 0.60000
-#&gt; 90 parent NA -1.875e-11 NA
-#&gt; 120 parent NA -2.805e-11 NA
-#&gt; 120 parent 3.5 -2.805e-11 3.50000
-#&gt; 0 M1 NA 0.000e+00 NA
-#&gt; 0 M1 NA 0.000e+00 NA
-#&gt; 1 M1 36.4 3.479e+01 1.61088
-#&gt; 1 M1 37.4 3.479e+01 2.61088
-#&gt; 3 M1 34.3 3.937e+01 -5.07027
-#&gt; 3 M1 39.8 3.937e+01 0.42973
-#&gt; 7 M1 15.1 1.549e+01 -0.38715
-#&gt; 7 M1 17.8 1.549e+01 2.31285
-#&gt; 14 M1 5.8 1.995e+00 3.80469
-#&gt; 14 M1 1.2 1.995e+00 -0.79531
-#&gt; 28 M1 NA 3.034e-02 NA
-#&gt; 28 M1 NA 3.034e-02 NA
-#&gt; 60 M1 0.5 2.111e-06 0.50000
-#&gt; 60 M1 NA 2.111e-06 NA
-#&gt; 90 M1 NA 2.913e-10 NA
-#&gt; 90 M1 3.2 2.913e-10 3.20000
-#&gt; 120 M1 1.5 3.625e-11 1.50000
-#&gt; 120 M1 0.6 3.625e-11 0.60000
-#&gt; 0 M2 NA 0.000e+00 NA
-#&gt; 0 M2 NA 0.000e+00 NA
-#&gt; 1 M2 NA 4.455e+00 NA
-#&gt; 1 M2 4.8 4.455e+00 0.34517
-#&gt; 3 M2 20.9 2.153e+01 -0.62527
-#&gt; 3 M2 19.3 2.153e+01 -2.22527
-#&gt; 7 M2 42.0 4.192e+01 0.07941
-#&gt; 7 M2 43.1 4.192e+01 1.17941
-#&gt; 14 M2 49.4 4.557e+01 3.83353
-#&gt; 14 M2 44.3 4.557e+01 -1.26647
-#&gt; 28 M2 34.6 3.547e+01 -0.87275
-#&gt; 28 M2 33.0 3.547e+01 -2.47275
-#&gt; 60 M2 18.8 1.858e+01 0.21837
-#&gt; 60 M2 17.6 1.858e+01 -0.98163
-#&gt; 90 M2 10.6 1.013e+01 0.47130
-#&gt; 90 M2 10.8 1.013e+01 0.67130
-#&gt; 120 M2 9.8 5.521e+00 4.27893
-#&gt; 120 M2 3.3 5.521e+00 -2.22107</div><div class='input'>
-</div></pre>
+# The data have been generated using the following kinetic models
+m_synth_SFO_lin <- mkinmod(parent = list(type = "SFO", to = "M1"),
+ M1 = list(type = "SFO", to = "M2"),
+ M2 = list(type = "SFO"), use_of_ff = "max")
+
+
+m_synth_SFO_par <- mkinmod(parent = list(type = "SFO", to = c("M1", "M2"),
+ sink = FALSE),
+ M1 = list(type = "SFO"),
+ M2 = list(type = "SFO"), use_of_ff = "max")
+
+m_synth_DFOP_lin <- mkinmod(parent = list(type = "DFOP", to = "M1"),
+ M1 = list(type = "SFO", to = "M2"),
+ M2 = list(type = "SFO"), use_of_ff = "max")
+
+m_synth_DFOP_par <- mkinmod(parent = list(type = "DFOP", to = c("M1", "M2"),
+ sink = FALSE),
+ M1 = list(type = "SFO"),
+ M2 = list(type = "SFO"), use_of_ff = "max")
+
+# The model predictions without intentional error were generated as follows
+sampling_times = c(0, 1, 3, 7, 14, 28, 60, 90, 120)
+
+d_synth_SFO_lin <- mkinpredict(m_synth_SFO_lin,
+ c(k_parent = 0.7, f_parent_to_M1 = 0.8,
+ k_M1 = 0.3, f_M1_to_M2 = 0.7,
+ k_M2 = 0.02),
+ c(parent = 100, M1 = 0, M2 = 0),
+ sampling_times)
+
+d_synth_DFOP_lin <- mkinpredict(m_synth_DFOP_lin,
+ c(k1 = 0.2, k2 = 0.02, g = 0.5,
+ f_parent_to_M1 = 0.5, k_M1 = 0.3,
+ f_M1_to_M2 = 0.7, k_M2 = 0.02),
+ c(parent = 100, M1 = 0, M2 = 0),
+ sampling_times)
+
+d_synth_SFO_par <- mkinpredict(m_synth_SFO_par,
+ c(k_parent = 0.2,
+ f_parent_to_M1 = 0.8, k_M1 = 0.01,
+ f_parent_to_M2 = 0.2, k_M2 = 0.02),
+ c(parent = 100, M1 = 0, M2 = 0),
+ sampling_times)
+
+d_synth_DFOP_par <- mkinpredict(m_synth_DFOP_par,
+ c(k1 = 0.3, k2 = 0.02, g = 0.7,
+ f_parent_to_M1 = 0.6, k_M1 = 0.04,
+ f_parent_to_M2 = 0.4, k_M2 = 0.01),
+ c(parent = 100, M1 = 0, M2 = 0),
+ sampling_times)
+
+# Construct names for datasets with errors
+d_synth_names = paste0("d_synth_", c("SFO_lin", "SFO_par",
+ "DFOP_lin", "DFOP_par"))
+
+# Function for adding errors. The add_err function now published with this
+# package is a slightly generalised version where the names of secondary
+# compartments that should have an initial value of zero (M1 and M2 in this
+# case) are not hardcoded any more.
+add_err = function(d, sdfunc, LOD = 0.1, reps = 2, seed = 123456789)
+{
+ set.seed(seed)
+ d_long = mkin_wide_to_long(d, time = "time")
+ d_rep = data.frame(lapply(d_long, rep, each = 2))
+ d_rep$value = rnorm(length(d_rep$value), d_rep$value, sdfunc(d_rep$value))
+
+ d_rep[d_rep$time == 0 & d_rep$name <!-- %in% c("M1", "M2"), "value"] &lt;- 0 -->
+ d_NA <- transform(d_rep, value = ifelse(value < LOD, NA, value))
+ d_NA$value <- round(d_NA$value, 1)
+ return(d_NA)
+}
+
+# The following is the two-component model of Rocke and Lorenzato (1995)
+sdfunc_twocomp = function(value, sd_low, rsd_high) {
+ sqrt(sd_low^2 + value^2 * rsd_high^2)
+}
+
+# Add the errors.
+for (d_synth_name in d_synth_names)
+{
+ d_synth = get(d_synth_name)
+ assign(paste0(d_synth_name, "_a"), add_err(d_synth, function(value) 3))
+ assign(paste0(d_synth_name, "_b"), add_err(d_synth, function(value) 7))
+ assign(paste0(d_synth_name, "_c"), add_err(d_synth,
+ function(value) sdfunc_twocomp(value, 0.5, 0.07)))
+
+}
+
+d_synth_err_names = c(
+ paste(rep(d_synth_names, each = 3), letters[1:3], sep = "_")
+)
+
+# This is just one example of an evaluation using the kinetic model used for
+# the generation of the data
+fit <- mkinfit(m_synth_SFO_lin, synthetic_data_for_UBA_2014[[1]]$data,
+ quiet = TRUE)
+plot_sep(fit)
+summary(fit)
+
+</div><div class='output co'>#&gt; <span class='error'>Error: &lt;text&gt;:68:43: Unerwartete(s) SPECIAL</span>
+#&gt; <span class='error'>67: </span>
+#&gt; <span class='error'>68: d_rep[d_rep$time == 0 &amp; d_rep$name &lt;!-- %in%</span>
+#&gt; <span class='error'> ^</span></div></pre>
</div>
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<h2>Contents</h2>
diff --git a/man/add_err.Rd b/man/add_err.Rd
index 808edbc6..e098d95c 100644
--- a/man/add_err.Rd
+++ b/man/add_err.Rd
@@ -9,7 +9,7 @@
may depend on the predicted value and is specified as a standard deviation.
}
\usage{
- add_err(prediction, sdfunc,
+ add_err(prediction, sdfunc, secondary = c("M1", "M2"),
n = 1000, LOD = 0.1, reps = 2,
digits = 1, seed = NA)
}
@@ -22,6 +22,9 @@
a standard deviation that should be used for generating the random error
terms for this value.
}
+ \item{secondary}{
+ The names of state variables that should have an initial value of zero
+ }
\item{n}{
The number of datasets to be generated.
}
diff --git a/man/synthetic_data_for_UBA.Rd b/man/synthetic_data_for_UBA.Rd
index a9739d55..3339798e 100644
--- a/man/synthetic_data_for_UBA.Rd
+++ b/man/synthetic_data_for_UBA.Rd
@@ -11,7 +11,7 @@
Variance component 'a' is based on a normal distribution with standard deviation of 3,
Variance component 'b' is also based on a normal distribution, but with a standard deviation of 7.
- Variance component 'c' is based on the error model from Rocke and Lorenzato (1995), with the
+ Variance component 'c' is based on the error model from Rocke and Lorenzato (1995), with the
minimum standard deviation (for small y values) of 0.5, and a proportionality constant of 0.07
for the increase of the standard deviation with y.
@@ -36,12 +36,13 @@
\source{
Ranke (2014) Prüfung und Validierung von Modellierungssoftware als Alternative
zu ModelMaker 4.0, Umweltbundesamt Projektnummer 27452
-
+
Rocke, David M. und Lorenzato, Stefan (1995) A two-component model for
measurement error in analytical chemistry. Technometrics 37(2), 176-184.
}
\examples{
\dontrun{
+# The data have been generated using the following kinetic models
m_synth_SFO_lin <- mkinmod(parent = list(type = "SFO", to = "M1"),
M1 = list(type = "SFO", to = "M2"),
M2 = list(type = "SFO"), use_of_ff = "max")
@@ -61,7 +62,82 @@ m_synth_DFOP_par <- mkinmod(parent = list(type = "DFOP", to = c("M1", "M2"),
M1 = list(type = "SFO"),
M2 = list(type = "SFO"), use_of_ff = "max")
-fit <- mkinfit(m_synth_SFO_lin, synthetic_data_for_UBA_2014[[1]]$data, quiet = TRUE)
+# The model predictions without intentional error were generated as follows
+sampling_times = c(0, 1, 3, 7, 14, 28, 60, 90, 120)
+
+d_synth_SFO_lin <- mkinpredict(m_synth_SFO_lin,
+ c(k_parent = 0.7, f_parent_to_M1 = 0.8,
+ k_M1 = 0.3, f_M1_to_M2 = 0.7,
+ k_M2 = 0.02),
+ c(parent = 100, M1 = 0, M2 = 0),
+ sampling_times)
+
+d_synth_DFOP_lin <- mkinpredict(m_synth_DFOP_lin,
+ c(k1 = 0.2, k2 = 0.02, g = 0.5,
+ f_parent_to_M1 = 0.5, k_M1 = 0.3,
+ f_M1_to_M2 = 0.7, k_M2 = 0.02),
+ c(parent = 100, M1 = 0, M2 = 0),
+ sampling_times)
+
+d_synth_SFO_par <- mkinpredict(m_synth_SFO_par,
+ c(k_parent = 0.2,
+ f_parent_to_M1 = 0.8, k_M1 = 0.01,
+ f_parent_to_M2 = 0.2, k_M2 = 0.02),
+ c(parent = 100, M1 = 0, M2 = 0),
+ sampling_times)
+
+d_synth_DFOP_par <- mkinpredict(m_synth_DFOP_par,
+ c(k1 = 0.3, k2 = 0.02, g = 0.7,
+ f_parent_to_M1 = 0.6, k_M1 = 0.04,
+ f_parent_to_M2 = 0.4, k_M2 = 0.01),
+ c(parent = 100, M1 = 0, M2 = 0),
+ sampling_times)
+
+# Construct names for datasets with errors
+d_synth_names = paste0("d_synth_", c("SFO_lin", "SFO_par",
+ "DFOP_lin", "DFOP_par"))
+
+# Function for adding errors. The add_err function now published with this
+# package is a slightly generalised version where the names of secondary
+# compartments that should have an initial value of zero (M1 and M2 in this
+# case) are not hardcoded any more.
+add_err = function(d, sdfunc, LOD = 0.1, reps = 2, seed = 123456789)
+{
+ set.seed(seed)
+ d_long = mkin_wide_to_long(d, time = "time")
+ d_rep = data.frame(lapply(d_long, rep, each = 2))
+ d_rep$value = rnorm(length(d_rep$value), d_rep$value, sdfunc(d_rep$value))
+
+ d_rep[d_rep$time == 0 & d_rep$name %in% c("M1", "M2"), "value"] <- 0
+ d_NA <- transform(d_rep, value = ifelse(value < LOD, NA, value))
+ d_NA$value <- round(d_NA$value, 1)
+ return(d_NA)
+}
+
+# The following is the two-component model of Rocke and Lorenzato (1995)
+sdfunc_twocomp = function(value, sd_low, rsd_high) {
+ sqrt(sd_low^2 + value^2 * rsd_high^2)
+}
+
+# Add the errors.
+for (d_synth_name in d_synth_names)
+{
+ d_synth = get(d_synth_name)
+ assign(paste0(d_synth_name, "_a"), add_err(d_synth, function(value) 3))
+ assign(paste0(d_synth_name, "_b"), add_err(d_synth, function(value) 7))
+ assign(paste0(d_synth_name, "_c"), add_err(d_synth,
+ function(value) sdfunc_twocomp(value, 0.5, 0.07)))
+
+}
+
+d_synth_err_names = c(
+ paste(rep(d_synth_names, each = 3), letters[1:3], sep = "_")
+)
+
+# This is just one example of an evaluation using the kinetic model used for
+# the generation of the data
+fit <- mkinfit(m_synth_SFO_lin, synthetic_data_for_UBA_2014[[1]]$data,
+ quiet = TRUE)
plot_sep(fit)
summary(fit)
}

Contact - Imprint