summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSuraj Yerramilli2015-02-11 16:14:44 +0530
committerSuraj Yerramilli2015-02-11 16:14:44 +0530
commit66bfdadddbaa4c082a497a6e36c83f817165e302 (patch)
treed6e405a0cfefd66cedf476c9eb5317479fa1b0ed
parent84229c4bbcc6c389f3f172e16fa16b751df8713a (diff)
downloadSysID-R-code-66bfdadddbaa4c082a497a6e36c83f817165e302.tar.gz
SysID-R-code-66bfdadddbaa4c082a497a6e36c83f817165e302.tar.bz2
SysID-R-code-66bfdadddbaa4c082a497a6e36c83f817165e302.zip
added predict function for detrend function
-rw-r--r--R/detrend.R19
1 files changed, 18 insertions, 1 deletions
diff --git a/R/detrend.R b/R/detrend.R
index c9033ce..670f0f0 100644
--- a/R/detrend.R
+++ b/R/detrend.R
@@ -14,8 +14,25 @@ detrend.idframe <- function(data,tt="linear",bp=c()){
output_d <- data$output - output0
input_d <- data$input - input0
- est <- list(fitted.values= data0,out.diff = output_d,inp.diff=input_d)
+ est <- list(fitted.values= data0,out.diff = output_d,inp.diff=input_d,
+ raw.values = data)
class(est) <- "detrend.idframe"
return(est)
+}
+
+#' Predict method for trend fits on idframe objects
+#'
+#'
+#' @export
+predict.detrend.idframe <- function(object,newdata=NULL,...){
+
+ if(is.null(newdata)){
+ data <- fitted(object)
+ } else{
+ data <- newdata
+ data$output <- newdata$output - object$out.diff
+ data$input <- newdata$input - object$inp.diff
+ }
+ return(data)
} \ No newline at end of file