[R] If-statement in for-loop

2013-12-10 Thread gncl dzgn
Hi everyone, you might find my question elementary but I am a beginner and unfortunately I can't fix the problem. So, I simulate this following algorithm and some values of c are NA. Therefore, I should add these following two if-statements but I don't know how I should do it in a for-loop.

[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] +