From 08465d77a6ca5a9656ac86047c6008f1e7f3e9c7 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Thu, 31 Mar 2022 19:21:03 +0200 Subject: Fix URLs in README, convert to roxygen - The roxygen conversion was done using Rd2roxygen - Also edit _pkgdown.yml to group the reference - Use markdown bullet lists for lod and loq docs --- .Rbuildignore | 1 + DESCRIPTION | 2 +- NAMESPACE | 34 ++++--- R/calplot.R | 44 ++++++++ R/chemCal-package.R | 194 ++++++++++++++++++++++++++++++++++++ R/inverse.predict.lm.R | 77 +++++++++++++- R/lod.R | 61 ++++++++++++ R/loq.R | 50 ++++++++++ README.html | 4 +- README.md | 4 +- README.rmd | 4 +- _pkgdown.yml | 16 +++ docs/articles/chemCal.html | 2 +- docs/index.html | 6 +- docs/pkgdown.yml | 2 +- docs/reference/calplot-1.png | Bin 0 -> 71932 bytes docs/reference/calplot.html | 154 ++++++++++++++++++++++++++++ docs/reference/din32645.html | 23 ++--- docs/reference/index.html | 27 +++-- docs/reference/inverse.predict.html | 103 +++++++++++-------- docs/reference/lod.html | 101 ++++++++++--------- docs/reference/loq.html | 99 +++++++++--------- docs/reference/massart97ex1.html | 11 +- docs/reference/massart97ex3.html | 19 ++-- docs/reference/rl95_cadmium.html | 17 ++-- docs/reference/rl95_toluene.html | 18 ++-- docs/reference/utstats14.html | 21 ++-- docs/sitemap.xml | 3 + man/calplot.Rd | 73 ++++++++++++++ man/calplot.lm.Rd | 72 ------------- man/din32645.Rd | 29 +++--- man/inverse.predict.Rd | 108 +++++++++++--------- man/lod.Rd | 123 +++++++++++------------ man/loq.Rd | 110 ++++++++++---------- man/massart97ex1.Rd | 19 ++-- man/massart97ex3.Rd | 27 ++--- man/rl95_cadmium.Rd | 21 ++-- man/rl95_toluene.Rd | 22 ++-- man/utstats14.Rd | 23 +++-- 39 files changed, 1192 insertions(+), 532 deletions(-) create mode 100644 R/chemCal-package.R create mode 100644 docs/reference/calplot-1.png create mode 100644 docs/reference/calplot.html create mode 100644 man/calplot.Rd delete mode 100644 man/calplot.lm.Rd diff --git a/.Rbuildignore b/.Rbuildignore index 3115cf6..f0b4d3d 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -4,6 +4,7 @@ check.log$ chemCal_.*.tar.gz docs _pkgdown.yml +README.rmd README.html .travis.yml experimental diff --git a/DESCRIPTION b/DESCRIPTION index cbf3c38..806d3d5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -20,4 +20,4 @@ VignetteBuilder: knitr Encoding: UTF-8 BugReports: https://github.com/jranke/chemCal/issues URL: https://pkgdown.jrwb.de/chemCal/, https://cgit.jrwb.de/chemCal/about -RoxygenNote: 6.1.1 +RoxygenNote: 7.1.2 diff --git a/NAMESPACE b/NAMESPACE index 7ca061a..5f98a2a 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,14 +1,22 @@ -# Export all names -exportPattern(".") -S3method(calplot, default) -S3method(calplot, lm) -S3method(lod, default) -S3method(lod, lm) -S3method(loq, default) -S3method(loq, lm) -S3method(inverse.predict, default) -S3method(inverse.predict, lm) -S3method(inverse.predict, rlm) +# Generated by roxygen2: do not edit by hand -importFrom("graphics", "legend", "matlines", "plot", "points") -importFrom("stats", "optimize", "predict", "qt") +S3method(calplot,default) +S3method(calplot,lm) +S3method(inverse.predict,default) +S3method(inverse.predict,lm) +S3method(inverse.predict,rlm) +S3method(lod,default) +S3method(lod,lm) +S3method(loq,default) +S3method(loq,lm) +export(calplot) +export(inverse.predict) +export(lod) +export(loq) +importFrom(graphics,legend) +importFrom(graphics,matlines) +importFrom(graphics,plot) +importFrom(graphics,points) +importFrom(stats,optimize) +importFrom(stats,predict) +importFrom(stats,qt) diff --git a/R/calplot.R b/R/calplot.R index fd49a54..3c227d4 100644 --- a/R/calplot.R +++ b/R/calplot.R @@ -1,3 +1,45 @@ +#' Plot calibration graphs from univariate linear models +#' +#' Produce graphics of calibration data, the fitted model as well as +#' confidence, and, for unweighted regression, prediction bands. +#' +#' @aliases calplot calplot.default calplot.lm +#' @param object A univariate model object of class \code{\link{lm}} or +#' \code{\link[MASS:rlm]{rlm}} with model formula \code{y ~ x} or \code{y ~ x - +#' 1}. +#' @param xlim The limits of the plot on the x axis. +#' @param ylim The limits of the plot on the y axis. +#' @param xlab The label of the x axis. +#' @param ylab The label of the y axis. +#' @param legend_x An optional numeric value for adjusting the x coordinate of +#' the legend. +#' @param alpha The error tolerance level for the confidence and prediction +#' bands. Note that this includes both tails of the Gaussian distribution, +#' unlike the alpha and beta parameters used in \code{\link{lod}} (see note +#' below). +#' @param varfunc The variance function for generating the weights in the +#' model. Currently, this argument is ignored (see note below). +#' @return A plot of the calibration data, of your fitted model as well as +#' lines showing the confidence limits. Prediction limits are only shown for +#' models from unweighted regression. +#' @note Prediction bands for models from weighted linear regression require +#' weights for the data, for which responses should be predicted. Prediction +#' intervals using weights e.g. from a variance function are currently not +#' supported by the internally used function \code{\link{predict.lm}}, +#' therefore, \code{calplot} does not draw prediction bands for such models. +#' +#' It is possible to compare the \code{\link{calplot}} prediction bands with +#' the \code{\link{lod}} values if the \code{lod()} alpha and beta parameters +#' are half the value of the \code{calplot()} alpha parameter. +#' @author Johannes Ranke +#' @importFrom graphics legend matlines plot points +#' @examples +#' +#' data(massart97ex3) +#' m <- lm(y ~ x, data = massart97ex3) +#' calplot(m) +#' +#' @export calplot calplot <- function(object, xlim = c("auto", "auto"), ylim = c("auto", "auto"), xlab = "Concentration", ylab = "Response", @@ -7,6 +49,7 @@ calplot <- function(object, UseMethod("calplot") } +#' @export calplot.default <- function(object, xlim = c("auto","auto"), ylim = c("auto","auto"), xlab = "Concentration", ylab = "Response", @@ -16,6 +59,7 @@ calplot.default <- function(object, stop("Calibration plots only implemented for univariate lm objects.") } +#' @export calplot.lm <- function(object, xlim = c("auto","auto"), ylim = c("auto","auto"), xlab = "Concentration", ylab = "Response", diff --git a/R/chemCal-package.R b/R/chemCal-package.R new file mode 100644 index 0000000..8cc8c76 --- /dev/null +++ b/R/chemCal-package.R @@ -0,0 +1,194 @@ +#' Calibration data from DIN 32645 +#' +#' Sample dataset to test the package. +#' +#' +#' @name din32645 +#' @docType data +#' @format A dataframe containing 10 rows of x and y values. +#' @references DIN 32645 (equivalent to ISO 11843), Beuth Verlag, Berlin, 1994 +#' +#' Dintest. Plugin for MS Excel for evaluations of calibration data. Written by +#' Georg Schmitt, University of Heidelberg. Formerly available from the Website +#' of the University of Heidelberg. +#' +#' Currie, L. A. (1997) Nomenclature in evaluation of analytical methods +#' including detection and quantification capabilities (IUPAC Recommendations +#' 1995). Analytica Chimica Acta 391, 105 - 126. +#' @keywords datasets +#' @examples +#' +#' m <- lm(y ~ x, data = din32645) +#' calplot(m) +#' +#' ## Prediction of x with confidence interval +#' prediction <- inverse.predict(m, 3500, alpha = 0.01) +#' +#' # This should give 0.07434 according to test data from Dintest, which +#' # was collected from Procontrol 3.1 (isomehr GmbH) in this case +#' round(prediction$Confidence, 5) +#' +#' ## Critical value: +#' crit <- lod(m, alpha = 0.01, beta = 0.5) +#' +#' # According to DIN 32645, we should get 0.07 for the critical value +#' # (decision limit, "Nachweisgrenze") +#' round(crit$x, 2) +#' # and according to Dintest test data, we should get 0.0698 from +#' round(crit$x, 4) +#' +#' ## Limit of detection (smallest detectable value given alpha and beta) +#' # In German, the smallest detectable value is the "Erfassungsgrenze", and we +#' # should get 0.14 according to DIN, which we achieve by using the method +#' # described in it: +#' lod.din <- lod(m, alpha = 0.01, beta = 0.01, method = "din") +#' round(lod.din$x, 2) +#' +#' ## Limit of quantification +#' # This accords to the test data coming with the test data from Dintest again, +#' # except for the last digits of the value cited for Procontrol 3.1 (0.2121) +#' loq <- loq(m, alpha = 0.01) +#' round(loq$x, 4) +#' +#' # A similar value is obtained using the approximation +#' # LQ = 3.04 * LC (Currie 1999, p. 120) +#' 3.04 * lod(m, alpha = 0.01, beta = 0.5)$x +#' +NULL + + + + + +#' Calibration data from Massart et al. (1997), example 1 +#' +#' Sample dataset from p. 175 to test the package. +#' +#' +#' @name massart97ex1 +#' @docType data +#' @format A dataframe containing 6 observations of x and y data. +#' @source 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, Chapter 8. +#' @keywords datasets +NULL + + + + + +#' Calibration data from Massart et al. (1997), example 3 +#' +#' Sample dataset from p. 188 to test the package. +#' +#' +#' @name massart97ex3 +#' @docType data +#' @format A dataframe containing 6 levels of x values with 5 observations of y +#' for each level. +#' @source 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, Chapter 8. +#' @keywords datasets +#' @examples +#' +#' # 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) +#' +#' # The following concords with the book p. 200 +#' inverse.predict(m3.means, 15, ws = 1.67) # 5.9 +- 2.5 +#' inverse.predict(m3.means, 90, ws = 0.145) # 44.1 +- 7.9 +#' +#' # The LOD is only calculated for models from unweighted regression +#' # with this version of chemCal +#' m0 <- lm(y ~ x, data = massart97ex3) +#' lod(m0) +#' +#' # Limit of quantification from unweighted regression +#' loq(m0) +#' +#' # For calculating the limit of quantification from a model from weighted +#' # regression, we need to supply weights, internally used for inverse.predict +#' # If we are not using a variance function, we can use the weight from +#' # the above example as a first approximation (x = 15 is close to our +#' # loq approx 14 from above). +#' loq(m3.means, w.loq = 1.67) +#' # 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. +#' +NULL + + + + + +#' Cadmium concentrations measured by AAS as reported by Rocke and Lorenzato +#' (1995) +#' +#' Dataset reproduced from Table 1 in Rocke and Lorenzato (1995). +#' +#' +#' @name rl95_cadmium +#' @docType data +#' @format A dataframe containing four replicate observations for each of the +#' six calibration standards. +#' @source Rocke, David M. und Lorenzato, Stefan (1995) A two-component model +#' for measurement error in analytical chemistry. Technometrics 37(2), 176-184. +#' @keywords datasets +NULL + + + + + +#' Toluene amounts measured by GC/MS as reported by Rocke and Lorenzato (1995) +#' +#' Dataset reproduced from Table 4 in Rocke and Lorenzato (1995). The toluene +#' amount in the calibration samples is given in picograms per 100 µL. +#' Presumably this is the volume that was injected into the instrument. +#' +#' +#' @name rl95_toluene +#' @docType data +#' @format A dataframe containing four replicate observations for each of the +#' six calibration standards. +#' @source Rocke, David M. und Lorenzato, Stefan (1995) A two-component model +#' for measurement error in analytical chemistry. Technometrics 37(2), 176-184. +#' @keywords datasets +NULL + + + + + +#' Example data for calibration with replicates from University of Toronto +#' +#' Dataset read into R from +#' \url{https://sites.chem.utoronto.ca/chemistry/coursenotes/analsci/stats/files/example14.xls}. +#' +#' +#' @name utstats14 +#' @docType data +#' @format A tibble containing three replicate observations of the response for +#' five calibration concentrations. +#' @source David Stone and Jon Ellis (2011) Statistics in Analytical Chemistry. +#' Tutorial website maintained by the Departments of Chemistry, University of +#' Toronto. +#' \url{https://sites.chem.utoronto.ca/chemistry/coursenotes/analsci/stats/index.html} +#' @keywords datasets +NULL + + + diff --git a/R/inverse.predict.lm.R b/R/inverse.predict.lm.R index 77d548f..031f9d4 100644 --- a/R/inverse.predict.lm.R +++ b/R/inverse.predict.lm.R @@ -1,19 +1,87 @@ -# This is an implementation of Equation (8.28) in the Handbook of Chemometrics -# and Qualimetrics, Part A, Massart et al (1997), page 200, validated with -# Example 8 on the same page, extended as specified in the package vignette - +#' Predict x from y for a linear calibration +#' +#' This function predicts x values using a univariate linear model that has +#' been generated for the purpose of calibrating a measurement method. +#' Prediction intervals are given at the specified confidence level. The +#' calculation method was taken from Massart et al. (1997). In particular, +#' Equations 8.26 and 8.28 were combined in order to yield a general treatment +#' of inverse prediction for univariate linear models, taking into account +#' weights that have been used to create the linear model, and at the same time +#' providing the possibility to specify a precision in sample measurements +#' differing from the precision in standard samples used for the calibration. +#' This is elaborated in the package vignette. +#' +#' This is an implementation of Equation (8.28) in the Handbook of Chemometrics +#' and Qualimetrics, Part A, Massart et al (1997), page 200, validated with +#' Example 8 on the same page, extended as specified in the package vignette +#' +#' @aliases inverse.predict inverse.predict.lm inverse.predict.rlm +#' inverse.predict.default +#' @param object A univariate model object of class \code{\link{lm}} or +#' \code{\link[MASS:rlm]{rlm}} with model formula \code{y ~ x} or \code{y ~ x - +#' 1}. +#' @param newdata A vector of observed y values for one sample. +#' @param \dots Placeholder for further arguments that might be needed by +#' future implementations. +#' @param ws The weight attributed to the sample. This argument is obligatory +#' if \code{object} has weights. +#' @param alpha The error tolerance level for the confidence interval to be +#' reported. +#' @param 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 \code{ws}, if applicable. This means that \code{var.s} overrides +#' \code{ws}. +#' @return A list containing the predicted x value, its standard error and a +#' confidence interval. +#' @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 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 +#' @importFrom stats optimize predict qt +#' @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 +#' inverse.predict(m, 90) # 43.9 +- 4.9 +#' inverse.predict(m, rep(90,5)) # 43.9 +- 3.2 +#' +#' # 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 +#' inverse.predict(m3.means, 90, ws = 0.145) # 44.1 +- 7.9 +#' +#' +#' @export inverse.predict <- function(object, newdata, ..., ws = "auto", alpha = 0.05, var.s = "auto") { UseMethod("inverse.predict") } +#' @export inverse.predict.default <- function(object, newdata, ..., ws = "auto", alpha = 0.05, var.s = "auto") { stop("Inverse prediction only implemented for univariate lm objects.") } +#' @export inverse.predict.lm <- function(object, newdata, ..., ws = "auto", alpha = 0.05, var.s = "auto") { @@ -31,6 +99,7 @@ inverse.predict.lm <- function(object, newdata, ..., ws = ws, alpha = alpha, var.s = var.s, w = w, xname = xname, yname = yname) } +#' @export inverse.predict.rlm <- function(object, newdata, ..., ws = "auto", alpha = 0.05, var.s = "auto") { diff --git a/R/lod.R b/R/lod.R index bccdf3e..bf6e928 100644 --- a/R/lod.R +++ b/R/lod.R @@ -1,13 +1,74 @@ +#' Estimate a limit of detection (LOD) +#' +#' The decision limit (German: Nachweisgrenze) is defined as the signal or +#' analyte concentration that is significantly different from the blank signal +#' with a first order error alpha (one-sided significance test). The detection +#' limit, or more precise, the minimum detectable value (German: +#' Erfassungsgrenze), is then defined as the signal or analyte concentration +#' where the probability that the signal is not detected although the analyte +#' is present (type II or false negative error), is beta (also a one-sided +#' significance test). +#' +#' @aliases lod lod.lm lod.rlm lod.default +#' @param object A univariate model object of class \code{\link{lm}} or +#' \code{\link[MASS:rlm]{rlm}} with model formula \code{y ~ x} or \code{y ~ x - +#' 1}, optionally from a weighted regression. +#' @param \dots Placeholder for further arguments that might be needed by +#' future implementations. +#' @param alpha The error tolerance for the decision limit (critical value). +#' @param beta The error tolerance beta for the detection limit. +#' @param method The \dQuote{default} method uses a prediction interval at the +#' LOD for the estimation of the LOD, which obviously requires iteration. This +#' is described for example in Massart, p. 432 ff. The \dQuote{din} method +#' uses the prediction interval at x = 0 as an approximation. +#' @param tol When the \dQuote{default} method is used, the default tolerance +#' for the LOD on the x scale is the value of the smallest non-zero standard +#' divided by 1000. Can be set to a numeric value to override this. +#' @return A list containig the corresponding x and y values of the estimated +#' limit of detection of a model used for calibration. +#' @note +#' * The default values for alpha and beta are the ones recommended by IUPAC. +#' * The estimation of the LOD in terms of the analyte amount/concentration xD +#' from the LOD in the signal domain SD is done by simply inverting the +#' calibration function (i.e. assuming a known calibration function). +#' * The calculation of a LOD from weighted calibration models requires a +#' weights argument for the internally used \code{\link{predict.lm}} +#' function, which is currently not supported in R. +#' @seealso Examples for \code{\link{din32645}} +#' @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, Chapter 13.7.8 +#' +#' J. Inczedy, T. Lengyel, and A.M. Ure (2002) International Union of Pure and +#' Applied Chemistry Compendium of Analytical Nomenclature: Definitive Rules. +#' Web edition. +#' +#' Currie, L. A. (1997) Nomenclature in evaluation of analytical methods +#' including detection and quantification capabilities (IUPAC Recommendations +#' 1995). Analytica Chimica Acta 391, 105 - 126. +#' @importFrom stats optimize predict +#' @examples +#' +#' m <- lm(y ~ x, data = din32645) +#' lod(m) +#' +#' # The critical value (decision limit, German Nachweisgrenze) can be obtained +#' # by using beta = 0.5: +#' lod(m, alpha = 0.01, beta = 0.5) +#' +#' @export lod <- function(object, ..., alpha = 0.05, beta = 0.05, method = "default", tol = "default") { UseMethod("lod") } +#' @export lod.default <- function(object, ..., alpha = 0.05, beta = 0.05, method = "default", tol = "default") { stop("lod is only implemented for univariate lm objects.") } +#' @export lod.lm <- function(object, ..., alpha = 0.05, beta = 0.05, method = "default", tol = "default") { if (length(object$weights) > 0) { diff --git a/R/loq.R b/R/loq.R index 26d6a53..a4dbcfe 100644 --- a/R/loq.R +++ b/R/loq.R @@ -1,15 +1,65 @@ +#' Estimate a limit of quantification (LOQ) +#' +#' The limit of quantification is the x value, where the relative error of the +#' quantification given the calibration model reaches a prespecified value 1/k. +#' Thus, it is the solution of the equation \deqn{L = k c(L)}{L = k * c(L)} +#' where c(L) is half of the length of the confidence interval at the limit L +#' (DIN 32645, equivalent to ISO 11843). c(L) is internally estimated by +#' \code{\link{inverse.predict}}, and L is obtained by iteration. +#' +#' @aliases loq loq.lm loq.rlm loq.default +#' @param object A univariate model object of class \code{\link{lm}} or +#' \code{\link[MASS:rlm]{rlm}} with model formula \code{y ~ x} or \code{y ~ x - +#' 1}, optionally from a weighted regression. If weights are specified in the +#' model, either \code{w.loq} or \code{var.loq} have to be specified. +#' @param alpha The error tolerance for the prediction of x values in the +#' calculation. +#' @param \dots Placeholder for further arguments that might be needed by +#' future implementations. +#' @param k The inverse of the maximum relative error tolerated at the desired +#' LOQ. +#' @param n The number of replicate measurements for which the LOQ should be +#' specified. +#' @param w.loq The weight that should be attributed to the LOQ. Defaults to +#' one for unweighted regression, and to the mean of the weights for weighted +#' regression. See \code{\link{massart97ex3}} for an example how to take +#' advantage of knowledge about the variance function. +#' @param var.loq The approximate variance at the LOQ. The default value is +#' calculated from the model. +#' @param tol The default tolerance for the LOQ on the x scale is the value of +#' the smallest non-zero standard divided by 1000. Can be set to a numeric +#' value to override this. +#' @return The estimated limit of quantification for a model used for +#' calibration. +#' @note +#' * IUPAC recommends to base the LOQ on the standard deviation of the +#' signal where x = 0. +#' * The calculation of a LOQ based on weighted regression is non-standard and +#' therefore not tested. Feedback is welcome. +#' @seealso Examples for \code{\link{din32645}} +#' @examples +#' +#' m <- lm(y ~ x, data = massart97ex1) +#' loq(m) +#' +#' # We can get better by using replicate measurements +#' loq(m, n = 3) +#' +#' @export loq <- function(object, ..., alpha = 0.05, k = 3, n = 1, w.loq = "auto", var.loq = "auto", tol = "default") { UseMethod("loq") } +#' @export loq.default <- function(object, ..., alpha = 0.05, k = 3, n = 1, w.loq = "auto", var.loq = "auto", tol = "default") { stop("loq is only implemented for univariate lm objects.") } +#' @export loq.lm <- function(object, ..., alpha = 0.05, k = 3, n = 1, w.loq = "auto", var.loq = "auto", tol = "default") { diff --git a/README.html b/README.html index 47ce3a1..3bb6cbd 100644 --- a/README.html +++ b/README.html @@ -611,7 +611,7 @@ body {

Overview

chemCal is an R package providing some basic functions for conveniently working with linear calibration curves with one explanatory variable.

Installation

-

From within R, get the official chemCal release using

+

From within R, get the official chemCal release using

install.packages("chemCal")

Usage

chemCal works with univariate linear models of class lm. Working with one of the datasets coming with chemCal, we can produce a calibration plot using the calplot function:

@@ -671,7 +671,7 @@ body { #> $`Confidence Limits` #> [1] 42.30749 45.57217

Reference

-

You can use the R help system to view documentation, or you can have a look at the online documentation.

+

You can use the R help system to view documentation, or you can have a look at the online documentation.

diff --git a/README.md b/README.md index 2ad063e..b7b4db6 100644 --- a/README.md +++ b/README.md @@ -139,5 +139,5 @@ inverse.predict(m0, c(91, 89, 87, 93, 90)) You can use the R help system to view documentation, or you can have a look at the [online documentation][pd-site]. -[r-project]: https://r-project.org -[pd-site]: https://pkgdown.jrwb.de/chemCal +[r-project]: https://www.r-project.org/ +[pd-site]: https://pkgdown.jrwb.de/chemCal/ diff --git a/README.rmd b/README.rmd index 6b027f4..361b4c0 100644 --- a/README.rmd +++ b/README.rmd @@ -99,5 +99,5 @@ inverse.predict(m0, c(91, 89, 87, 93, 90)) You can use the R help system to view documentation, or you can have a look at the [online documentation][pd-site]. -[r-project]: https://r-project.org -[pd-site]: https://pkgdown.jrwb.de/chemCal +[r-project]: https://www.r-project.org/ +[pd-site]: https://pkgdown.jrwb.de/chemCal/ diff --git a/_pkgdown.yml b/_pkgdown.yml index f5eeff8..7942085 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -2,3 +2,19 @@ title: chemCal template: bootswatch: spacelab + +reference: + - title: Main functions + contents: + - calplot + - lod + - loq + - inverse.predict + - title: Datasets + contents: + - din32645 + - massart97ex1 + - massart97ex3 + - rl95_cadmium + - rl95_toluene + - utstats14 diff --git a/docs/articles/chemCal.html b/docs/articles/chemCal.html index 4e145bf..bbcc568 100644 --- a/docs/articles/chemCal.html +++ b/docs/articles/chemCal.html @@ -98,7 +98,7 @@
 library(chemCal)
 m0 <- lm(y ~ x, data = massart97ex3)
-calplot(m0)
+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:

diff --git a/docs/index.html b/docs/index.html
index 4019484..7882a73 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -87,7 +87,7 @@
 

Installation

-

From within R, get the official chemCal release using

+

From within R, get the official chemCal release using

 install.packages("chemCal")
@@ -101,7 +101,7 @@
 library(chemCal)
 m0 <- lm(y ~ x, data = massart97ex3)
-calplot(m0)
+calplot(m0)

@@ -169,7 +169,7 @@

Reference

-

You can use the R help system to view documentation, or you can have a look at the online documentation.

+

You can use the R help system to view documentation, or you can have a look at the online documentation.

diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index dc4cced..3c1d018 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -3,5 +3,5 @@ pkgdown: 2.0.2 pkgdown_sha: ~ articles: chemCal: chemCal.html -last_built: 2022-03-31T16:32Z +last_built: 2022-03-31T17:56Z diff --git a/docs/reference/calplot-1.png b/docs/reference/calplot-1.png new file mode 100644 index 0000000..c2deae8 Binary files /dev/null and b/docs/reference/calplot-1.png differ diff --git a/docs/reference/calplot.html b/docs/reference/calplot.html new file mode 100644 index 0000000..88321b1 --- /dev/null +++ b/docs/reference/calplot.html @@ -0,0 +1,154 @@ + +Plot calibration graphs from univariate linear models — calplot • chemCal + + +
+
+ + + +
+
+ + +
+

Produce graphics of calibration data, the fitted model as well as +confidence, and, for unweighted regression, prediction bands.

+
+ +
+
calplot(
+  object,
+  xlim = c("auto", "auto"),
+  ylim = c("auto", "auto"),
+  xlab = "Concentration",
+  ylab = "Response",
+  legend_x = "auto",
+  alpha = 0.05,
+  varfunc = NULL
+)
+
+ +
+

Arguments

+
object
+

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

+
xlim
+

The limits of the plot on the x axis.

+
ylim
+

The limits of the plot on the y axis.

+
xlab
+

The label of the x axis.

+
ylab
+

The label of the y axis.

+
legend_x
+

An optional numeric value for adjusting the x coordinate of +the legend.

+
alpha
+

The error tolerance level for the confidence and prediction +bands. Note that this includes both tails of the Gaussian distribution, +unlike the alpha and beta parameters used in lod (see note +below).

+
varfunc
+

The variance function for generating the weights in the +model. Currently, this argument is ignored (see note below).

+
+
+

Value

+

A plot of the calibration data, of your fitted model as well as +lines showing the confidence limits. Prediction limits are only shown for +models from unweighted regression.

+
+
+

Note

+

Prediction bands for models from weighted linear regression require +weights for the data, for which responses should be predicted. Prediction +intervals using weights e.g. from a variance function are currently not +supported by the internally used function predict.lm, +therefore, calplot does not draw prediction bands for such models.

+

It is possible to compare the calplot prediction bands with +the lod values if the lod() alpha and beta parameters +are half the value of the calplot() alpha parameter.

+
+
+

Author

+

Johannes Ranke

+
+ +
+

Examples

+

+data(massart97ex3)
+m <- lm(y ~ x, data = massart97ex3)
+calplot(m)
+
+
+
+
+
+ +
+ + +
+ +
+

Site built with pkgdown 2.0.2.

+
+ +
+ + + + + + + + diff --git a/docs/reference/din32645.html b/docs/reference/din32645.html index 1c02f36..ba6246a 100644 --- a/docs/reference/din32645.html +++ b/docs/reference/din32645.html @@ -47,7 +47,7 @@
@@ -55,9 +55,6 @@

Sample dataset to test the package.

-
-
data(din32645)
-

Format

@@ -66,18 +63,19 @@

References

DIN 32645 (equivalent to ISO 11843), Beuth Verlag, Berlin, 1994

-

Dintest. Plugin for MS Excel for evaluations of calibration data. Written - by Georg Schmitt, University of Heidelberg. Formerly available from - the Website of the University of Heidelberg.

-

Currie, L. A. (1997) Nomenclature in evaluation of analytical methods including - detection and quantification capabilities (IUPAC Recommendations 1995). - Analytica Chimica Acta 391, 105 - 126.

+

Dintest. Plugin for MS Excel for evaluations of calibration data. Written by +Georg Schmitt, University of Heidelberg. Formerly available from the Website +of the University of Heidelberg.

+

Currie, L. A. (1997) Nomenclature in evaluation of analytical methods +including detection and quantification capabilities (IUPAC Recommendations +1995). Analytica Chimica Acta 391, 105 - 126.

Examples

-
m <- lm(y ~ x, data = din32645)
-calplot(m)
+    

+m <- lm(y ~ x, data = din32645)
+calplot(m)
 
 
 ## Prediction of x with confidence interval
@@ -118,6 +116,7 @@
 # LQ = 3.04 * LC (Currie 1999, p. 120)
 3.04 * lod(m, alpha = 0.01, beta = 0.5)$x
 #> [1] 0.2122306
+
 
diff --git a/docs/reference/index.html b/docs/reference/index.html index 3685007..9812256 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -50,21 +50,13 @@
- - - - @@ -73,6 +65,18 @@

loq()

+ + + + + @@ -84,7 +88,8 @@ - + diff --git a/docs/reference/inverse.predict.html b/docs/reference/inverse.predict.html index cb9fe98..6fe081e 100644 --- a/docs/reference/inverse.predict.html +++ b/docs/reference/inverse.predict.html @@ -1,14 +1,14 @@ -Predict x from y for a linear calibration — inverse.predict • chemCalPredict x from y for a linear calibration — inverse.predict • chemCal @@ -56,73 +56,87 @@
-

This function predicts x values using a univariate linear model that has been - generated for the purpose of calibrating a measurement method. Prediction - intervals are given at the specified confidence level. - The calculation method was taken from Massart et al. (1997). In particular, - Equations 8.26 and 8.28 were combined in order to yield a general treatment - of inverse prediction for univariate linear models, taking into account - weights that have been used to create the linear model, and at the same - time providing the possibility to specify a precision in sample measurements - differing from the precision in standard samples used for the calibration. - This is elaborated in the package vignette.

+

This function predicts x values using a univariate linear model that has +been generated for the purpose of calibrating a measurement method. +Prediction intervals are given at the specified confidence level. The +calculation method was taken from Massart et al. (1997). In particular, +Equations 8.26 and 8.28 were combined in order to yield a general treatment +of inverse prediction for univariate linear models, taking into account +weights that have been used to create the linear model, and at the same time +providing the possibility to specify a precision in sample measurements +differing from the precision in standard samples used for the calibration. +This is elaborated in the package vignette.

-
inverse.predict(object, newdata, ...,
-  ws, alpha=0.05, var.s = "auto")
+
inverse.predict(
+  object,
+  newdata,
+  ...,
+  ws = "auto",
+  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.

+

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.

+

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.

+if object has weights.

alpha
-

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

+

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.

+

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

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

+confidence interval.

+
+
+

Details

+

This is an implementation of Equation (8.28) in the Handbook of Chemometrics +and Qualimetrics, Part A, Massart et al (1997), page 200, validated with +Example 8 on the same page, extended as specified in the package vignette

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.

+

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

-

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

+

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)
+    

+# 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
@@ -204,6 +218,7 @@
 #> [1] 36.20523 51.91526
 #> 
 
+
 
diff --git a/docs/reference/lod.html b/docs/reference/lod.html index a2d66ce..1fbae76 100644 --- a/docs/reference/lod.html +++ b/docs/reference/lod.html @@ -1,12 +1,12 @@ Estimate a limit of detection (LOD) — lod • chemCal @@ -54,76 +54,81 @@

The decision limit (German: Nachweisgrenze) is defined as the signal or - analyte concentration that is significantly different from the blank signal - with a first order error alpha (one-sided significance test). - The detection limit, or more precise, the minimum detectable value - (German: Erfassungsgrenze), is then defined as the signal or analyte - concentration where the probability that the signal is not detected although - the analyte is present (type II or false negative error), is beta (also a - one-sided significance test).

+analyte concentration that is significantly different from the blank signal +with a first order error alpha (one-sided significance test). The detection +limit, or more precise, the minimum detectable value (German: +Erfassungsgrenze), is then defined as the signal or analyte concentration +where the probability that the signal is not detected although the analyte +is present (type II or false negative error), is beta (also a one-sided +significance test).

-
lod(object, ..., alpha = 0.05, beta = 0.05, method = "default", tol = "default")
+
lod(
+  object,
+  ...,
+  alpha = 0.05,
+  beta = 0.05,
+  method = "default",
+  tol = "default"
+)

Arguments

object
-

A univariate model object of class lm or - rlm - with model formula y ~ x or y ~ x - 1, - optionally from a weighted regression.

+

A univariate model object of class lm or +rlm with model formula y ~ x or y ~ x - +1, optionally from a weighted regression.

...
-

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

+

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

alpha

The error tolerance for the decision limit (critical value).

beta

The error tolerance beta for the detection limit.

method
-

The “default” method uses a prediction interval at the LOD - for the estimation of the LOD, which obviously requires - iteration. This is described for example in Massart, p. 432 ff. - The “din” method uses the prediction interval at - x = 0 as an approximation.

+

The “default” method uses a prediction interval at the +LOD for the estimation of the LOD, which obviously requires iteration. This +is described for example in Massart, p. 432 ff. The “din” method +uses the prediction interval at x = 0 as an approximation.

tol

When the “default” method is used, the default tolerance - for the LOD on the x scale is the value of the smallest non-zero standard - divided by 1000. Can be set to a numeric value to override this.

+for the LOD on the x scale is the value of the smallest non-zero standard +divided by 1000. Can be set to a numeric value to override this.

Value

-

A list containig the corresponding x and y values of the estimated limit of - detection of a model used for calibration.

+

A list containig the corresponding x and y values of the estimated +limit of detection of a model used for calibration.

Note

-

- The default values for alpha and beta are the ones recommended by IUPAC. - - The estimation of the LOD in terms of the analyte amount/concentration - xD from the LOD in the signal domain SD is done by simply inverting the - calibration function (i.e. assuming a known calibration function). - - The calculation of a LOD from weighted calibration models requires - a weights argument for the internally used predict.lm - function, which is currently not supported in R.

+

* The default values for alpha and beta are the ones recommended by IUPAC. +* The estimation of the LOD in terms of the analyte amount/concentration xD +from the LOD in the signal domain SD is done by simply inverting the +calibration function (i.e. assuming a known calibration function). +* The calculation of a LOD from weighted calibration models requires a +weights argument for the internally used predict.lm +function, which is currently not supported in R.

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, - Chapter 13.7.8

+

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, Chapter 13.7.8

J. Inczedy, T. Lengyel, and A.M. Ure (2002) International Union of Pure and - Applied Chemistry Compendium of Analytical Nomenclature: Definitive Rules. - Web edition.

-

Currie, L. A. (1997) Nomenclature in evaluation of analytical methods including - detection and quantification capabilities (IUPAC Recommendations 1995). - Analytica Chimica Acta 391, 105 - 126.

+Applied Chemistry Compendium of Analytical Nomenclature: Definitive Rules. +Web edition.

+

Currie, L. A. (1997) Nomenclature in evaluation of analytical methods +including detection and quantification capabilities (IUPAC Recommendations +1995). Analytica Chimica Acta 391, 105 - 126.

See also

@@ -132,7 +137,8 @@

Examples

-
m <- lm(y ~ x, data = din32645)
+    

+m <- lm(y ~ x, data = din32645)
 lod(m) 
 #> $x
 #> [1] 0.08655484
@@ -150,6 +156,7 @@
 #> $y
 #> [1] 3155.393
 #> 
+
 
diff --git a/docs/reference/loq.html b/docs/reference/loq.html index 0960251..86c8f43 100644 --- a/docs/reference/loq.html +++ b/docs/reference/loq.html @@ -1,11 +1,10 @@ -Estimate a limit of quantification (LOQ) — loq • chemCalEstimate a limit of quantification (LOQ) — loq • chemCal @@ -53,69 +52,75 @@
-

The limit of quantification is the x value, where the relative error - of the quantification given the calibration model reaches a prespecified - value 1/k. Thus, it is the solution of the equation - $$L = k c(L)$$ - where c(L) is half of the length of the confidence interval at the limit L - (DIN 32645, equivalent to ISO 11843). c(L) is internally estimated by - inverse.predict, and L is obtained by iteration.

+

The limit of quantification is the x value, where the relative error of the +quantification given the calibration model reaches a prespecified value 1/k. +Thus, it is the solution of the equation $$L = k c(L)$$ +where c(L) is half of the length of the confidence interval at the limit L +(DIN 32645, equivalent to ISO 11843). c(L) is internally estimated by +inverse.predict, and L is obtained by iteration.

-
loq(object, ..., alpha = 0.05, k = 3, n = 1, w.loq = "auto",
-    var.loq = "auto", tol = "default")
+
loq(
+  object,
+  ...,
+  alpha = 0.05,
+  k = 3,
+  n = 1,
+  w.loq = "auto",
+  var.loq = "auto",
+  tol = "default"
+)

Arguments

object
-

A univariate model object of class lm or - rlm - with model formula y ~ x or y ~ x - 1, - optionally from a weighted regression. If weights are specified - in the model, either w.loq or var.loq have to - be specified.

-
alpha
-

The error tolerance for the prediction of x values in the calculation.

+

A univariate model object of class lm or +rlm with model formula y ~ x or y ~ x - +1, optionally from a weighted regression. If weights are specified in the +model, either w.loq or var.loq have to be specified.

...
-

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

+

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

+
alpha
+

The error tolerance for the prediction of x values in the +calculation.

k
-

The inverse of the maximum relative error tolerated at the - desired LOQ.

+

The inverse of the maximum relative error tolerated at the desired +LOQ.

n

The number of replicate measurements for which the LOQ should be - specified.

+specified.

w.loq
-

The weight that should be attributed to the LOQ. Defaults - to one for unweighted regression, and to the mean of the weights - for weighted regression. See massart97ex3 for - an example how to take advantage of knowledge about the - variance function.

+

The weight that should be attributed to the LOQ. Defaults to +one for unweighted regression, and to the mean of the weights for weighted +regression. See massart97ex3 for an example how to take +advantage of knowledge about the variance function.

var.loq
-

The approximate variance at the LOQ. The default value is - calculated from the model.

+

The approximate variance at the LOQ. The default value is +calculated from the model.

tol
-

The default tolerance for the LOQ on the x scale is the value of the - smallest non-zero standard divided by 1000. Can be set to a - numeric value to override this.

+

The default tolerance for the LOQ on the x scale is the value of +the smallest non-zero standard divided by 1000. Can be set to a numeric +value to override this.

Value

-

The estimated limit of quantification for a model used for calibration.

+

The estimated limit of quantification for a model used for +calibration.

Note

-

- IUPAC recommends to base the LOQ on the standard deviation of the signal - where x = 0. - - The calculation of a LOQ based on weighted regression is non-standard - and therefore not tested. Feedback is welcome.

+

* IUPAC recommends to base the LOQ on the standard deviation of the +signal where x = 0. +* The calculation of a LOQ based on weighted regression is non-standard and +therefore not tested. Feedback is welcome.

See also

@@ -124,7 +129,8 @@

Examples

-
m <- lm(y ~ x, data = massart97ex1)
+    

+m <- lm(y ~ x, data = massart97ex1)
 loq(m)
 #> $x
 #> [1] 13.97764
@@ -141,6 +147,7 @@
 #> $y
 #> [1] 22.68539
 #> 
+
 
diff --git a/docs/reference/massart97ex1.html b/docs/reference/massart97ex1.html index e5dd85a..a02dfe0 100644 --- a/docs/reference/massart97ex1.html +++ b/docs/reference/massart97ex1.html @@ -47,7 +47,7 @@
@@ -55,9 +55,6 @@

Sample dataset from p. 175 to test the package.

-
-
data(massart97ex1)
-

Format

@@ -65,9 +62,9 @@

Source

-

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, - Chapter 8.

+

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, Chapter 8.

diff --git a/docs/reference/massart97ex3.html b/docs/reference/massart97ex3.html index 4196882..5cbdbd6 100644 --- a/docs/reference/massart97ex3.html +++ b/docs/reference/massart97ex3.html @@ -47,7 +47,7 @@
@@ -55,25 +55,23 @@

Sample dataset from p. 188 to test the package.

-
-
massart97ex3
-

Format

-

A dataframe containing 6 levels of x values with 5 - observations of y for each level.

+

A dataframe containing 6 levels of x values with 5 observations of y +for each level.

Source

-

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, - Chapter 8.

+

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, Chapter 8.

Examples

-
# For reproducing the results for replicate standard measurements in example 8,
+    

+# 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)
@@ -149,6 +147,7 @@
 # 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. 
+
 
diff --git a/docs/reference/rl95_cadmium.html b/docs/reference/rl95_cadmium.html index da9294d..4ddb8e4 100644 --- a/docs/reference/rl95_cadmium.html +++ b/docs/reference/rl95_cadmium.html @@ -1,5 +1,7 @@ -Cadmium concentrations measured by AAS as reported by Rocke and Lorenzato (1995) — rl95_cadmium • chemCalCadmium concentrations measured by AAS as reported by Rocke and Lorenzato +(1995) — rl95_cadmium • chemCal @@ -46,8 +48,9 @@
@@ -58,13 +61,13 @@

Format

-

A dataframe containing four replicate observations for each - of the six calibration standards.

+

A dataframe containing four replicate observations for each of the +six calibration standards.

Source

-

Rocke, David M. und Lorenzato, Stefan (1995) A two-component model for - measurement error in analytical chemistry. Technometrics 37(2), 176-184.

+

Rocke, David M. und Lorenzato, Stefan (1995) A two-component model +for measurement error in analytical chemistry. Technometrics 37(2), 176-184.

diff --git a/docs/reference/rl95_toluene.html b/docs/reference/rl95_toluene.html index fb071e1..4c8c7d2 100644 --- a/docs/reference/rl95_toluene.html +++ b/docs/reference/rl95_toluene.html @@ -1,7 +1,7 @@ Toluene amounts measured by GC/MS as reported by Rocke and Lorenzato (1995) — rl95_toluene • chemCal @@ -49,26 +49,26 @@

Dataset reproduced from Table 4 in Rocke and Lorenzato (1995). The toluene - amount in the calibration samples is given in picograms per 100 µL. - Presumably this is the volume that was injected into the instrument.

+amount in the calibration samples is given in picograms per 100 µL. +Presumably this is the volume that was injected into the instrument.

Format

-

A dataframe containing four replicate observations for each - of the six calibration standards.

+

A dataframe containing four replicate observations for each of the +six calibration standards.

Source

-

Rocke, David M. und Lorenzato, Stefan (1995) A two-component model for - measurement error in analytical chemistry. Technometrics 37(2), 176-184.

+

Rocke, David M. und Lorenzato, Stefan (1995) A two-component model +for measurement error in analytical chemistry. Technometrics 37(2), 176-184.

diff --git a/docs/reference/utstats14.html b/docs/reference/utstats14.html index 78d2604..1ffc224 100644 --- a/docs/reference/utstats14.html +++ b/docs/reference/utstats14.html @@ -1,6 +1,6 @@ -Example data for calibration with replicates from University of Toronto — utstats14 • chemCalExample data for calibration with replicates from University of Toronto — utstats14 • chemCal @@ -48,26 +48,27 @@

Format

-

A tibble containing three replicate observations of the response for five - calibration concentrations.

+

A tibble containing three replicate observations of the response for +five calibration concentrations.

Source

-

David Stone and Jon Ellis (2011) Statistics in Analytical Chemistry. Tutorial website - maintained by the Departments of Chemistry, University of Toronto. - https://sites.chem.utoronto.ca/chemistry/coursenotes/analsci/stats/index.html

+

David Stone and Jon Ellis (2011) Statistics in Analytical Chemistry. +Tutorial website maintained by the Departments of Chemistry, University of +Toronto. +https://sites.chem.utoronto.ca/chemistry/coursenotes/analsci/stats/index.html

diff --git a/docs/sitemap.xml b/docs/sitemap.xml index 5d588da..01d9b26 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -18,6 +18,9 @@ /news/index.html + + /reference/calplot.html + /reference/calplot.lm.html diff --git a/man/calplot.Rd b/man/calplot.Rd new file mode 100644 index 0000000..440d469 --- /dev/null +++ b/man/calplot.Rd @@ -0,0 +1,73 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/calplot.R +\name{calplot} +\alias{calplot} +\alias{calplot.default} +\alias{calplot.lm} +\title{Plot calibration graphs from univariate linear models} +\usage{ +calplot( + object, + xlim = c("auto", "auto"), + ylim = c("auto", "auto"), + xlab = "Concentration", + ylab = "Response", + legend_x = "auto", + alpha = 0.05, + varfunc = NULL +) +} +\arguments{ +\item{object}{A univariate model object of class \code{\link{lm}} or +\code{\link[MASS:rlm]{rlm}} with model formula \code{y ~ x} or \code{y ~ x - +1}.} + +\item{xlim}{The limits of the plot on the x axis.} + +\item{ylim}{The limits of the plot on the y axis.} + +\item{xlab}{The label of the x axis.} + +\item{ylab}{The label of the y axis.} + +\item{legend_x}{An optional numeric value for adjusting the x coordinate of +the legend.} + +\item{alpha}{The error tolerance level for the confidence and prediction +bands. Note that this includes both tails of the Gaussian distribution, +unlike the alpha and beta parameters used in \code{\link{lod}} (see note +below).} + +\item{varfunc}{The variance function for generating the weights in the +model. Currently, this argument is ignored (see note below).} +} +\value{ +A plot of the calibration data, of your fitted model as well as +lines showing the confidence limits. Prediction limits are only shown for +models from unweighted regression. +} +\description{ +Produce graphics of calibration data, the fitted model as well as +confidence, and, for unweighted regression, prediction bands. +} +\note{ +Prediction bands for models from weighted linear regression require +weights for the data, for which responses should be predicted. Prediction +intervals using weights e.g. from a variance function are currently not +supported by the internally used function \code{\link{predict.lm}}, +therefore, \code{calplot} does not draw prediction bands for such models. + +It is possible to compare the \code{\link{calplot}} prediction bands with +the \code{\link{lod}} values if the \code{lod()} alpha and beta parameters +are half the value of the \code{calplot()} alpha parameter. +} +\examples{ + +data(massart97ex3) +m <- lm(y ~ x, data = massart97ex3) +calplot(m) + +} +\author{ +Johannes Ranke +} diff --git a/man/calplot.lm.Rd b/man/calplot.lm.Rd deleted file mode 100644 index 39f20de..0000000 --- a/man/calplot.lm.Rd +++ /dev/null @@ -1,72 +0,0 @@ -\name{calplot} -\alias{calplot} -\alias{calplot.default} -\alias{calplot.lm} -\title{Plot calibration graphs from univariate linear models} -\description{ - Produce graphics of calibration data, the fitted model as well - as confidence, and, for unweighted regression, prediction bands. -} -\usage{ - calplot(object, xlim = c("auto", "auto"), ylim = c("auto", "auto"), - xlab = "Concentration", ylab = "Response", legend_x = "auto", - alpha=0.05, varfunc = NULL) -} -\arguments{ - \item{object}{ - A univariate model object of class \code{\link{lm}} or - \code{\link[MASS:rlm]{rlm}} - with model formula \code{y ~ x} or \code{y ~ x - 1}. - } - \item{xlim}{ - The limits of the plot on the x axis. - } - \item{ylim}{ - The limits of the plot on the y axis. - } - \item{xlab}{ - The label of the x axis. - } - \item{ylab}{ - The label of the y axis. - } - \item{legend_x}{ - An optional numeric value for adjusting the x coordinate of the legend. - } - \item{alpha}{ - The error tolerance level for the confidence and prediction bands. Note that this - includes both tails of the Gaussian distribution, unlike the alpha and beta parameters - used in \code{\link{lod}} (see note below). - } - \item{varfunc}{ - The variance function for generating the weights in the model. - Currently, this argument is ignored (see note below). - } -} -\value{ - A plot of the calibration data, of your fitted model as well as lines showing - the confidence limits. Prediction limits are only shown for models from - unweighted regression. -} -\note{ - Prediction bands for models from weighted linear regression require weights - for the data, for which responses should be predicted. Prediction intervals - using weights e.g. from a variance function are currently not supported by - the internally used function \code{\link{predict.lm}}, therefore, - \code{calplot} does not draw prediction bands for such models. - - It is possible to compare the \code{\link{calplot}} prediction bands with the - \code{\link{lod}} values if the \code{lod()} alpha and beta parameters are - half the value of the \code{calplot()} alpha parameter. - -} -\examples{ -data(massart97ex3) -m <- lm(y ~ x, data = massart97ex3) -calplot(m) -} -\author{ - Johannes Ranke - \email{jranke@uni-bremen.de} -} -\keyword{regression} diff --git a/man/din32645.Rd b/man/din32645.Rd index ffcbaed..a8e6a31 100644 --- a/man/din32645.Rd +++ b/man/din32645.Rd @@ -1,15 +1,17 @@ -\name{din32645} +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/chemCal-package.R \docType{data} +\name{din32645} \alias{din32645} \title{Calibration data from DIN 32645} -\description{ - Sample dataset to test the package. -} -\usage{data(din32645)} \format{ - A dataframe containing 10 rows of x and y values. +A dataframe containing 10 rows of x and y values. +} +\description{ +Sample dataset to test the package. } \examples{ + m <- lm(y ~ x, data = din32645) calplot(m) @@ -45,16 +47,17 @@ round(loq$x, 4) # A similar value is obtained using the approximation # LQ = 3.04 * LC (Currie 1999, p. 120) 3.04 * lod(m, alpha = 0.01, beta = 0.5)$x + } \references{ - DIN 32645 (equivalent to ISO 11843), Beuth Verlag, Berlin, 1994 +DIN 32645 (equivalent to ISO 11843), Beuth Verlag, Berlin, 1994 - Dintest. Plugin for MS Excel for evaluations of calibration data. Written - by Georg Schmitt, University of Heidelberg. Formerly available from - the Website of the University of Heidelberg. +Dintest. Plugin for MS Excel for evaluations of calibration data. Written by +Georg Schmitt, University of Heidelberg. Formerly available from the Website +of the University of Heidelberg. - Currie, L. A. (1997) Nomenclature in evaluation of analytical methods including - detection and quantification capabilities (IUPAC Recommendations 1995). - Analytica Chimica Acta 391, 105 - 126. +Currie, L. A. (1997) Nomenclature in evaluation of analytical methods +including detection and quantification capabilities (IUPAC Recommendations +1995). Analytica Chimica Acta 391, 105 - 126. } \keyword{datasets} diff --git a/man/inverse.predict.Rd b/man/inverse.predict.Rd index 373623e..08c24d7 100644 --- a/man/inverse.predict.Rd +++ b/man/inverse.predict.Rd @@ -1,67 +1,72 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/inverse.predict.lm.R \name{inverse.predict} \alias{inverse.predict} \alias{inverse.predict.lm} \alias{inverse.predict.rlm} \alias{inverse.predict.default} \title{Predict x from y for a linear calibration} -\usage{inverse.predict(object, newdata, \dots, - ws, alpha=0.05, var.s = "auto") +\usage{ +inverse.predict( + object, + newdata, + ..., + ws = "auto", + alpha = 0.05, + var.s = "auto" +) } \arguments{ - \item{object}{ - A univariate model object of class \code{\link{lm}} or - \code{\link[MASS:rlm]{rlm}} - with model formula \code{y ~ x} or \code{y ~ x - 1}. - } - \item{newdata}{ - A vector of observed y values for one sample. - } - \item{\dots}{ - Placeholder for further arguments that might be needed by - future implementations. - } - \item{ws}{ - The weight attributed to the sample. This argument is obligatory - if \code{object} has weights. - } - \item{alpha}{ - The error tolerance level for the confidence interval to be reported. - } - \item{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 \code{ws}, if applicable. This means that \code{var.s} - overrides \code{ws}. - } +\item{object}{A univariate model object of class \code{\link{lm}} or +\code{\link[MASS:rlm]{rlm}} with model formula \code{y ~ x} or \code{y ~ x - +1}.} + +\item{newdata}{A vector of observed y values for one sample.} + +\item{\dots}{Placeholder for further arguments that might be needed by +future implementations.} + +\item{ws}{The weight attributed to the sample. This argument is obligatory +if \code{object} has weights.} + +\item{alpha}{The error tolerance level for the confidence interval to be +reported.} + +\item{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 \code{ws}, if applicable. This means that \code{var.s} overrides +\code{ws}.} } \value{ - A list containing the predicted x value, its standard error and a - confidence interval. +A list containing the predicted x value, its standard error and a +confidence interval. } \description{ - This function predicts x values using a univariate linear model that has been - generated for the purpose of calibrating a measurement method. Prediction - intervals are given at the specified confidence level. - The calculation method was taken from Massart et al. (1997). In particular, - Equations 8.26 and 8.28 were combined in order to yield a general treatment - of inverse prediction for univariate linear models, taking into account - weights that have been used to create the linear model, and at the same - time providing the possibility to specify a precision in sample measurements - differing from the precision in standard samples used for the calibration. - This is elaborated in the package vignette. +This function predicts x values using a univariate linear model that has +been generated for the purpose of calibrating a measurement method. +Prediction intervals are given at the specified confidence level. The +calculation method was taken from Massart et al. (1997). In particular, +Equations 8.26 and 8.28 were combined in order to yield a general treatment +of inverse prediction for univariate linear models, taking into account +weights that have been used to create the linear model, and at the same time +providing the possibility to specify a precision in sample measurements +differing from the precision in standard samples used for the calibration. +This is elaborated in the package vignette. +} +\details{ +This is an implementation of Equation (8.28) in the Handbook of Chemometrics +and Qualimetrics, Part A, Massart et al (1997), page 200, validated with +Example 8 on the same page, extended as specified in the package vignette } \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{ - 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 +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. } \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 @@ -84,5 +89,10 @@ m3.means <- lm(y ~ x, w = weights, data = massart97ex3.means) inverse.predict(m3.means, 15, ws = 1.67) # 5.9 +- 2.5 inverse.predict(m3.means, 90, ws = 0.145) # 44.1 +- 7.9 + +} +\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 } -\keyword{manip} diff --git a/man/lod.Rd b/man/lod.Rd index ce32670..05107f3 100644 --- a/man/lod.Rd +++ b/man/lod.Rd @@ -1,3 +1,5 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/lod.R \name{lod} \alias{lod} \alias{lod.lm} @@ -5,83 +7,82 @@ \alias{lod.default} \title{Estimate a limit of detection (LOD)} \usage{ - lod(object, \dots, alpha = 0.05, beta = 0.05, method = "default", tol = "default") +lod( + object, + ..., + alpha = 0.05, + beta = 0.05, + method = "default", + tol = "default" +) } \arguments{ - \item{object}{ - A univariate model object of class \code{\link{lm}} or - \code{\link[MASS:rlm]{rlm}} - with model formula \code{y ~ x} or \code{y ~ x - 1}, - optionally from a weighted regression. - } - \item{\dots}{ - Placeholder for further arguments that might be needed by - future implementations. - } - \item{alpha}{ - The error tolerance for the decision limit (critical value). - } - \item{beta}{ - The error tolerance beta for the detection limit. - } - \item{method}{ - The \dQuote{default} method uses a prediction interval at the LOD - for the estimation of the LOD, which obviously requires - iteration. This is described for example in Massart, p. 432 ff. - The \dQuote{din} method uses the prediction interval at - x = 0 as an approximation. - } - \item{tol}{ - When the \dQuote{default} method is used, the default tolerance - for the LOD on the x scale is the value of the smallest non-zero standard - divided by 1000. Can be set to a numeric value to override this. - } +\item{object}{A univariate model object of class \code{\link{lm}} or +\code{\link[MASS:rlm]{rlm}} with model formula \code{y ~ x} or \code{y ~ x - +1}, optionally from a weighted regression.} + +\item{\dots}{Placeholder for further arguments that might be needed by +future implementations.} + +\item{alpha}{The error tolerance for the decision limit (critical value).} + +\item{beta}{The error tolerance beta for the detection limit.} + +\item{method}{The \dQuote{default} method uses a prediction interval at the +LOD for the estimation of the LOD, which obviously requires iteration. This +is described for example in Massart, p. 432 ff. The \dQuote{din} method +uses the prediction interval at x = 0 as an approximation.} + +\item{tol}{When the \dQuote{default} method is used, the default tolerance +for the LOD on the x scale is the value of the smallest non-zero standard +divided by 1000. Can be set to a numeric value to override this.} } \value{ - A list containig the corresponding x and y values of the estimated limit of - detection of a model used for calibration. +A list containig the corresponding x and y values of the estimated +limit of detection of a model used for calibration. } \description{ - The decision limit (German: Nachweisgrenze) is defined as the signal or - analyte concentration that is significantly different from the blank signal - with a first order error alpha (one-sided significance test). - The detection limit, or more precise, the minimum detectable value - (German: Erfassungsgrenze), is then defined as the signal or analyte - concentration where the probability that the signal is not detected although - the analyte is present (type II or false negative error), is beta (also a - one-sided significance test). +The decision limit (German: Nachweisgrenze) is defined as the signal or +analyte concentration that is significantly different from the blank signal +with a first order error alpha (one-sided significance test). The detection +limit, or more precise, the minimum detectable value (German: +Erfassungsgrenze), is then defined as the signal or analyte concentration +where the probability that the signal is not detected although the analyte +is present (type II or false negative error), is beta (also a one-sided +significance test). } \note{ - - The default values for alpha and beta are the ones recommended by IUPAC. - - The estimation of the LOD in terms of the analyte amount/concentration - xD from the LOD in the signal domain SD is done by simply inverting the - calibration function (i.e. assuming a known calibration function). - - The calculation of a LOD from weighted calibration models requires - a weights argument for the internally used \code{\link{predict.lm}} - function, which is currently not supported in R. -} -\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, - Chapter 13.7.8 - - J. Inczedy, T. Lengyel, and A.M. Ure (2002) International Union of Pure and - Applied Chemistry Compendium of Analytical Nomenclature: Definitive Rules. - Web edition. - - Currie, L. A. (1997) Nomenclature in evaluation of analytical methods including - detection and quantification capabilities (IUPAC Recommendations 1995). - Analytica Chimica Acta 391, 105 - 126. +* The default values for alpha and beta are the ones recommended by IUPAC. +* The estimation of the LOD in terms of the analyte amount/concentration xD +from the LOD in the signal domain SD is done by simply inverting the +calibration function (i.e. assuming a known calibration function). +* The calculation of a LOD from weighted calibration models requires a +weights argument for the internally used \code{\link{predict.lm}} +function, which is currently not supported in R. } \examples{ + m <- lm(y ~ x, data = din32645) lod(m) # The critical value (decision limit, German Nachweisgrenze) can be obtained # by using beta = 0.5: lod(m, alpha = 0.01, beta = 0.5) + +} +\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, Chapter 13.7.8 + +J. Inczedy, T. Lengyel, and A.M. Ure (2002) International Union of Pure and +Applied Chemistry Compendium of Analytical Nomenclature: Definitive Rules. +Web edition. + +Currie, L. A. (1997) Nomenclature in evaluation of analytical methods +including detection and quantification capabilities (IUPAC Recommendations +1995). Analytica Chimica Acta 391, 105 - 126. } \seealso{ - Examples for \code{\link{din32645}} +Examples for \code{\link{din32645}} } -\keyword{manip} diff --git a/man/loq.Rd b/man/loq.Rd index c247f34..390d3a8 100644 --- a/man/loq.Rd +++ b/man/loq.Rd @@ -1,3 +1,5 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/loq.R \name{loq} \alias{loq} \alias{loq.lm} @@ -5,76 +7,74 @@ \alias{loq.default} \title{Estimate a limit of quantification (LOQ)} \usage{ - loq(object, \dots, alpha = 0.05, k = 3, n = 1, w.loq = "auto", - var.loq = "auto", tol = "default") +loq( + object, + ..., + alpha = 0.05, + k = 3, + n = 1, + w.loq = "auto", + var.loq = "auto", + tol = "default" +) } \arguments{ - \item{object}{ - A univariate model object of class \code{\link{lm}} or - \code{\link[MASS:rlm]{rlm}} - with model formula \code{y ~ x} or \code{y ~ x - 1}, - optionally from a weighted regression. If weights are specified - in the model, either \code{w.loq} or \code{var.loq} have to - be specified. - } - \item{alpha}{ - The error tolerance for the prediction of x values in the calculation. - } - \item{\dots}{ - Placeholder for further arguments that might be needed by - future implementations. - } - \item{k}{ - The inverse of the maximum relative error tolerated at the - desired LOQ. - } - \item{n}{ - The number of replicate measurements for which the LOQ should be - specified. - } - \item{w.loq}{ - The weight that should be attributed to the LOQ. Defaults - to one for unweighted regression, and to the mean of the weights - for weighted regression. See \code{\link{massart97ex3}} for - an example how to take advantage of knowledge about the - variance function. - } - \item{var.loq}{ - The approximate variance at the LOQ. The default value is - calculated from the model. - } - \item{tol}{ - The default tolerance for the LOQ on the x scale is the value of the - smallest non-zero standard divided by 1000. Can be set to a - numeric value to override this. - } +\item{object}{A univariate model object of class \code{\link{lm}} or +\code{\link[MASS:rlm]{rlm}} with model formula \code{y ~ x} or \code{y ~ x - +1}, optionally from a weighted regression. If weights are specified in the +model, either \code{w.loq} or \code{var.loq} have to be specified.} + +\item{\dots}{Placeholder for further arguments that might be needed by +future implementations.} + +\item{alpha}{The error tolerance for the prediction of x values in the +calculation.} + +\item{k}{The inverse of the maximum relative error tolerated at the desired +LOQ.} + +\item{n}{The number of replicate measurements for which the LOQ should be +specified.} + +\item{w.loq}{The weight that should be attributed to the LOQ. Defaults to +one for unweighted regression, and to the mean of the weights for weighted +regression. See \code{\link{massart97ex3}} for an example how to take +advantage of knowledge about the variance function.} + +\item{var.loq}{The approximate variance at the LOQ. The default value is +calculated from the model.} + +\item{tol}{The default tolerance for the LOQ on the x scale is the value of +the smallest non-zero standard divided by 1000. Can be set to a numeric +value to override this.} } \value{ - The estimated limit of quantification for a model used for calibration. +The estimated limit of quantification for a model used for +calibration. } \description{ - The limit of quantification is the x value, where the relative error - of the quantification given the calibration model reaches a prespecified - value 1/k. Thus, it is the solution of the equation - \deqn{L = k c(L)}{L = k * c(L)} - where c(L) is half of the length of the confidence interval at the limit L - (DIN 32645, equivalent to ISO 11843). c(L) is internally estimated by - \code{\link{inverse.predict}}, and L is obtained by iteration. +The limit of quantification is the x value, where the relative error of the +quantification given the calibration model reaches a prespecified value 1/k. +Thus, it is the solution of the equation \deqn{L = k c(L)}{L = k * c(L)} +where c(L) is half of the length of the confidence interval at the limit L +(DIN 32645, equivalent to ISO 11843). c(L) is internally estimated by +\code{\link{inverse.predict}}, and L is obtained by iteration. } \note{ - - IUPAC recommends to base the LOQ on the standard deviation of the signal - where x = 0. - - The calculation of a LOQ based on weighted regression is non-standard - and therefore not tested. Feedback is welcome. +* IUPAC recommends to base the LOQ on the standard deviation of the +signal where x = 0. +* The calculation of a LOQ based on weighted regression is non-standard and +therefore not tested. Feedback is welcome. } \examples{ + m <- lm(y ~ x, data = massart97ex1) loq(m) # We can get better by using replicate measurements loq(m, n = 3) + } \seealso{ - Examples for \code{\link{din32645}} +Examples for \code{\link{din32645}} } -\keyword{manip} diff --git a/man/massart97ex1.Rd b/man/massart97ex1.Rd index 44e1b85..d154a9c 100644 --- a/man/massart97ex1.Rd +++ b/man/massart97ex1.Rd @@ -1,17 +1,18 @@ -\name{massart97ex1} +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/chemCal-package.R \docType{data} +\name{massart97ex1} \alias{massart97ex1} \title{Calibration data from Massart et al. (1997), example 1} -\description{ - Sample dataset from p. 175 to test the package. -} -\usage{data(massart97ex1)} \format{ - A dataframe containing 6 observations of x and y data. +A dataframe containing 6 observations of x and y data. } \source{ - 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, - Chapter 8. +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, Chapter 8. +} +\description{ +Sample dataset from p. 175 to test the package. } \keyword{datasets} diff --git a/man/massart97ex3.Rd b/man/massart97ex3.Rd index d7f8d00..284a435 100644 --- a/man/massart97ex3.Rd +++ b/man/massart97ex3.Rd @@ -1,16 +1,23 @@ -\name{massart97ex3} +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/chemCal-package.R \docType{data} +\name{massart97ex3} \alias{massart97ex3} \title{Calibration data from Massart et al. (1997), example 3} -\description{ - Sample dataset from p. 188 to test the package. -} -\usage{massart97ex3} \format{ - A dataframe containing 6 levels of x values with 5 - observations of y for each level. +A dataframe containing 6 levels of x values with 5 observations of y +for each level. +} +\source{ +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, Chapter 8. +} +\description{ +Sample dataset from p. 188 to test the package. } \examples{ + # 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, { @@ -45,10 +52,6 @@ loq(m3.means, w.loq = 1.67) # 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. -} -\source{ - 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, - Chapter 8. + } \keyword{datasets} diff --git a/man/rl95_cadmium.Rd b/man/rl95_cadmium.Rd index 7ee4222..8e0b02c 100644 --- a/man/rl95_cadmium.Rd +++ b/man/rl95_cadmium.Rd @@ -1,16 +1,19 @@ -\name{rl95_cadmium} +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/chemCal-package.R \docType{data} +\name{rl95_cadmium} \alias{rl95_cadmium} -\title{Cadmium concentrations measured by AAS as reported by Rocke and Lorenzato (1995)} -\description{ - Dataset reproduced from Table 1 in Rocke and Lorenzato (1995). -} +\title{Cadmium concentrations measured by AAS as reported by Rocke and Lorenzato +(1995)} \format{ - A dataframe containing four replicate observations for each - of the six calibration standards. +A dataframe containing four replicate observations for each of the +six calibration standards. } \source{ - Rocke, David M. und Lorenzato, Stefan (1995) A two-component model for - measurement error in analytical chemistry. Technometrics 37(2), 176-184. +Rocke, David M. und Lorenzato, Stefan (1995) A two-component model +for measurement error in analytical chemistry. Technometrics 37(2), 176-184. +} +\description{ +Dataset reproduced from Table 1 in Rocke and Lorenzato (1995). } \keyword{datasets} diff --git a/man/rl95_toluene.Rd b/man/rl95_toluene.Rd index 21fea0f..1f8836a 100644 --- a/man/rl95_toluene.Rd +++ b/man/rl95_toluene.Rd @@ -1,18 +1,20 @@ -\name{rl95_toluene} +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/chemCal-package.R \docType{data} +\name{rl95_toluene} \alias{rl95_toluene} \title{Toluene amounts measured by GC/MS as reported by Rocke and Lorenzato (1995)} -\description{ - Dataset reproduced from Table 4 in Rocke and Lorenzato (1995). The toluene - amount in the calibration samples is given in picograms per 100 µL. - Presumably this is the volume that was injected into the instrument. -} \format{ - A dataframe containing four replicate observations for each - of the six calibration standards. +A dataframe containing four replicate observations for each of the +six calibration standards. } \source{ - Rocke, David M. und Lorenzato, Stefan (1995) A two-component model for - measurement error in analytical chemistry. Technometrics 37(2), 176-184. +Rocke, David M. und Lorenzato, Stefan (1995) A two-component model +for measurement error in analytical chemistry. Technometrics 37(2), 176-184. +} +\description{ +Dataset reproduced from Table 4 in Rocke and Lorenzato (1995). The toluene +amount in the calibration samples is given in picograms per 100 µL. +Presumably this is the volume that was injected into the instrument. } \keyword{datasets} diff --git a/man/utstats14.Rd b/man/utstats14.Rd index ec41bd5..1b739d4 100644 --- a/man/utstats14.Rd +++ b/man/utstats14.Rd @@ -1,18 +1,21 @@ -\name{utstats14} +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/chemCal-package.R \docType{data} +\name{utstats14} \alias{utstats14} \title{Example data for calibration with replicates from University of Toronto} -\description{ - Dataset read into R from - \url{https://sites.chem.utoronto.ca/chemistry/coursenotes/analsci/stats/files/example14.xls}. -} \format{ - A tibble containing three replicate observations of the response for five - calibration concentrations. +A tibble containing three replicate observations of the response for +five calibration concentrations. } \source{ - David Stone and Jon Ellis (2011) Statistics in Analytical Chemistry. Tutorial website - maintained by the Departments of Chemistry, University of Toronto. - \url{https://sites.chem.utoronto.ca/chemistry/coursenotes/analsci/stats/index.html} +David Stone and Jon Ellis (2011) Statistics in Analytical Chemistry. +Tutorial website maintained by the Departments of Chemistry, University of +Toronto. +\url{https://sites.chem.utoronto.ca/chemistry/coursenotes/analsci/stats/index.html} +} +\description{ +Dataset read into R from +\url{https://sites.chem.utoronto.ca/chemistry/coursenotes/analsci/stats/files/example14.xls}. } \keyword{datasets} -- cgit v1.2.1
-

All functions

+

Main functions

-

calplot()

+

calplot()

Plot calibration graphs from univariate linear models

-

din32645

-

Calibration data from DIN 32645

-

inverse.predict()

-

Predict x from y for a linear calibration

lod()

Estimate a limit of quantification (LOQ)

+

inverse.predict()

+

Predict x from y for a linear calibration

+

Datasets

+

+
+

din32645

+

Calibration data from DIN 32645

massart97ex1

rl95_cadmium

Cadmium concentrations measured by AAS as reported by Rocke and Lorenzato (1995)

Cadmium concentrations measured by AAS as reported by Rocke and Lorenzato +(1995)

rl95_toluene