Chapter 1 homework for Time Series Analysis

Below are partial answers to the homework problems.

1.2

Below is my code and output for a and part of c.

> set.seed(9811)

> x<-numeric(200) #Initializes a vector filled with NA’s (Not available)

> w<-rnorm(n = 200, mean = 0, sd = 1)

> x[1:100]<-w[1:100]

> #####################################################################

> #Part a

> #Notice the use of 101:200 and how R does the mathematical calculations with

these vectors

> x[101:200]<-10*exp(-(101:200 - 100)/20)*cos(2*pi*(101:200)/4) + w[101:200]

> win.graph(width = 8, height = 6, pointsize = 10)

> plot(x = x, ylab = expression(x[t]), xlab = "t", type = "l", col = c("red"),

main = "Problem 1.2", panel.first=grid(col = "gray", lty = "dotted"))

> points(x = x, pch = 20, col = "blue")

> #####################################################################

> # Part c

> #The curve function allows you to plot a function of "x". By default, the

functionin the expr option is evaluated at 101 values and then plotted.

> curve(expr = exp(-x/20), col = "red", lty = "solid", lwd = 1, from = 1, to =

100, ylab = expression(e^{-t/20}), xlab = "t", main = "Plot of signal - a",

ylim = c(0,1.0))

> curve(expr = exp(-x/200), col = "red", lty = "solid", lwd = 1, from = 1, to =

100, ylab = expression(e^{-t/200}), xlab = "t", main = "Plot of signal - b",

ylim = c(0,1.0))

First series looks more like the explosion.

1.4

1.5

a)E(xt) = E(st + wt) = E(st) + E(wt) = st + 0 = st - Note that wt is a random variable with mean 0 since it is white noise. Also note that st is not a random variable.

b)x(s,t) = Cov(xt, xt+h) = Cov(st+wt, st+h+wt+h) = Cov(st, st+h) + Cov(st, wt+h) + Cov(wt, st+h) +
Cov(wt, wt+h) = 0 + 0 + 0 + Cov(wt, wt+h). Then Cov(wt, wt+h) = Var(wt) for h=0 and Cov(wt, wt+h) = 0 for h0 since wt’s are independent

1.6

Skip part c

1.7 You do not need to plot the autocovariance or autocorrelation functions because is unknown.

and (h) = (h)/6

1.11

a)This was done in the notes

b)Skip this part

1.15

1.20

Below is my code and output.

> set.seed(1988)

> w<-rnorm(n = 500, mean = 0, sd = 1)

> head(w)

[1] 0.1357288 -0.3380447 -1.0388604 -0.4845740 1.2579352 0.9398159

> win.graph(width = 8, height = 6, pointsize = 10)

> plot(x = w, ylab = expression(w[t]), xlab = "t", type = "l", col = c("red"),

main = expression(paste("White noise where ", w[t], " ~ ind. N(0, 1)")),

panel.first=grid(col = "gray", lty = "dotted"))

> points(x = w, pch = 20, col = "blue")

> par(mfrow = c(2,1))

> acf.wn500<-acf(x = w, type = "correlation", ylim = c(-1,1), lag.max = 20, xlim

= c(1,20), main = expression(paste("n=500, Estimated ACF plot for ", w[t])))

> acf.wn50<-acf(x = w[1:50], type = "correlation", ylim = c(-1,1), lag.max = 20,

xlim = c(1,20), main = expression(paste("n=50, Estimated ACF plot for ",

w[t])))

> data.frame(h=1:20, acf500 = acf.wn500$acf[1:20], acf50 = acf.wn50$acf[1:20] )

h acf500 acf50

1 1 1.000000000 1.0000000000

2 2 0.013255965 0.0262344888

3 3 0.052784511 -0.0095778060

4 4 -0.003340119 -0.1786548709

5 5 -0.016353677 -0.0741446661

6 6 0.032286863 -0.2637757323

7 7 -0.009322809 -0.0778562611

8 8 -0.033924828 0.0494881741

9 9 -0.023527654 -0.0578820973

10 10 0.010429189 0.0268185125

11 11 -0.075761179 -0.0367459489

12 12 0.046835133 0.1508953983

13 13 -0.035100256 -0.2191634301

14 14 -0.003293960 0.0737340500

15 15 -0.018071353 0.0752325156

16 16 0.035717614 0.0850325590

17 17 -0.029929145 -0.1019136482

18 18 -0.007813102 0.0476876908

19 19 0.044517886 -0.0000201907

20 20 -0.098331715 -0.0593784179

> alpha<-0.05

> #ACF interval limits for Ho:rho(h) = 0 vs. Ha:rho(h)>0

> 0+qnorm(p = c(alpha/2, 1-alpha/2), mean = 0, sd = 1)/sqrt(500)

[1] -0.08765225 0.08765225

> 0+qnorm(p = c(alpha/2, 1-alpha/2), mean = 0, sd = 1)/sqrt(50)

[1] -0.2771808 0.2771808

How many estimated autocorrelation values would you expect to be outside of the interval range? About 1 out of 20 since  = 0.05 and (h) = 0 for h = 1, …, 20.

1.22 – Not stationary since st part depends on t and this ends up being the mean of the series. Notice the ACF pattern repeats every 4th lag.

1