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.

84

Figure 8.2: Correlogram plotted in R of a sequence of normally distributed random variables.

8.5.1 Example 1 - Fixed Linear Trend

The following R code generates a sequence of integers from 1 to 100 and then plots the autocorrelation:

> w <- seq(1, 100)

> acf(w)

The plot is displayed in Figure 8.3.

Notice that the ACF plot decreases in an almost linear fashion as the lags increase. Hence a

correlogram of this type is clear indication of a trend.

8.5.2 Example 2 - Repeated Sequence

The following R code generates a repeated sequence of numbers with period p = 10 and then

plots the autocorrelation:

> w <- rep(1:10, 10)

> acf(w)

The plot is displayed in Figure 8.4.

We can see that at lag 10 and 20 there are significant peaks. This makes sense, since the

sequences are repeating with a period of 10. Interestingly, note that there is a negative correlation

at lags 5 and 15 of exactly -0.5. This is very characteristic of seasonal time series and behaviour

of this sort in a correlogram is usually indicative that seasonality/periodic effects have not fully

been accounted for in a model.

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

Saved successfully!

Ooh no, something went wrong!