aboutsummaryrefslogtreecommitdiff
path: root/R/lod.R
diff options
context:
space:
mode:
authorranke <ranke@5fad18fb-23f0-0310-ab10-e59a3bee62b4>2006-05-23 07:33:22 +0000
committerranke <ranke@5fad18fb-23f0-0310-ab10-e59a3bee62b4>2006-05-23 07:33:22 +0000
commitf381f9a6a8a47b89ec25cd627833a7248da7932b (patch)
tree3155c1f5b2f5810a453aa8cb8a8f44f5920b01e8 /R/lod.R
parente12be874ff477509b737ad09bf05144a7fbedac2 (diff)
Don't do calplot and lod for linear models from weighted
regression any more, since this is not supported (PR#8877). git-svn-id: http://kriemhild.uft.uni-bremen.de/svn/chemCal@13 5fad18fb-23f0-0310-ab10-e59a3bee62b4
Diffstat (limited to 'R/lod.R')
-rw-r--r--R/lod.R19
1 files changed, 16 insertions, 3 deletions
diff --git a/R/lod.R b/R/lod.R
index 39ce7b3..54618c8 100644
--- a/R/lod.R
+++ b/R/lod.R
@@ -10,7 +10,18 @@ lod.default <- function(object, ..., alpha = 0.05, beta = 0.05)
lod.lm <- function(object, ..., alpha = 0.05, beta = 0.05)
{
+ if (length(object$weights) > 0) {
+ stop(paste(
+ "\nThe detemination of a lod from calibration models obtained by",
+ "weighted linear regression requires confidence intervals for",
+ "predicted y values taking into account weights for the x values",
+ "from which the predictions are to be generated.",
+ "This is not supported by the internally used predict.lm method.",
+ sep = "\n"
+ ))
+ }
xname <- names(object$model)[[2]]
+ yname <- names(object$model)[[1]]
newdata <- data.frame(0)
names(newdata) <- xname
y0 <- predict(object, newdata, interval="prediction",
@@ -28,7 +39,9 @@ lod.lm <- function(object, ..., alpha = 0.05, beta = 0.05)
}
lod.x <- optimize(f,interval=c(0,max(object$model[[xname]])))$minimum
newdata <- data.frame(x = lod.x)
- names(lod.x) <- xname
- lod.y <- predict(object, newdata = lod.x)
- return(list(x = lod.x, y = lod.y))
+ names(newdata) <- xname
+ lod.y <- predict(object, newdata)
+ lod <- list(lod.x, lod.y)
+ names(lod) <- c(xname, yname)
+ return(lod)
}

Contact - Imprint