diff options
author | ranke <ranke@5fad18fb-23f0-0310-ab10-e59a3bee62b4> | 2014-04-24 17:01:51 +0000 |
---|---|---|
committer | ranke <ranke@5fad18fb-23f0-0310-ab10-e59a3bee62b4> | 2014-04-24 17:01:51 +0000 |
commit | 9f1c53849ba99e9f607a817f0ca44eb693430e76 (patch) | |
tree | bcd68e64c3409d1e7ced370df16239a93b772950 /branches | |
parent | 867ba670518e1d5ae98f58881351cefebd38b279 (diff) |
- Added the tolerance argument and the fix to the call to optimize() also in
loq()
- Version 0.1-33 just submitted to CRAN
git-svn-id: http://kriemhild.uft.uni-bremen.de/svn/chemCal@33 5fad18fb-23f0-0310-ab10-e59a3bee62b4
Diffstat (limited to 'branches')
-rw-r--r-- | branches/0.1/chemCal/ChangeLog | 14 | ||||
-rw-r--r-- | branches/0.1/chemCal/DESCRIPTION | 2 | ||||
-rw-r--r-- | branches/0.1/chemCal/R/loq.R | 11 | ||||
-rw-r--r-- | branches/0.1/chemCal/man/lod.Rd | 4 | ||||
-rw-r--r-- | branches/0.1/chemCal/man/loq.Rd | 7 | ||||
-rw-r--r-- | branches/0.1/chemCal/tests/din32645.Rout.save | 2 | ||||
-rw-r--r-- | branches/0.1/chemCal/tests/massart97.Rout.save | 12 |
7 files changed, 29 insertions, 23 deletions
diff --git a/branches/0.1/chemCal/ChangeLog b/branches/0.1/chemCal/ChangeLog index 852b753..c258c26 100644 --- a/branches/0.1/chemCal/ChangeLog +++ b/branches/0.1/chemCal/ChangeLog @@ -1,11 +1,11 @@ -2014-04-24 Johannes Ranke <jranke@uni-bremen.de> for chemCal (0.1-32)
+2014-04-24 Johannes Ranke <jranke@uni-bremen.de> for chemCal (0.1-33)
- * Bugfix in lod(): In the case of small absolute x values (e.g. on the order
- of 1e-4 and smaller), the lod calculated using the default method could
- produce inaccurate results as the default tolerance that was used in the
- internal call to optimize is inappropriate in such cases. Now a reasonable
- default is used which can be overriden by the user. Thanks to Jérôme
- Ambroise for reporting the bug.
+ * Bugfix in lod() and loq(): In the case of small absolute x values (e.g. on
+ the order of 1e-4 and smaller), the lod or loq calculated using the default
+ method could produce inaccurate results as the default tolerance that was
+ used in the internal call to optimize is inappropriate in such cases. Now a
+ reasonable default is used which can be overriden by the user. Thanks to
+ Jérôme Ambroise for reporting the bug.
Changes performed in earlier versions are documented in the subversion log
files found at http://kriemhild.uft.uni-bremen.de/viewcvs/?root=chemCal
diff --git a/branches/0.1/chemCal/DESCRIPTION b/branches/0.1/chemCal/DESCRIPTION index 900c92a..13d5bc6 100644 --- a/branches/0.1/chemCal/DESCRIPTION +++ b/branches/0.1/chemCal/DESCRIPTION @@ -1,5 +1,5 @@ Package: chemCal -Version: 0.1-32 +Version: 0.1-33 Date: 2014-04-24 Title: Calibration functions for analytical chemistry Author: Johannes Ranke <jranke@uni-bremen.de> diff --git a/branches/0.1/chemCal/R/loq.R b/branches/0.1/chemCal/R/loq.R index 5776096..f832265 100644 --- a/branches/0.1/chemCal/R/loq.R +++ b/branches/0.1/chemCal/R/loq.R @@ -1,17 +1,17 @@ loq <- function(object, ..., alpha = 0.05, k = 3, n = 1, w.loq = "auto", - var.loq = "auto") + var.loq = "auto", tol = "default") { UseMethod("loq") } loq.default <- function(object, ..., alpha = 0.05, k = 3, n = 1, w.loq = "auto", - var.loq = "auto") + var.loq = "auto", tol = "default") { stop("loq is only implemented for univariate lm objects.") } loq.lm <- function(object, ..., alpha = 0.05, k = 3, n = 1, w.loq = "auto", - var.loq = "auto") + var.loq = "auto", tol = "default") { if (length(object$weights) > 0 && var.loq == "auto" && w.loq == "auto") { stop(paste("If you are using a model from weighted regression,", @@ -20,6 +20,7 @@ loq.lm <- function(object, ..., alpha = 0.05, k = 3, n = 1, w.loq = "auto", "limit of quantification")) } xname <- names(object$model)[[2]] + xvalues <- object$model[[2]] yname <- names(object$model)[[1]] f <- function(x) { newdata <- data.frame(x = x) @@ -29,8 +30,8 @@ loq.lm <- function(object, ..., alpha = 0.05, k = 3, n = 1, w.loq = "auto", var.s = var.loq, alpha = alpha) (p[["Prediction"]] - k * p[["Confidence"]])^2 } - tmp <- optimize(f,interval=c(0,max(object$model[[2]]))) - loq.x <- tmp$minimum + if (tol == "default") tol = min(xvalues[xvalues !=0]) / 1000 + loq.x <- optimize(f, interval = c(0, max(xvalues) * 10), tol = tol)$minimum newdata <- data.frame(x = loq.x) names(newdata) <- xname loq.y <- predict(object, newdata) diff --git a/branches/0.1/chemCal/man/lod.Rd b/branches/0.1/chemCal/man/lod.Rd index 918e820..04aac1f 100644 --- a/branches/0.1/chemCal/man/lod.Rd +++ b/branches/0.1/chemCal/man/lod.Rd @@ -33,8 +33,8 @@ } \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. + 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{ diff --git a/branches/0.1/chemCal/man/loq.Rd b/branches/0.1/chemCal/man/loq.Rd index 7541e77..082cf34 100644 --- a/branches/0.1/chemCal/man/loq.Rd +++ b/branches/0.1/chemCal/man/loq.Rd @@ -6,7 +6,7 @@ \title{Estimate a limit of quantification (LOQ)} \usage{ loq(object, \dots, alpha = 0.05, k = 3, n = 1, w.loq = "auto", - var.loq = "auto") + var.loq = "auto", tol = "default") } \arguments{ \item{object}{ @@ -43,6 +43,11 @@ 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. diff --git a/branches/0.1/chemCal/tests/din32645.Rout.save b/branches/0.1/chemCal/tests/din32645.Rout.save index d7c6102..7c9e55d 100644 --- a/branches/0.1/chemCal/tests/din32645.Rout.save +++ b/branches/0.1/chemCal/tests/din32645.Rout.save @@ -45,4 +45,4 @@ $y > > proc.time() user system elapsed - 0.454 0.286 0.341 + 0.472 0.302 0.354 diff --git a/branches/0.1/chemCal/tests/massart97.Rout.save b/branches/0.1/chemCal/tests/massart97.Rout.save index f00ae97..ce99c30 100644 --- a/branches/0.1/chemCal/tests/massart97.Rout.save +++ b/branches/0.1/chemCal/tests/massart97.Rout.save @@ -108,21 +108,21 @@ $y > > loq(m0) $x -[1] 13.97767 +[1] 13.97764 $y - 1 -30.62355 + 1 +30.6235 > loq(m, w.loq = 1.67) $x -[1] 7.346231 +[1] 7.346195 $y 1 -17.90784 +17.90777 > > proc.time() user system elapsed - 0.516 0.344 0.412 + 0.529 0.327 0.443 |