summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--R/estpoly.R5
-rw-r--r--man/sim.arx.Rd34
2 files changed, 38 insertions, 1 deletions
diff --git a/R/estpoly.R b/R/estpoly.R
index 7bf94ea..eca1a5f 100644
--- a/R/estpoly.R
+++ b/R/estpoly.R
@@ -99,7 +99,10 @@ estARX <- function(data,order=c(0,1,0)){
yout <- apply(y,2,padZeros,n=n);
uout <- apply(u,2,padZeros,n=n);
- reg <- function(i) cbind(-yout[i-1:na,],uout[i-nk:nb1])
+ reg <- function(i) {
+ if(nk==0) v <- i-0:(nb-1) else v <- i-nk:nb1
+ cbind(-yout[i-1:na,],uout[v])
+ }
X <- t(sapply(n+1:(N+n),reg))
Y <- yout[n+1:(N+n),,drop=F]
diff --git a/man/sim.arx.Rd b/man/sim.arx.Rd
new file mode 100644
index 0000000..848dd5f
--- /dev/null
+++ b/man/sim.arx.Rd
@@ -0,0 +1,34 @@
+% Generated by roxygen2 (4.1.1): do not edit by hand
+% Please edit documentation in R/sim.R
+\name{sim.arx}
+\alias{sim.arx}
+\title{Simulate from an ARX Model}
+\usage{
+\method{sim}{arx}(model, input, sigma = 0)
+}
+\arguments{
+\item{model}{an object of class \code{arx} containing the coefficients}
+
+\item{input}{a vector/matrix containing the input}
+
+\item{sigma}{standard deviation of the innovations (Default= \code{0})}
+}
+\value{
+a vector containing the output
+}
+\description{
+Simulate the response of an ARX system, given the input
+}
+\details{
+The routine is currently built only for SISO systems. Future Versions will
+include support for MIMO systems
+}
+\examples{
+u <- rnorm(100,1)
+model <- arx(A=c(1,-1.5,0.7),B=c(0.8,-0.25))
+y <- sim(model,u,sigma=3)
+}
+\seealso{
+\code{\link{arx}} for defining ARX models
+}
+