Are the white noise model or the random walk model stationary?
The white noise (WN) and random walk (RW) models are very closely related. However, only the RW is always non-stationary, both with and without a drift term. This is a simulation exercise to highlight the differences.
Recall that if we start with a mean zero WN process and compute its running or cumulative sum, the result is a RW process. The cumsum()
function will make this transformation for you. Similarly, if we create a WN process, but change its mean from zero, and then compute its cumulative sum, the result is a RW process with a drift.
This exercise is part of the course
Time Series Analysis in R
Exercise instructions
- Use
arima.sim()
to generate a WN model. Set themodel
argument equal tolist(order = c(0, 0, 0))
to generate a WN-type model and setn
equal to100
to produce 100 observations. Save this towhite_noise
. - Use the
cumsum()
function onwhite_noise
to quickly convert your WN model to RW data. Save this torandom_walk
. - Use a similar call to
arima.sim()
to generate a second WN model. Keep all arguments the same, but this time set themean
argument to0.4
. Save this town_drift
. - Use another call to
cumsum()
to convert yourwn_drift
data to RW. Save this asrw_drift
. - Enter the pre-written code to plot all four series for comparison.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Use arima.sim() to generate WN data
white_noise <-
# Use cumsum() to convert your WN data to RW
random_walk <-
# Use arima.sim() to generate WN drift data
wn_drift <-
# Use cumsum() to convert your WN drift data to RW
rw_drift <-
# Plot all four data objects
plot.ts(cbind(white_noise, random_walk, wn_drift, rw_drift))