Random Walk and White Noise
On the lecture slides the definition of a random walk is given as
with white noise \(u_t\), which means \(E(u_t) = 0\) and \(Var(u_t) = \sigma_u^2\) and \(Corr(u_t,u_s) = 0 \) for \(t \neq s\), and assuming that the initial value \(y_0\) equals 0.
The two equations above can be rewritten as a cumulative sum of white noise variates. First, rewrite the equation for a random walk without drift,
and for a random walk with drift parameter \(\mu\),
To generate a gaussian random walk (with and without drift) in R we need the functions rnorm(), set.seed(), and cumsum().