[R] n Realizations of a Stochastic Process assigned to dynamically generated variable names?

Vishal Belsare shoot.spam at gmail.com
Sun May 25 21:02:57 CEST 2008


I am interested in creating multiple (say 1000) time series, from a
given stochastic process, of length 250. I want to refer to each
realization with its own variable name, of the format say, tsn, where
n is the n'th simulation. i.e. ts1, ts2, ts3, ts4, .... , ts1000

The way I am thinking of doing this is placing the following code
within another loop, and the 'tsn' assignment should happen as ts1 and
so on, the n being taken from the iteration of the outer loop.
However, crucially, I don't know how/whether I can create variable
names dynamically and assign values to them.

#begin

tsn <- (10);

for (i in 1:250) {

  tsn <- c(tsn, tsn[i] + rnorm(1, mean=0.01, sd=0.025))

                     };

plot.ts(tsn, lwd=2, col="maroon");

#end


Thanks in anticipation.


Best Regards

Vishal Belsare



More information about the R-help mailing list