diff options
author | Suraj Yerramilli | 2016-02-13 18:42:31 +0530 |
---|---|---|
committer | Suraj Yerramilli | 2016-02-13 18:42:31 +0530 |
commit | 038a72560568425cbed6554ef4f62debcf30400c (patch) | |
tree | cac2c75499eb528fcbe7121b340ca9ca1beb710e | |
parent | 8b7f7f92b633584310e8661fdf00004efe29289a (diff) | |
download | SysID-R-code-038a72560568425cbed6554ef4f62debcf30400c.tar.gz SysID-R-code-038a72560568425cbed6554ef4f62debcf30400c.tar.bz2 SysID-R-code-038a72560568425cbed6554ef4f62debcf30400c.zip |
Adding the iv4 method
-rw-r--r-- | NAMESPACE | 1 | ||||
-rw-r--r-- | R/iv.R | 14 |
2 files changed, 14 insertions, 1 deletions
@@ -47,6 +47,7 @@ export(impulseest) export(inputData) export(inputNames) export(iv) +export(iv4) export(misdata) export(nInputSeries) export(nOutputSeries) @@ -10,6 +10,10 @@ iv <- function(z,order=c(0,1,0),x=NULL){ x <- matrix(sim(mod_arx$sys,u,sigma=0)) } + ivcompute(y,u,x,na,nb,nk,n,N) +} + +ivcompute <- function(y,u,x,na,nb,nk,n,N){ padZeros <- function(x,n) c(rep(0,n),x,rep(0,n)) yout <- apply(y,2,padZeros,n=n); xout <- apply(x,2,padZeros,n=n); @@ -63,7 +67,15 @@ iv4 <- function(z,order=c(0,1,0)){ w <- matrix(as.numeric(signal::filter(A,y)) - as.numeric(signal::filter(B,u))) mod_ar <- ar(w,aic = F,order=na+nb) - L <- signal::Ma(c(1,-mod_ar$ar)) + Lhat <- signal::Ma(c(1,-mod_ar$ar)) # Step 4 + G2 <- signal::Arma(as.numeric(B),as.numeric(A)) + x2 <- as.numeric(signal::filter(G2,u)) + + Lf <- function(x,L) matrix(as.numeric(signal::filter(L,x))) + filtered <- lapply(list(y,u,x2),Lf,L=Lhat) + yf <- filtered[[1]]; uf<- filtered[[2]]; xf <- filtered[[3]] + + ivcompute(yf,uf,xf,na,nb,nk,n,N) }
\ No newline at end of file |