diff options
author | Suraj Yerramilli | 2016-01-03 13:00:44 +0530 |
---|---|---|
committer | Suraj Yerramilli | 2016-01-03 13:00:44 +0530 |
commit | eed9b50e306de80ac007851185829e29855bbe0f (patch) | |
tree | dfabedadc5992a265edb3af307d720e2a5a86bbd | |
parent | f262485f677d70bd6b3e0edff65f5e5966271ae2 (diff) | |
download | SysID-R-code-eed9b50e306de80ac007851185829e29855bbe0f.tar.gz SysID-R-code-eed9b50e306de80ac007851185829e29855bbe0f.tar.bz2 SysID-R-code-eed9b50e306de80ac007851185829e29855bbe0f.zip |
created a separate predict file containing predict methods
-rw-r--r-- | R/estpoly.R | 17 | ||||
-rw-r--r-- | R/poly.R | 16 | ||||
-rw-r--r-- | R/predict.R | 32 |
3 files changed, 32 insertions, 33 deletions
diff --git a/R/estpoly.R b/R/estpoly.R index 25a65d2..132cabf 100644 --- a/R/estpoly.R +++ b/R/estpoly.R @@ -63,23 +63,6 @@ print.summary.estpoly <- function(x,digits=4){ } #' @export -predict.estpoly <- function(x,newdata=NULL,nahead=1){ - if(is.null(newdata)&&nahead=1){ - return(fitted(x)) - } else{ - model <- x$sys - if(is.null(newdata)){ - y <- fitted(x)+resid(x) - u <- x$input - z <- idframe(y,u,Ts = deltat(y),start=start(y)) - } else{ - z <- newdata - } - predict(model,z,nahead) - } -} - -#' @export plot.estpoly <- function(model,newdata=NULL){ require(ggplot2) @@ -164,20 +164,4 @@ print.idpoly <- function(mod,se=NULL,dig=3){ } } cat("\n") -} - -#' @export -predict.idpoly <- function(x,data,nahead=1){ - y <- outputData(z); u<- inputData(z) - G <- signal::Arma(b=c(rep(0,x$ioDelay),x$B), - a= as.numeric(polynom::polynomial(x$A)* - polynom::polynomial(x$F1))) - if(x$type=="oe" || nahead==Inf){ - ypred <- signal::filter(G,u) - } else{ - Hden <- as.numeric(polynom::polynomial(x$A)*polynom::polynomial(x$D)) - Hinv <- signal::Arma(b=Hden,a=x$C) - } - - return(ypred) }
\ No newline at end of file diff --git a/R/predict.R b/R/predict.R new file mode 100644 index 0000000..23c6b62 --- /dev/null +++ b/R/predict.R @@ -0,0 +1,32 @@ +#' @export +predict.idpoly <- function(x,data,nahead=1){ + y <- outputData(z); u<- inputData(z) + G <- signal::Arma(b=c(rep(0,x$ioDelay),x$B), + a= as.numeric(polynom::polynomial(x$A)* + polynom::polynomial(x$F1))) + if(x$type=="oe" || nahead==Inf){ + ypred <- signal::filter(G,u) + } else{ + Hden <- as.numeric(polynom::polynomial(x$A)*polynom::polynomial(x$D)) + Hinv <- signal::Arma(b=Hden,a=x$C) + } + + return(ypred) +} + +#' @export +predict.estpoly <- function(x,newdata=NULL,nahead=1){ + if(is.null(newdata)&& nahead==1){ + return(fitted(x)) + } else{ + model <- x$sys + if(is.null(newdata)){ + y <- fitted(x)+resid(x) + u <- x$input + z <- idframe(y,u,Ts = deltat(y),start=start(y)) + } else{ + z <- newdata + } + predict(model,z,nahead) + } +} |