aboutsummaryrefslogtreecommitdiff
path: root/R
diff options
context:
space:
mode:
authorranke <ranke@5fad18fb-23f0-0310-ab10-e59a3bee62b4>2007-03-22 16:44:33 +0000
committerranke <ranke@5fad18fb-23f0-0310-ab10-e59a3bee62b4>2007-03-22 16:44:33 +0000
commit49679639ded05e7ef954c23f50d3d94d3d6dc1dd (patch)
treeb6dc323d45f296f9a296fb5586873a7818344be1 /R
parentf4443942f10740ecc62b928181a1911ef14eeb04 (diff)
Start of the integration of nonlinear calibration models
git-svn-id: http://kriemhild.uft.uni-bremen.de/svn/chemCal@19 5fad18fb-23f0-0310-ab10-e59a3bee62b4
Diffstat (limited to 'R')
-rw-r--r--R/calfunctions.R2
-rw-r--r--R/inverse.predict.lm.R20
2 files changed, 21 insertions, 1 deletions
diff --git a/R/calfunctions.R b/R/calfunctions.R
new file mode 100644
index 0000000..6ce29f7
--- /dev/null
+++ b/R/calfunctions.R
@@ -0,0 +1,2 @@
+powfunc <- function(x,a,b) a * x^b
+ipowfunc <- function(y,a,b) (y/a)^1/b
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