aboutsummaryrefslogtreecommitdiff
path: root/R/lod.R
diff options
context:
space:
mode:
Diffstat (limited to 'R/lod.R')
-rw-r--r--R/lod.R26
1 files changed, 15 insertions, 11 deletions
diff --git a/R/lod.R b/R/lod.R
index 6562c04..1bb7981 100644
--- a/R/lod.R
+++ b/R/lod.R
@@ -1,23 +1,27 @@
-lod <- function(object, ..., alpha = 0.05, beta = 0.05, n = 1, w = "auto")
+lod <- function(object, ..., alpha = 0.05, beta = 0.05)
{
UseMethod("lod")
}
-lod.default <- function(object, ..., alpha = 0.05, beta = 0.05,
- n = 1, w = "auto")
+lod.default <- function(object, ..., alpha = 0.05, beta = 0.05)
{
stop("lod is only implemented for univariate lm objects.")
}
-lod.lm <- function(object, ..., alpha = 0.05, beta = 0.05, n = 1, w = "auto")
+lod.lm <- function(object, ..., alpha = 0.05, beta = 0.05)
{
- f <- function(x) {
- y1 <- predict(object, data.frame(x = 0), interval="prediction",
+ y0 <- predict(object, data.frame(x = 0), interval="prediction",
level = 1 - alpha)
- y2 <- predict(object, data.frame(x = x), interval="prediction",
- level = 1 - beta)
- (y2[[1,"lwr"]] - y1[[1,"upr"]])^2
+ yc <- y0[[1,"upr"]]
+ xc <- inverse.predict(object,yc)[["Prediction"]]
+ f <- function(x)
+ {
+ # Here I need the variance of y values as a function of x or
+ # y values
+ # Strangely, setting the confidence level to 0.5 does not result
+ # in a zero confidence or prediction interval
}
- tmp <- optimize(f,interval=c(0,max(object$model$x)))
- return(tmp$minimum)
+ lod.x <- optimize(f,interval=c(0,max(object$model$x)))$minimum
+ lod.y <- predict(object, data.frame(x = lod.x))
+ return(list(x = lod.x, y = lod.y))
}

Contact - Imprint