[R] applying data generating function

Spencer Graves spencer.graves at pdf.com
Sun Mar 7 22:32:47 CET 2004


      I'd use a for loop: 

set.seed(123)
e <- 0.001*rnorm(100)
x <- rep(0, 100)
for(i in 2:100)
    x[i] <- (3.8*x[i-1]*(1-x[i-1])+e[i])
plot(x, type="l")
plot(x[-100], x[-1])

      "R" is great for standard vector and matrix operations, but 
recursions are not so easy.  

      hope this helps.  spencer graves

Fred J. wrote:

>Hello
>
>Coming from matlab background, I could use some help
>on this one.
>
>I need to generate a data set based on this equation
>X(t) = 3.8x(t-1) (1-x(t-1)) + e(t), where e(t) is a
>N(0,0,001) random variable
>I need say 100 values.
>
>How do I do this? 
>
>Thanks
>
>______________________________________________
>R-help at stat.math.ethz.ch mailing list
>https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>  
>




More information about the R-help mailing list