diff options
author | Suraj Yerramilli | 2015-11-01 23:17:18 +0530 |
---|---|---|
committer | Suraj Yerramilli | 2015-11-01 23:17:18 +0530 |
commit | b10b9011e2c2485e7e3b297f0dd72ad10ff31f64 (patch) | |
tree | 8c6695460200691994e507b98330b43ad9948bdd /R | |
parent | 5beb096b342412a6f65802e50b6415ea46d25fe8 (diff) | |
download | SysID-R-code-b10b9011e2c2485e7e3b297f0dd72ad10ff31f64.tar.gz SysID-R-code-b10b9011e2c2485e7e3b297f0dd72ad10ff31f64.tar.bz2 SysID-R-code-b10b9011e2c2485e7e3b297f0dd72ad10ff31f64.zip |
Fixing bugs in ARX
Diffstat (limited to 'R')
-rw-r--r-- | R/estpoly.R | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/R/estpoly.R b/R/estpoly.R index fc1d957..2b9d4c5 100644 --- a/R/estpoly.R +++ b/R/estpoly.R @@ -66,7 +66,7 @@ print.summary.estPoly <- function(object){ } #' @export -predict.estPoly <- function(model,newData=NULL){ +predict.estPoly <- function(model,newdata=NULL){ if(is.null(newdata)){ return(fitted(model)) } else{ @@ -176,15 +176,19 @@ arx <- function(x,order=c(0,1,0)){ reg <- function(i) { if(nk==0) v <- i-0:(nb-1) else v <- i-nk:nb1 - cbind(-yout[i-1:na,],uout[v]) + c(-yout[i-1:na,,drop=T],uout[v,,drop=T]) } X <- t(sapply(n+1:(N+n),reg)) Y <- yout[n+1:(N+n),,drop=F] - qx <- qr(X); coef <- qr.solve(qx,Y) - sigma2 <- sum((Y-X%*%coef)^2)/(df+n) + lambda <- 0.1 + inner <- t(X)%*%X + lambda*diag(dim(X)[2]) + innerinv <- solve(inner) + pinv <- innerinv%*% t(X) + coef <- pinv%*%Y - vcov <- sigma2 * chol2inv(qx$qr) + sigma2 <- sum((Y-X%*%coef)^2)/(df+n) + vcov <- sigma2 * innerinv model <- idpoly(A = c(1,coef[1:na]),B = coef[na+1:nb], ioDelay = nk,Ts=deltat(x)) |