aboutsummaryrefslogtreecommitdiff
path: root/R/inverse.predict.lm.R
diff options
context:
space:
mode:
Diffstat (limited to 'R/inverse.predict.lm.R')
-rw-r--r--R/inverse.predict.lm.R20
1 files changed, 19 insertions, 1 deletions
diff --git a/R/inverse.predict.lm.R b/R/inverse.predict.lm.R
index 927e672..d57275c 100644
--- a/R/inverse.predict.lm.R
+++ b/R/inverse.predict.lm.R
@@ -11,7 +11,7 @@ inverse.predict <- function(object, newdata, ...,
inverse.predict.default <- function(object, newdata, ...,
ws = "auto", alpha = 0.05, var.s = "auto")
{
- stop("Inverse prediction only implemented for univariate lm objects.")
+ stop("Inverse prediction only implemented for univariate lm and nls objects.")
}
inverse.predict.lm <- function(object, newdata, ...,
@@ -46,6 +46,24 @@ inverse.predict.rlm <- function(object, newdata, ...,
ws = ws, alpha = alpha, var.s = var.s, w = w, xname = xname, yname = yname)
}
+inverse.predict.nls <- function(object, newdata, ...,
+ ws = "auto", alpha = 0.05, var.s = "auto")
+{
+ yname = names(object$model)[[1]]
+ xname = names(object$model)[[2]]
+ if (ws == "auto") {
+ ws <- ifelse(length(object$weights) > 0, mean(object$weights), 1)
+ }
+ if (length(object$weights) > 0) {
+ wx <- split(object$weights,object$model[[xname]])
+ w <- sapply(wx,mean)
+ } else {
+ w <- rep(1,length(split(object$model[[yname]],object$model[[xname]])))
+ }
+ if (length(object$coef) > 2)
+ stop("More than one independent variable in your model - not implemented")
+}
+
.inverse.predict <- function(object, newdata, ws, alpha, var.s, w, xname, yname)
{
if (length(object$coef) > 2)

Contact - Imprint