summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NAMESPACE1
-rw-r--r--R/poly.R35
2 files changed, 36 insertions, 0 deletions
diff --git a/NAMESPACE b/NAMESPACE
index 4affc7a..d9136e0 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -4,6 +4,7 @@ S3method(plot,idframe)
S3method(plot,idfrd)
S3method(plot,impulseest)
S3method(predict,detrend)
+S3method(print,arx)
S3method(print,summary.idframe)
S3method(print,tf)
S3method(summary,idframe)
diff --git a/R/poly.R b/R/poly.R
index cf821c8..4a96617 100644
--- a/R/poly.R
+++ b/R/poly.R
@@ -13,6 +13,41 @@ arx <- function(A,B,ioDelay=0){
}
#' @export
+print.arx <- function(obj){
+ cat("Discrete-time ARX model: A(q^{-1})y[k] = B(q^{-1})u[k] + e[k] \n\n")
+ cat("A(q^{-1}) = ")
+ for(i in seq_along(obj$A)){
+ if(i-1==0){
+ cat(obj$A[i])
+ } else{
+ if(obj$A[i]>0) cat(" + ") else cat("- ")
+
+ if(!(abs(obj$A[i])==1)) cat(abs(obj$A[i]))
+ cat("q^{-",i-1,"}",sep="")
+ }
+ cat("\t")
+ }
+ cat("\n")
+ cat("B(q^{-1}) = ")
+ for(i in seq_along(obj$B)){
+ if(i+obj$ioDelay-1==0){
+ cat(obj$B[i])
+ } else{
+
+ if(!((obj$ioDelay!=0) && (i==1))){
+ if(obj$B[i]>0) cat(" + ") else cat("- ")
+ } else{
+ if(obj$B[i]<0) cat("-")
+ }
+
+ if(!(abs(obj$B[i])==1)) cat(abs(obj$B[i]))
+ cat("q^{-",i+obj$ioDelay-1,"}",sep="")
+ }
+ cat("\t")
+ }
+}
+
+#' @export
armax <- function(A,B,C,ioDelay=0){
out <- idpoly(A=A,B=B,C=C,D=1,E=1,F1=1,ioDelay = ioDelay)
class(out) <- c("armax","idpoly")