Question: 2.3 In this problem, we explore the difference between a random walk and a trend stationary process. (a) Generate four series that are random walk

2.3 In this problem, we explore the difference between a random walk and a trend

stationary process.

(a) Generate four series that are random walk with drift, (1.4), of length n = 100

with = .01 and w = 1. Call the data xt for t = 1, . . . , 100. Fit the regression

xt = t + wt using least squares. Plot the data, the true mean function (i.e.,

t = .01 t) and the fitted line, xt = t, on the same graph. Hint: The following R

code may be useful.

par(mfrow=c(2,2), mar=c(2.5,2.5,0,0)+.5, mgp=c(1.6,.6,0)) # set up

for (i in 1:4){

x = ts(cumsum(rnorm(100,.01,1))) # data

regx = lm(x~0+time(x), na.action=NULL) # regression

plot(x, ylab='Random Walk w Drift') # plots

abline(a=0, b=.01, col=2, lty=2) # true mean (red - dashed)

abline(regx, col=4) # fitted line (blue - solid)

}

(b) Generate four series of length n = 100 that are linear trend plus noise, say

yt = .01 t + wt, where t and wt are as in part (a). Fit the regression yt = t + wt

using least squares. Plot the data, the true mean function (i.e., t = .01 t) and the

fitted line, yt = t, on the same graph.

(c) Comment (what did you learn from this assignment).

WE USE R IN CLASS

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Mathematics Questions!