summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--R/sim.R3
1 files changed, 2 insertions, 1 deletions
diff --git a/R/sim.R b/R/sim.R
index 3892958..6f802f3 100644
--- a/R/sim.R
+++ b/R/sim.R
@@ -42,7 +42,8 @@ sim.arx <- function(model,input,sigma=0){
# u <- apply(input,2,padLeftZeros)
for(i in n+1:length(input)){
- reg <- matrix(c(-(y[i-1:na]),u[i-nk:nb1]),ncol=na+nb1)
+ if(nk==0) v <- u[i-0:(nb-1)] else v <- u[i-nk:nb1]
+ reg <- matrix(c(-(y[i-1:na]),v),ncol=na+nb1)
y[i] <- reg%*%coef + rnorm(1,sd = sigma)
}
return(y[n+1:length(input)])