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.

79

> set.seed(1)

> x <- seq(1,100) + 20.0*rnorm(1:100)

> set.seed(2)

> y <- seq(1,100) + 20.0*rnorm(1:100)

> plot(x,y)

The plot is given in Figure 8.1.

Figure 8.1: Scatter plot of two linearly increasing variables with normally distributed noise.

There is a relatively clear association between the two variables. We can now calculate the

sample covariance:

> cov(x,y)

[1] 681.6859

The sample covariance is given as 681.6859.

One drawback of using the covariance to estimate linear association between two random

variables is that it is a dimensional measure. That is, it isn’t normalised by the spread of the

data and thus it is hard to draw comparisons between datasets with large differences in spread.

This motivates another concept, namely correlation.

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

Saved successfully!

Ooh no, something went wrong!