summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSuraj Yerramilli2016-02-13 15:27:59 +0530
committerSuraj Yerramilli2016-02-13 15:27:59 +0530
commitb8f0248649d7c1fdc67938c01575ab93677bf803 (patch)
treefcd0f2e89e5c57f9a3c40e625bd23f241a0795af
parentda207fa8b73af55f0c1e259247af7cc1c1a649bd (diff)
downloadSysID-R-code-b8f0248649d7c1fdc67938c01575ab93677bf803.tar.gz
SysID-R-code-b8f0248649d7c1fdc67938c01575ab93677bf803.tar.bz2
SysID-R-code-b8f0248649d7c1fdc67938c01575ab93677bf803.zip
added initial parameter estimates for ARMAX model
-rw-r--r--R/estpoly.R11
1 files changed, 8 insertions, 3 deletions
diff --git a/R/estpoly.R b/R/estpoly.R
index 686c147..72ed6a8 100644
--- a/R/estpoly.R
+++ b/R/estpoly.R
@@ -260,10 +260,15 @@ armax <- function(x,order=c(0,1,1,0),options=optimOptions()){
yout <- apply(y,2,padZeros,n=n)
uout <- apply(u,2,padZeros,n=n)
- theta0 <- matrix(runif(na+nb+nc,min=-0.3,max=0.3)) # current parameters
+ # Initial Parameter Estimates
+ mod_arx <- arx(x,c(na,nb,nk)) # fitting ARX model
+ eps_init <- matrix(resid(mod_arx))
+ mod_ar <- ar(eps_init,aic=F,order=nc)
+ e_init <- matrix(mod_ar$resid); e_init[is.na(e_init)] <- 0
+ theta0 <- matrix(c(mod_arx$sys$A[-1],mod_arx$sys$B,-mod_ar$ar))
- l <- levbmqdt(yout,uout,order,obj=armaxGrad,theta0=theta0,N=N,
- opt=options)
+ l <- levbmqdt(yout,uout,order,e_init,obj=armaxGrad,
+ theta0=theta0,N=N,opt=options)
theta <- l$params
e <- ts(l$residuals,start = start(y),deltat = deltat(y))