[R] applying data generating function

Phineas Campbell pcampbell at econ.bbk.ac.uk
Sun Mar 7 22:10:56 CET 2004


It may be possible to do this without a loop but I haven't found a way


###Generate an array of 100 N(0,1) RVs
z<-rnorm(100)
###Build the array to store output
x<-vector(length=100)
###Create initial value
x[1]<-z[1]
###Loop though building series
for(i in 2:100){
	x[i]<-3.8*x[i-1]*(1-x[i-1])+z[i]
}



As I understand it you take an overhead hit when using loops, so they are
best avoided.
HTH
Phineas
http://www.phineas.pwp.blueyonder.co.uk/

-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch]On Behalf Of Fred J.
Sent: Sunday, March 07, 2004 7:55 PM
To: r help
Subject: [R] applying data generating function


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