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.

121

This provided evidence of both conditional heteroskedasticity (i.e. volatility clustering) and longmemory

effects. It lead us to conclude that the AR(p) model was insufficient to capture all of

the autocorrelation present.

As we have seen above the MA(q) model was insufficient to capture additional serial correlation

in the residuals of the fitted model to the first order differenced daily log price series. We

will now attempt to fit the MA(q) model to the S&P500.

One might ask why we are doing this is if we know that it is unlikely to be a good fit. This

is a good question. The answer is that we need to see exactly how it is not a good fit. This

is the ultimate process we will be following when we review more sophisticated models that are

potentially harder to interpret.

Let us begin by obtaining the data and converting it to a first order differenced series of

logarithmically transformed daily closing prices as in the previous section:

> getSymbols("^GSPC")

> gspcrt = diff(log(Cl(GSPC)))

We are now going to fit a MA(1), MA(2) and MA(3) model to the series, as we did above for

AMZN. Let us start with MA(1):

> gspcrt.ma <- arima(gspcrt, order=c(0, 0, 1))

> gspcrt.ma

Call:

arima(x = gspcrt, order = c(0, 0, 1))

Coefficients:

ma1 intercept

-0.1284 2e-04

s.e. 0.0223 3e-04

sigma^2 estimated as 0.0001844: log likelihood = 6250.23, aic = -12494.46

Let us make a plot of the residuals of this fitted model, as given in Figure 10.16.

> acf(gspcrt.ma$res[-1])

The first significant peak occurs at k = 2, but there are many more at k ∈ {5, 10, 14, 15, 16, 18, 20, 21}.

This is clearly not a realisation of white noise and so we must reject the MA(1) model as a potential

good fit for the S&P500.

Does the situation improve with MA(2)?

> gspcrt.ma <- arima(gspcrt, order=c(0, 0, 2))

> gspcrt.ma

Call:

arima(x = gspcrt, order = c(0, 0, 2))

Coefficients:

ma1 ma2 intercept

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

Saved successfully!

Ooh no, something went wrong!