summaryrefslogtreecommitdiff
path: root/R
diff options
context:
space:
mode:
authorSuraj Yerramilli2015-11-01 16:58:27 +0530
committerSuraj Yerramilli2015-11-01 16:58:27 +0530
commit839ab8c3cb6a260a4ad6904d00a332f52164b280 (patch)
treeb0fa1bc8573d577e8aa146d45452201a73717b17 /R
parentc80fbfc2f1cb1a07846f0c52e1a4625a427ea955 (diff)
downloadSysID-R-code-839ab8c3cb6a260a4ad6904d00a332f52164b280.tar.gz
SysID-R-code-839ab8c3cb6a260a4ad6904d00a332f52164b280.tar.bz2
SysID-R-code-839ab8c3cb6a260a4ad6904d00a332f52164b280.zip
Corrections in ARX model
Diffstat (limited to 'R')
-rw-r--r--R/estpoly.R6
1 files changed, 3 insertions, 3 deletions
diff --git a/R/estpoly.R b/R/estpoly.R
index 84ff239..c95a1b3 100644
--- a/R/estpoly.R
+++ b/R/estpoly.R
@@ -167,8 +167,8 @@ residplot <- function(model,newdata=NULL){
#' @export
arx <- function(x,order=c(0,1,0)){
y <- outputData(x); u <- inputData(x); N <- dim(y)[1]
- na <- order[1];nb <- order[2]-1; nk <- order[3]
- nb1 <- nb+nk ; n <- max(na,nb1); df <- N - na - nb - 1
+ na <- order[1];nb <- order[2]; nk <- order[3]
+ nb1 <- nb+nk-1 ; n <- max(na,nb1); df <- N-na-nb
padZeros <- function(x,n) c(rep(0,n),x,rep(0,n))
yout <- apply(y,2,padZeros,n=n);
@@ -182,7 +182,7 @@ arx <- function(x,order=c(0,1,0)){
Y <- yout[n+1:(N+n),,drop=F]
qx <- qr(X); coef <- qr.solve(qx,Y)
- sigma2 <- sum((Y-X%*%coef)^2)/df
+ sigma2 <- sum((Y-X%*%coef)^2)/(df+n)
vcov <- sigma2 * chol2inv(qx$qr)