Skip to content
Prev 245385 / 398506 Next

Replacing the for loop for time series buid-up

Torch wrote:
You can have a look at filter.
Test example:

alpha <- 0.75
N <- 10

boot.res <- ts(rnorm(N))
boot.res

val.init <- boot.res[1] + alpha

boot.x <- ts(val.init, start=1,end=N)
for(t in 2:N) { boot.x[t] <- alpha*boot.x[t-1] + boot.res[t] }
boot.x

boot.x.filter <-
ts(c(val.init,filter(boot.res[-1],filter=alpha,method="recursive",init=val.init)))
boot.x.filter
boot.x - boot.x.filter

succes

Berend