How to repeat 1000 times this random walk simulation in R?
<p>I'm simulating a one-dimensional and symmetric random walk procedure:</p>

<pre><code>y[t] = y[t-1] + epsilon[t]
</code></pre>

<p>where white noise is denoted by <code>epsilon[t] ~ N(0,1)</code> in time period <code>t</code>. There is no drift in this procedure. </p>

<p>Also, RW is symmetric, because <code>Pr(y[i] = +1) = Pr(y[i] = -1) = 0.5</code>.</p>

<p>Here's my code in R:</p>

<pre><code>set.seed(1)
t=1000
epsilon=sample(c(-1,1), t, replace = 1)

y&lt;-c()
y[1]&lt;-0
for (i in 2:t) {
  y[i]&lt;-y[i-1]+epsilon[i]
}
par(mfrow=c(1,2))
plot(1:t, y, type="l", main="Random walk")
outcomes &lt;- sapply(1:1000, function(i) cumsum(y[i]))
hist(outcomes)
</code></pre>

<p>I would like to simulate 1000 different <code>y[i,t]</code> series (<code>i=1,...,1000; t=1,...,1000</code>). (After that, I will check the probability of getting back to the origin (<code>y[1]=0</code>) at <code>t=3</code>, <code>t=5</code> and <code>t=10</code>.)</p>

<p>Which function would allow me to do this kind of repetition with <code>y[t]</code> random walk time-series?</p>