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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started