aboutsummaryrefslogtreecommitdiff
path: root/docs/reference/massart97ex3.html
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2018-07-17 17:29:14 +0200
committerJohannes Ranke <jranke@uni-bremen.de>2018-07-17 17:38:29 +0200
commit280d36230052de4f94e384648c1283031fbc9840 (patch)
treedf0ba9e07386b593cc396b8b6976210d42ee1a46 /docs/reference/massart97ex3.html
parente636c17f0d354a8e74546fc1469431dbe502dc76 (diff)
Fix inverse predictions for replicate measurements
For details, see NEWS.md
Diffstat (limited to 'docs/reference/massart97ex3.html')
-rw-r--r--docs/reference/massart97ex3.html63
1 files changed, 36 insertions, 27 deletions
diff --git a/docs/reference/massart97ex3.html b/docs/reference/massart97ex3.html
index 434fc7b..e9fa06a 100644
--- a/docs/reference/massart97ex3.html
+++ b/docs/reference/massart97ex3.html
@@ -61,17 +61,26 @@
</button>
<span class="navbar-brand">
<a class="navbar-link" href="../index.html">chemCal</a>
- <span class="label label-default" data-toggle="tooltip" data-placement="bottom" title="Released package">0.1.37.9001</span>
+ <span class="label label-default" data-toggle="tooltip" data-placement="bottom" title="Released package">0.2.1</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>
+ <a href="../index.html">
+ <span class="fa fa-home fa-lg"></span>
+
+ </a>
</li>
<li>
- <a href="../articles/chemCal.pdf">Short manual (pdf)</a>
+ <a href="../articles/chemCal.html">Get started</a>
+</li>
+<li>
+ <a href="../reference/index.html">Reference</a>
+</li>
+<li>
+ <a href="../news/index.html">Changelog</a>
</li>
</ul>
@@ -100,7 +109,7 @@
</div>
- <pre class="usage"><span class='fu'>data</span>(<span class='no'>massart97ex3</span>)</pre>
+ <pre class="usage"><span class='no'>massart97ex3</span></pre>
<h2 class="hasAnchor" id="format"><a class="anchor" href="#format"></a>Format</h2>
@@ -115,18 +124,21 @@
<h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
- <pre class="examples"><div class='input'><span class='fu'>data</span>(<span class='no'>massart97ex3</span>)
-<span class='fu'>attach</span>(<span class='no'>massart97ex3</span>)</div><div class='output co'>#&gt; <span class='message'>The following objects are masked from massart97ex3 (pos = 3):</span>
-#&gt; <span class='message'></span>
-#&gt; <span class='message'> x, y</span></div><div class='input'><span class='no'>yx</span> <span class='kw'>&lt;-</span> <span class='fu'>split</span>(<span class='no'>y</span>, <span class='no'>x</span>)
-<span class='no'>ybar</span> <span class='kw'>&lt;-</span> <span class='fu'>sapply</span>(<span class='no'>yx</span>, <span class='no'>mean</span>)
-<span class='no'>s</span> <span class='kw'>&lt;-</span> <span class='fu'>round</span>(<span class='fu'>sapply</span>(<span class='no'>yx</span>, <span class='no'>sd</span>), <span class='kw'>digits</span> <span class='kw'>=</span> <span class='fl'>2</span>)
-<span class='no'>w</span> <span class='kw'>&lt;-</span> <span class='fu'>round</span>(<span class='fl'>1</span> / (<span class='no'>s</span>^<span class='fl'>2</span>), <span class='kw'>digits</span> <span class='kw'>=</span> <span class='fl'>3</span>)
-<span class='no'>weights</span> <span class='kw'>&lt;-</span> <span class='no'>w</span>[<span class='fu'>factor</span>(<span class='no'>x</span>)]
-<span class='no'>m</span> <span class='kw'>&lt;-</span> <span class='fu'>lm</span>(<span class='no'>y</span> ~ <span class='no'>x</span>, <span class='kw'>w</span> <span class='kw'>=</span> <span class='no'>weights</span>)
-<span class='fu'>calplot</span>(<span class='no'>m</span>)</div><div class='output co'>#&gt; <span class='warning'>Warning: Assuming constant prediction variance even though model fit is weighted</span></div><div class='img'><img src='massart97ex3-1.png' alt='' width='700' height='433' /></div><div class='input'>
+ <pre class="examples"><div class='input'><span class='co'># For reproducing the results for replicate standard measurements in example 8,</span>
+<span class='co'># we need to do the calibration on the means when using chemCal &gt; 0.2</span>
+<span class='no'>weights</span> <span class='kw'>&lt;-</span> <span class='fu'>with</span>(<span class='no'>massart97ex3</span>, {
+ <span class='no'>yx</span> <span class='kw'>&lt;-</span> <span class='fu'>split</span>(<span class='no'>y</span>, <span class='no'>x</span>)
+ <span class='no'>ybar</span> <span class='kw'>&lt;-</span> <span class='fu'>sapply</span>(<span class='no'>yx</span>, <span class='no'>mean</span>)
+ <span class='no'>s</span> <span class='kw'>&lt;-</span> <span class='fu'>round</span>(<span class='fu'>sapply</span>(<span class='no'>yx</span>, <span class='no'>sd</span>), <span class='kw'>digits</span> <span class='kw'>=</span> <span class='fl'>2</span>)
+ <span class='no'>w</span> <span class='kw'>&lt;-</span> <span class='fu'>round</span>(<span class='fl'>1</span> / (<span class='no'>s</span>^<span class='fl'>2</span>), <span class='kw'>digits</span> <span class='kw'>=</span> <span class='fl'>3</span>)
+})
+
+<span class='no'>massart97ex3.means</span> <span class='kw'>&lt;-</span> <span class='fu'>aggregate</span>(<span class='no'>y</span> ~ <span class='no'>x</span>, <span class='no'>massart97ex3</span>, <span class='no'>mean</span>)
+
+<span class='no'>m3.means</span> <span class='kw'>&lt;-</span> <span class='fu'>lm</span>(<span class='no'>y</span> ~ <span class='no'>x</span>, <span class='kw'>w</span> <span class='kw'>=</span> <span class='no'>weights</span>, <span class='kw'>data</span> <span class='kw'>=</span> <span class='no'>massart97ex3.means</span>)
+
<span class='co'># The following concords with the book p. 200</span>
-<span class='fu'>inverse.predict</span>(<span class='no'>m</span>, <span class='fl'>15</span>, <span class='kw'>ws</span> <span class='kw'>=</span> <span class='fl'>1.67</span>) <span class='co'># 5.9 +- 2.5</span></div><div class='output co'>#&gt; $Prediction
+<span class='fu'><a href='inverse.predict.html'>inverse.predict</a></span>(<span class='no'>m3.means</span>, <span class='fl'>15</span>, <span class='kw'>ws</span> <span class='kw'>=</span> <span class='fl'>1.67</span>) <span class='co'># 5.9 +- 2.5</span></div><div class='output co'>#&gt; $Prediction
#&gt; [1] 5.865367
#&gt;
#&gt; $`Standard Error`
@@ -137,7 +149,7 @@
#&gt;
#&gt; $`Confidence Limits`
#&gt; [1] 3.387082 8.343652
-#&gt; </div><div class='input'><span class='fu'>inverse.predict</span>(<span class='no'>m</span>, <span class='fl'>90</span>, <span class='kw'>ws</span> <span class='kw'>=</span> <span class='fl'>0.145</span>) <span class='co'># 44.1 +- 7.9</span></div><div class='output co'>#&gt; $Prediction
+#&gt; </div><div class='input'><span class='fu'><a href='inverse.predict.html'>inverse.predict</a></span>(<span class='no'>m3.means</span>, <span class='fl'>90</span>, <span class='kw'>ws</span> <span class='kw'>=</span> <span class='fl'>0.145</span>) <span class='co'># 44.1 +- 7.9</span></div><div class='output co'>#&gt; $Prediction
#&gt; [1] 44.06025
#&gt;
#&gt; $`Standard Error`
@@ -151,33 +163,30 @@
#&gt; </div><div class='input'>
<span class='co'># The LOD is only calculated for models from unweighted regression</span>
<span class='co'># with this version of chemCal</span>
-<span class='no'>m0</span> <span class='kw'>&lt;-</span> <span class='fu'>lm</span>(<span class='no'>y</span> ~ <span class='no'>x</span>)
-<span class='fu'>lod</span>(<span class='no'>m0</span>)</div><div class='output co'>#&gt; $x
+<span class='no'>m0</span> <span class='kw'>&lt;-</span> <span class='fu'>lm</span>(<span class='no'>y</span> ~ <span class='no'>x</span>, <span class='kw'>data</span> <span class='kw'>=</span> <span class='no'>massart97ex3</span>)
+<span class='fu'><a href='lod.html'>lod</a></span>(<span class='no'>m0</span>)</div><div class='output co'>#&gt; $x
#&gt; [1] 5.407085
#&gt;
#&gt; $y
-#&gt; 1
-#&gt; 13.63911
+#&gt; [1] 13.63911
#&gt; </div><div class='input'>
<span class='co'># Limit of quantification from unweighted regression</span>
-<span class='fu'>loq</span>(<span class='no'>m0</span>)</div><div class='output co'>#&gt; $x
-#&gt; [1] 13.97764
+<span class='fu'><a href='loq.html'>loq</a></span>(<span class='no'>m0</span>)</div><div class='output co'>#&gt; $x
+#&gt; [1] 9.627349
#&gt;
#&gt; $y
-#&gt; 1
-#&gt; 30.6235
+#&gt; [1] 22.00246
#&gt; </div><div class='input'>
<span class='co'># For calculating the limit of quantification from a model from weighted</span>
<span class='co'># regression, we need to supply weights, internally used for inverse.predict</span>
<span class='co'># If we are not using a variance function, we can use the weight from</span>
<span class='co'># the above example as a first approximation (x = 15 is close to our</span>
<span class='co'># loq approx 14 from above).</span>
-<span class='fu'>loq</span>(<span class='no'>m</span>, <span class='kw'>w.loq</span> <span class='kw'>=</span> <span class='fl'>1.67</span>)</div><div class='output co'>#&gt; $x
+<span class='fu'><a href='loq.html'>loq</a></span>(<span class='no'>m3.means</span>, <span class='kw'>w.loq</span> <span class='kw'>=</span> <span class='fl'>1.67</span>)</div><div class='output co'>#&gt; $x
#&gt; [1] 7.346195
#&gt;
#&gt; $y
-#&gt; 1
-#&gt; 17.90777
+#&gt; [1] 17.90777
#&gt; </div><div class='input'># The weight for the loq should therefore be derived at x = 7.3 instead
# of 15, but the graphical procedure of Massart (p. 201) to derive the
# variances on which the weights are based is quite inaccurate anyway.

Contact - Imprint