From f4fcef8228ebd5a1a73bc6edc47b5efa259c2e20 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Wed, 23 Mar 2022 10:32:36 +0100 Subject: Use 'investr' conditionally in tests, updates Most prominently, a README was added, giving a nice overview for the people visiting the github page, the package page on CRAN, or the online docs at pkgdown.jrwb.de. The maintainer e-mail address was also updated. --- docs/reference/inverse.predict.html | 350 ++++++++++++++---------------------- 1 file changed, 138 insertions(+), 212 deletions(-) (limited to 'docs/reference/inverse.predict.html') diff --git a/docs/reference/inverse.predict.html b/docs/reference/inverse.predict.html index aece430..cb9fe98 100644 --- a/docs/reference/inverse.predict.html +++ b/docs/reference/inverse.predict.html @@ -1,46 +1,5 @@ - - - - - - - -Predict x from y for a linear calibration — inverse.predict • chemCal - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Predict x from y for a linear calibration — inverse.predict • chemCal - - - - - - - - - - - - - + + -
-
- -
- -
+
-
inverse.predict(object, newdata, ...,
-  ws, alpha=0.05, var.s = "auto")
+
+
inverse.predict(object, newdata, ...,
+  ws, alpha=0.05, var.s = "auto")
+
-

Arguments

- - - - - - - - - - - - - - - - - - - - - - - - - - -
object

A univariate model object of class lm or - rlm - with model formula y ~ x or y ~ x - 1.

newdata

A vector of observed y values for one sample.

...

Placeholder for further arguments that might be needed by - future implementations.

ws

The weight attributed to the sample. This argument is obligatory - if object has weights.

alpha

The error tolerance level for the confidence interval to be reported.

var.s

The estimated variance of the sample measurements. The default is to take +

+

Arguments

+
object
+

A univariate model object of class lm or + rlm + with model formula y ~ x or y ~ x - 1.

+
newdata
+

A vector of observed y values for one sample.

+
...
+

Placeholder for further arguments that might be needed by + future implementations.

+
ws
+

The weight attributed to the sample. This argument is obligatory + if object has weights.

+
alpha
+

The error tolerance level for the confidence interval to be reported.

+
var.s
+

The estimated variance of the sample measurements. The default is to take the residual standard error from the calibration and to adjust it using ws, if applicable. This means that var.s - overrides ws.

- -

Value

- + overrides ws.

+
+
+

Value

A list containing the predicted x value, its standard error and a confidence interval.

-

Note

- +
+
+

Note

The function was validated with examples 7 and 8 from Massart et al. (1997). Note that the behaviour of inverse.predict changed with chemCal version 0.2.1. Confidence intervals for x values obtained from calibrations with replicate measurements did not take the variation about the means into account. Please refer to the vignette for details.

-

References

- +
+
+

References

Massart, L.M, Vandenginste, B.G.M., Buydens, L.M.C., De Jong, S., Lewi, P.J., Smeyers-Verbeke, J. (1997) Handbook of Chemometrics and Qualimetrics: Part A, p. 200

+
-

Examples

-
# This is example 7 from Chapter 8 in Massart et al. (1997) -m <- lm(y ~ x, data = massart97ex1) -inverse.predict(m, 15) # 6.1 +- 4.9 -
#> $Prediction -#> [1] 6.09381 -#> -#> $`Standard Error` -#> [1] 1.767278 -#> -#> $Confidence -#> [1] 4.906751 -#> -#> $`Confidence Limits` -#> [1] 1.187059 11.000561 -#>
inverse.predict(m, 90) # 43.9 +- 4.9 -
#> $Prediction -#> [1] 43.93983 -#> -#> $`Standard Error` -#> [1] 1.767747 -#> -#> $Confidence -#> [1] 4.908053 -#> -#> $`Confidence Limits` -#> [1] 39.03178 48.84788 -#>
inverse.predict(m, rep(90,5)) # 43.9 +- 3.2 -
#> $Prediction -#> [1] 43.93983 -#> -#> $`Standard Error` -#> [1] 1.141204 -#> -#> $Confidence -#> [1] 3.168489 -#> -#> $`Confidence Limits` -#> [1] 40.77134 47.10832 -#>
-# For reproducing the results for replicate standard measurements in example 8, -# we need to do the calibration on the means when using chemCal > 0.2 -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) - -m3.means <- lm(y ~ x, w = weights, data = massart97ex3.means) - -inverse.predict(m3.means, 15, ws = 1.67) # 5.9 +- 2.5 -
#> $Prediction -#> [1] 5.865367 -#> -#> $`Standard Error` -#> [1] 0.8926109 -#> -#> $Confidence -#> [1] 2.478285 -#> -#> $`Confidence Limits` -#> [1] 3.387082 8.343652 -#>
inverse.predict(m3.means, 90, ws = 0.145) # 44.1 +- 7.9 -
#> $Prediction -#> [1] 44.06025 -#> -#> $`Standard Error` -#> [1] 2.829162 -#> -#> $Confidence -#> [1] 7.855012 -#> -#> $`Confidence Limits` -#> [1] 36.20523 51.91526 -#>
-
+
+

Examples

+
# This is example 7 from Chapter 8 in Massart et al. (1997)
+m <- lm(y ~ x, data = massart97ex1)
+inverse.predict(m, 15)        #  6.1 +- 4.9
+#> $Prediction
+#> [1] 6.09381
+#> 
+#> $`Standard Error`
+#> [1] 1.767278
+#> 
+#> $Confidence
+#> [1] 4.906751
+#> 
+#> $`Confidence Limits`
+#> [1]  1.187059 11.000561
+#> 
+inverse.predict(m, 90)        # 43.9 +- 4.9
+#> $Prediction
+#> [1] 43.93983
+#> 
+#> $`Standard Error`
+#> [1] 1.767747
+#> 
+#> $Confidence
+#> [1] 4.908053
+#> 
+#> $`Confidence Limits`
+#> [1] 39.03178 48.84788
+#> 
+inverse.predict(m, rep(90,5)) # 43.9 +- 3.2
+#> $Prediction
+#> [1] 43.93983
+#> 
+#> $`Standard Error`
+#> [1] 1.141204
+#> 
+#> $Confidence
+#> [1] 3.168489
+#> 
+#> $`Confidence Limits`
+#> [1] 40.77134 47.10832
+#> 
+
+# For reproducing the results for replicate standard measurements in example 8,
+# we need to do the calibration on the means when using chemCal > 0.2
+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)
+
+m3.means <- lm(y ~ x, w = weights, data = massart97ex3.means)
+
+inverse.predict(m3.means, 15, ws = 1.67)  # 5.9 +- 2.5
+#> $Prediction
+#> [1] 5.865367
+#> 
+#> $`Standard Error`
+#> [1] 0.8926109
+#> 
+#> $Confidence
+#> [1] 2.478285
+#> 
+#> $`Confidence Limits`
+#> [1] 3.387082 8.343652
+#> 
+inverse.predict(m3.means, 90, ws = 0.145) # 44.1 +- 7.9
+#> $Prediction
+#> [1] 44.06025
+#> 
+#> $`Standard Error`
+#> [1] 2.829162
+#> 
+#> $Confidence
+#> [1] 7.855012
+#> 
+#> $`Confidence Limits`
+#> [1] 36.20523 51.91526
+#> 
+
+
+
+
- - - + + -- cgit v1.2.1