diff options
Diffstat (limited to 'R/lod.R')
-rw-r--r-- | R/lod.R | 19 |
1 files changed, 16 insertions, 3 deletions
@@ -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) } |