13.08.2022 Views

advanced-algorithmic-trading

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

159

autocorrelation:

> layout(1:2)

> acf(z)

> acf(diff(z))

Figure 12.2: Correlograms of z t and the differenced series of z t

Hence this realisation of z t clearly looks like a random walk. The next step is to create x t

and y t from z t , using p = 0.3 and q = 0.6, and then plot both:

> x <- y <- rep(0, 1000)

> x <- 0.3*z + rnorm(1000)

> y <- 0.6*z + rnorm(1000)

> layout(1:2)

> plot(x, type="l")

> plot(y, type="l")

As you can see they both look similar. Of course they will be by definition–they share the

same underlying random walk structure from z t . We can now form the linear combination, comb,

using p = 2 and q = −1 and examine the autocorrelation structure:

> comb <- 2*x - y

> layout(1:2)

> plot(comb, type="l")

> acf(comb)

It is clear that the combination series comb looks very much like a stationary series. This is

to be expected given its definition.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!