summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSuraj Yerramilli2016-01-04 19:28:00 +0530
committerSuraj Yerramilli2016-01-04 19:28:00 +0530
commitd831fea9c22bb609a2c4d4131b666eb4a654bb51 (patch)
tree0a41ed36fe6f142e74933b995bff4c71b4f71d99
parent95f6c4a8eed9b192a956a609d3bbb2418e198574 (diff)
downloadSysID-R-code-d831fea9c22bb609a2c4d4131b666eb4a654bb51.tar.gz
SysID-R-code-d831fea9c22bb609a2c4d4131b666eb4a654bb51.tar.bz2
SysID-R-code-d831fea9c22bb609a2c4d4131b666eb4a654bb51.zip
minor changes
-rw-r--r--NAMESPACE3
-rw-r--r--R/predict.R33
2 files changed, 21 insertions, 15 deletions
diff --git a/NAMESPACE b/NAMESPACE
index b51f61a..069151b 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -18,7 +18,6 @@ S3method(plot,idfrd)
S3method(plot,impulseest)
S3method(predict,detrend)
S3method(predict,estpoly)
-S3method(predict,idpoly)
S3method(print,estpoly)
S3method(print,idpoly)
S3method(print,summary.estpoly)
@@ -33,6 +32,7 @@ export("inputNames<-")
export("outputNames<-")
export(armax)
export(arx)
+export(compare)
export(dataSlice)
export(detrend)
export(estpoly)
@@ -62,6 +62,7 @@ export(spa)
export(step)
export(tf)
import(ggplot2)
+import(reshape)
import(tfplot)
import(tframe)
importFrom(zoo,na.approx)
diff --git a/R/predict.R b/R/predict.R
index 2cbcf20..a3a8083 100644
--- a/R/predict.R
+++ b/R/predict.R
@@ -1,4 +1,3 @@
-#' @export
predict.idpoly <- function(x,data,nahead=1){
y <- outputData(data); u<- inputData(data)
G <- signal::Arma(b=c(rep(0,x$ioDelay),x$B),
@@ -22,6 +21,22 @@ predict.idpoly <- function(x,data,nahead=1){
ts(ypred,start=start(data),deltat=deltat(data))
}
+polyinv <- function(x,k){
+ gamma <- 1/Re(polyroot(x))
+
+ inverse <- function(y,k){
+ sapply(1:k-1,function(i) y^i)
+ }
+ z <- lapply(lapply(gamma,inverse,k=2),polynom::polynomial)
+ temp = z[[1]]
+ if(length(z)>1){
+ for(i in 2:length(z)){
+ temp = temp*z[[i]]
+ }
+ }
+ temp
+}
+
#' @export
predict.estpoly <- function(x,newdata=NULL,nahead=1){
if(is.null(newdata)&& nahead==1){
@@ -39,18 +54,8 @@ predict.estpoly <- function(x,newdata=NULL,nahead=1){
}
}
-polyinv <- function(x,k){
- gamma <- 1/Re(polyroot(x))
+#' @import ggplot2 reshape
+#' @export
+compare <- function(){
- inverse <- function(y,k){
- sapply(1:k-1,function(i) y^i)
- }
- z <- lapply(lapply(gamma,inverse,k=2),polynom::polynomial)
- temp = z[[1]]
- if(length(z)>1){
- for(i in 2:length(z)){
- temp = temp*z[[i]]
- }
- }
- temp
} \ No newline at end of file