From 43d58935483e0d9dda7a74c029e7d7d2adad9ed7 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Wed, 20 May 2020 08:44:47 +0200 Subject: Static documentation rebuilt by pkgdown::build_site() --- docs/articles/chemCal.html | 80 +++++++++++++++++++++++++--------------------- 1 file changed, 43 insertions(+), 37 deletions(-) (limited to 'docs/articles/chemCal.html') diff --git a/docs/articles/chemCal.html b/docs/articles/chemCal.html index e301880..ce745fb 100644 --- a/docs/articles/chemCal.html +++ b/docs/articles/chemCal.html @@ -6,18 +6,19 @@ Introduction to chemCal • chemCal - - - + + + + + - - + - +
@@ -61,15 +69,16 @@ +
@@ -90,25 +99,25 @@ Usage

When calibrating an analytical method, the first task is to generate a suitable model. If we want to use the chemCal functions, we have to restrict ourselves to univariate, possibly weighted, linear regression so far.

Once such a model has been created, the calibration can be graphically shown by using the calplot function:

-
library(chemCal)
-m0 <- lm(y ~ x, data = massart97ex3)
-calplot(m0)
+
library(chemCal)
+m0 <- lm(y ~ x, data = massart97ex3)
+calplot(m0)

As we can see, the scatter increases with increasing x. This is also illustrated by one of the diagnostic plots for linear models provided by R:

-
plot(m0, which=3)
+
plot(m0, which=3)

Therefore, in Example 8 in Massart et al. (1997), weighted regression is proposed which can be reproduced by the following code. Note that we are building the model on the mean values for each standard in order to be able to reproduce the results given in the book with the current version of chemCal.

-
weights <- with(massart97ex3, {
-  yx <- split(y, x)
-  ybar <- sapply(yx, mean)
-  s <- round(sapply(yx, sd), digits = 2)
-  w <- round(1 / (s^2), digits = 3)
-})
-massart97ex3.means <- aggregate(y ~ x, massart97ex3, mean)
-
-m <- lm(y ~ x, w = weights, data = massart97ex3.means)
+
weights <- with(massart97ex3, {
+  yx <- split(y, x)
+  ybar <- sapply(yx, mean)
+  s <- round(sapply(yx, sd), digits = 2)
+  w <- round(1 / (s^2), digits = 3)
+})
+massart97ex3.means <- aggregate(y ~ x, massart97ex3, mean)
+
+m <- lm(y ~ x, w = weights, data = massart97ex3.means)

If we now want to predict a new x value from measured y values, we use the inverse.predict function:

-
inverse.predict(m, 15, ws=1.67)
+
inverse.predict(m, 15, ws=1.67)
## $Prediction
 ## [1] 5.865367
 ## 
@@ -120,7 +129,7 @@
 ## 
 ## $`Confidence Limits`
 ## [1] 3.387082 8.343652
-
inverse.predict(m, 90, ws = 0.145)
+
inverse.predict(m, 90, ws = 0.145)
## $Prediction
 ## [1] 44.06025
 ## 
@@ -178,32 +187,29 @@ s_{\hat{x_s}} = \frac{1}{b_1} \sqrt{\frac{{s_s}^2}{w_s m} +
 
- +
-

Site built with pkgdown 1.3.0.

+

Site built with pkgdown 1.5.1.

+
+ -- cgit v1.2.1