Re: [R] Generating restricted numbers

2013-12-06 Thread Adams, Jean
What value do you want d to take on if it is outside that interval? Here is an example where if d is outside the interval, it is assigned to be one of the interval endpoints. minx <- 0 for(i in 2:T) { x <- alpha * d[i-1] + e[i] maxx <- a*(T-i) if(x < minx) { d[i] <- minx } else { if(x > maxx)

[R] Generating restricted numbers

2013-12-06 Thread gncl dzgn
Hello everyone, I'm trying to generate a sequence that consists of random numbers and the following algorithm works well ### a <- 0.08 b <- 0.01 T <- 90 t <- 0:T alpha <- 1 e <- rnorm(T, mean = 0, sd = 0.1) d <- c( runif(1,0, a*T), rep(0, T-1) ) for (i in 2:T) { d[i] <- alpha * d[i-1] +