summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSuraj Yerramilli2015-11-01 13:27:51 +0530
committerSuraj Yerramilli2015-11-01 13:27:51 +0530
commit53a494166197e5414399f24b8aa80e2c74493159 (patch)
treefaaf5bc90f5bfd28d52bb75c07fd42a5f81b44fb
parentfe30af3bf4a8fe330e495d42d066ee8aba65044b (diff)
downloadSysID-R-code-53a494166197e5414399f24b8aa80e2c74493159.tar.gz
SysID-R-code-53a494166197e5414399f24b8aa80e2c74493159.tar.bz2
SysID-R-code-53a494166197e5414399f24b8aa80e2c74493159.zip
Correcting errors
-rw-r--r--NAMESPACE2
-rw-r--r--R/estpoly.R38
2 files changed, 35 insertions, 5 deletions
diff --git a/NAMESPACE b/NAMESPACE
index bc54573..465b3fd 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -36,8 +36,6 @@ export(estPoly)
export(etfe)
export(idframe)
export(idfrd)
-export(idin.rbs)
-export(idin.rgs)
export(idinput)
export(idpoly)
export(impulseest)
diff --git a/R/estpoly.R b/R/estpoly.R
index 92647cd..e15e8f8 100644
--- a/R/estpoly.R
+++ b/R/estpoly.R
@@ -178,13 +178,45 @@ arx <- function(x,order=c(0,1,0)){
}
armax <- function(x,order=c(0,1,1,0)){
+ library(signal)
y <- outputData(x); u <- inputData(x); N <- dim(y)[1]
- e <- matrix(rep(0,N),ncol=1)
- na <- order[1];nb <- order[2]-1; nc <- order[3]
- nb1 <- nb+nk ; n <- max(na,nb1,nc)
+ na <- order[1];nb <- order[2]; nc <- order[3]; nk <- order[4]
+ nb1 <- nb+nk-1 ; n <- max(na,nb1,nc)
if(nc<1)
stop("Error: Not an ARMAX model")
+ padZeros <- function(x,n) c(rep(0,n),x,rep(0,n))
+ yout <- apply(y,2,padZeros,n=n)
+ uout <- apply(u,2,padZeros,n=n)
+ tol <- 10^(-3); sumsq <- 10^3; i = 0
+ eout <- matrix(rep(0,N+2*n))
+
+ reg <- function(i) {
+ if(nk==0) v <- i-0:(nb-1) else v <- i-nk:nb1
+ matrix(c(-yout[i-1:na,],uout[v,],eout[i-1:nc,]))
+ }
+
+ while (sumsq > tol){
+ if(i==0){
+ theta <- matrix(rnorm(na+nb+nc))
+ }
+
+ # Generate Residuals from previous params
+ X <- t(sapply(n+1:(N+n),reg))
+ Y <- yout[n+1:(N+n),,drop=F]
+ e <- Y-X%*%theta
+
+ # Compute gradient
+ eout <- matrix(c(rep(0,n),e[,]))
+ X <- t(sapply(n+1:(N+n),reg))
+ filt1 <- Arma(b=1,a=c(1,theta[(na+nb+1):length(theta)]))
+ grad <- apply(X,2,filter,filt=filt1)
+
+ # Update Parameters
+
+
+ i=i+1
+ }
} \ No newline at end of file