summaryrefslogtreecommitdiff
path: root/R
diff options
context:
space:
mode:
authorSuraj Yerramilli2016-05-22 12:19:39 +0530
committerSuraj Yerramilli2016-05-22 12:19:39 +0530
commit1fad9cfca90f28a6a1bcac7380974fc9d38eca6a (patch)
tree592e2fd75a391390fd3b6b4d32e378ac916954fa /R
parent79737d5e93037300eb78d89300af4bd44e4a781c (diff)
downloadSysID-R-code-1fad9cfca90f28a6a1bcac7380974fc9d38eca6a.tar.gz
SysID-R-code-1fad9cfca90f28a6a1bcac7380974fc9d38eca6a.tar.bz2
SysID-R-code-1fad9cfca90f28a6a1bcac7380974fc9d38eca6a.zip
correcting the initialization step
Diffstat (limited to 'R')
-rw-r--r--R/rarx.R10
1 files changed, 4 insertions, 6 deletions
diff --git a/R/rarx.R b/R/rarx.R
index b55e5ce..92f9333 100644
--- a/R/rarx.R
+++ b/R/rarx.R
@@ -22,17 +22,15 @@ rarx <- function(x,order=c(1,1,1),lambda=0.95){
# R0 <- reg(n+1)%*%t(reg(n+1))
# Plast <- solve(R0)
Plast <- 10^4*diag(na+nb)
- theta <- matrix(0,N,na+nb)
- theta[1,] <- Plast%*%reg(n+1)%*%y[1,,drop=FALSE]
+ theta <- matrix(0,N+1,na+nb)
yhat <- y
- yhat[1,] <- t(reg(n+1))%*%t(theta[1,,drop=FALSE])
- for(i in 2:N){
+ for(i in 1:N){
temp <- reg(n+i)
- yhat[i,] <- t(temp)%*%t(theta[i-1,,drop=FALSE])
+ yhat[i,] <- t(temp)%*%t(theta[i,,drop=FALSE])
eps_i <- y[i,,drop=FALSE] - yhat[i,,drop=FALSE]
kappa_i <- Plast%*%temp/(lambda+t(temp)%*%Plast%*%temp)[1]
- theta[i,] <- t(t(theta[i-1,,drop=F])+eps_i[1]*kappa_i)
+ theta[i+1,] <- t(t(theta[i,,drop=F])+eps_i[1]*kappa_i)
Plast <- (diag(na+nb)-kappa_i%*%t(temp))%*%Plast/lambda
}
list(theta=theta,yhat=yhat,P=Plast)