summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSuraj Yerramilli2016-01-04 19:36:56 +0530
committerSuraj Yerramilli2016-01-04 19:36:56 +0530
commit26b6f9b837dac73f927a5ceed9442544191c2258 (patch)
tree3fbcb8f411f3b027a966719b55e48e3c3ee3df9b
parentd831fea9c22bb609a2c4d4131b666eb4a654bb51 (diff)
downloadSysID-R-code-26b6f9b837dac73f927a5ceed9442544191c2258.tar.gz
SysID-R-code-26b6f9b837dac73f927a5ceed9442544191c2258.tar.bz2
SysID-R-code-26b6f9b837dac73f927a5ceed9442544191c2258.zip
added the compare routine
-rw-r--r--NAMESPACE2
-rw-r--r--R/predict.R12
2 files changed, 11 insertions, 3 deletions
diff --git a/NAMESPACE b/NAMESPACE
index 069151b..0cb4291 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -62,7 +62,7 @@ export(spa)
export(step)
export(tf)
import(ggplot2)
-import(reshape)
+import(reshape2)
import(tfplot)
import(tframe)
importFrom(zoo,na.approx)
diff --git a/R/predict.R b/R/predict.R
index a3a8083..d11578e 100644
--- a/R/predict.R
+++ b/R/predict.R
@@ -54,8 +54,16 @@ predict.estpoly <- function(x,newdata=NULL,nahead=1){
}
}
-#' @import ggplot2 reshape
+#' @import ggplot2 reshape2
#' @export
-compare <- function(){
+compare <- function(data,nahead=1,...){
+ # Input Validation
+ dots <- list(...)
+ if(is.null(dots)) stop("No model supplied")
+ Y <- sapply(dots,predict,newdata=data,nahead=nahead)
+ df <- data.frame(Time = time(data),Actual=outputData(data)[,1],Y)
+ meltdf <- melt(df,id="Time")
+
+ ggplot(meltdf,aes(x=Time,y=value,color=variable,group=variable))+geom_line()
} \ No newline at end of file