13.08.2022 Views

advanced-algorithmic-trading

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

90

9.3.2 Correlogram

We can also plot the correlogram of a DWN using R, see Figure 9.1. Firstly we’ll set the random

seed to be 1, so that your random draws will be identical to mine. Then we will sample 1000

elements from a normal distribution and plot the autocorrelation:

> set.seed(1)

> acf(rnorm(1000))

Figure 9.1: Correlogram of Discrete White Noise.

Notice that at k = 6, k = 15 and k = 18, we have three peaks that differ from zero at the 5%

level. However, this is to be expected simply due to the variation in sampling from the normal

distribution.

Once again, we must be extremely careful in our interpretation of results. In this instance,

do we really expect anything physically meaningful to be happening at k = 6, k = 15 or k = 18?

Notice that the DWN model only has a single parameter, namely the variance σ 2 . Thankfully,

it is straightforward to estimate the variance with R. We can simply use the var function:

> set.seed(1)

> var(rnorm(1000, mean=0, sd=1))

[1] 1.071051

We have specifically highlighted that the normal distribution above has a mean of zero and a

standard deviation of 1 (and thus a variance of 1). R calculates the sample variance as 1.071051,

which is close to the population value of 1.

The key takeaway with Discrete White Noise is that we use it as a model for the residuals.

We are looking to fit other time series models to our observed series, at which point we use DWN

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

Saved successfully!

Ooh no, something went wrong!