diff options
author | Suraj Yerramilli | 2015-12-30 14:46:14 +0530 |
---|---|---|
committer | Suraj Yerramilli | 2015-12-30 14:46:14 +0530 |
commit | d333a1d95d8105532cbecde94c7945214b776d08 (patch) | |
tree | 5e6fe4fd3d08bf564245fd7b87ead900b7be45d4 /R | |
parent | b6cef1d9634b735b4424c4d09488ea4cf3e8ad6f (diff) | |
download | SysID-R-code-d333a1d95d8105532cbecde94c7945214b776d08.tar.gz SysID-R-code-d333a1d95d8105532cbecde94c7945214b776d08.tar.bz2 SysID-R-code-d333a1d95d8105532cbecde94c7945214b776d08.zip |
corrected code errors
Diffstat (limited to 'R')
-rw-r--r-- | R/estUtil.R | 11 | ||||
-rw-r--r-- | R/estpoly.R | 4 |
2 files changed, 7 insertions, 8 deletions
diff --git a/R/estUtil.R b/R/estUtil.R index b8e5b5e..eda0b52 100644 --- a/R/estUtil.R +++ b/R/estUtil.R @@ -132,7 +132,7 @@ armaxGrad <- function(theta,e,dots){ } oeGrad <- function(theta,e,dots){ - y <- dots[[1]]; u <- dots[[2]]; order <- dots[[3]]; + y <- dots[[1]]; uout <- dots[[2]]; order <- dots[[3]]; nb <- order[1];nf <- order[2]; nk <- order[3]; nb1 <- nb+nk-1 ; n <- max(nb1,nf) N <- dim(y)[1] @@ -143,18 +143,17 @@ oeGrad <- function(theta,e,dots){ iv <- y-e } eout <- matrix(c(rep(0,n),iv[,])) - + reg <- function(i) { if(nk==0) v <- i-0:(nb-1) else v <- i-nk:nb1 matrix(c(uout[v,],-eout[i-1:nf,])) } - X <- t(sapply(n+1:(N+n),reg)) - Y <- y[n+1:(N+n),,drop=F] - l <- list(X=X,Y=Y) + X <- t(sapply(n+1:N,reg)) + l <- list(X=X,Y=y) if(!is.null(e)){ - filt1 <- Arma(b=1,a=c(1,theta[nb+1:nf])) + filt1 <- Arma(b=1,a=c(1,theta[nb+1:nf,])) grad <- apply(X,2,filter,filt=filt1) l$grad <- grad } diff --git a/R/estpoly.R b/R/estpoly.R index 79b597f..3a0c7c8 100644 --- a/R/estpoly.R +++ b/R/estpoly.R @@ -360,10 +360,10 @@ oe <- function(x,order=c(1,1,0),options=optimOptions()){ # Initial Guess mod_arx <- arx(x,c(nf,nb,nk)) # fitting ARX model iv <- matrix(predict(mod_arx)) - theta0 <- c(coef(mod_arx)$B,coef(mod_arx)$A[-1]) + theta0 <- matrix(c(mod_arx$sys$B,mod_arx$sys$A[-1])) uout <- apply(u,2,leftPadZeros,n=n) - l <- levbmqdt(y,uout,order,iv,obj=armaxGrad,theta0=theta0,N=N, + l <- levbmqdt(y,uout,order,iv,obj=oeGrad,theta0=theta0,N=N, opt=options) theta <- l$params e <- ts(l$residuals,start = start(y),deltat = deltat(y)) |