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.

161

library:

> library("tseries")

> adf.test(comb)

Augmented Dickey-Fuller Test

data: comb

Dickey-Fuller = -10.321, Lag order = 9, p-value = 0.01

alternative hypothesis: stationary

Warning message:

In adf.test(comb) : p-value smaller than printed p-value

The p-value is small and hence we have evidence to reject the null hypothesis that the series

possesses a unit root. Now we try the Phillips-Perron test:

> pp.test(comb)

Phillips-Perron Unit Root Test

data: comb

Dickey-Fuller Z(alpha) = -1016.988, Truncation lag parameter = 7,

p-value = 0.01

alternative hypothesis: stationary

Warning message:

In pp.test(comb) : p-value smaller than printed p-value

Once again we have a small p-value and hence we have evidence to reject the null hypothesis

of a unit root. Finally, we try the Phillips-Ouliaris test (notice that it requires matrix input of

the underlying series constituents):

> po.test(cbind(2*x,-1.0*y))

Phillips-Ouliaris Cointegration Test

data: cbind(2 * x, -1 * y)

Phillips-Ouliaris demeaned = -1023.784, Truncation lag parameter = 9,

p-value = 0.01

Warning message:

In po.test(cbind(2 * x, -1 * y)) : p-value smaller than printed p-value

Yet again we see a small p-value indicating evidence to reject the null hypothesis. Hence it

is clear we are dealing with a pair of series that are cointegrated.

What happens if we instead create a separate combination with, say p = −1 and q = 2?

> badcomb <- -1.0*x + 2.0*y

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

Saved successfully!

Ooh no, something went wrong!