Applying Ljung-Box tests to return data
As you saw in the video, this code applies the Ljung-Box test to the ftse
data with a lag of 10:
Box.test(ftse, lag = 10, type = "Ljung")
In this exercise, you will carry out a Ljung-Box test for serial correlation on the time series djx
which contains the Dow Jones daily index returns for 2008-2011, as well as on all the individual equity return series in djall
which contains the Dow Jones data for 2006-2015. You will implement this test on both the raw return series and the absolute values of the series, which you can calculate with abs()
. Both djx
and djall
are loaded in your workspace.
You should notice that while the hypothesis of no serial correlation is rejected for many of the raw return series, it is rejected overwhelmingly for all of the absolute value series.
This exercise is part of the course
Quantitative Risk Management in R
Exercise instructions
- Apply the Ljung-Box test to the Dow Jones index returns
djx
with a lag of 10. - Apply the Ljung-Box test to the absolute values of
djx
with a lag of 10. - Use the
apply()
function to perform the Ljung-Box test, with a lag of 10, for each of the equity return series indjall
. - Use the
apply()
function to perform the Ljung-Box test, with a lag of 10, for the absolute values of the data indjall
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Apply the Ljung-Box test to djx
Box.test(___, lag = ___, type = ___)
# Apply the Ljung-Box test to absolute values of djx
___(___)
# Apply the Ljung-Box test to all return series in djall
apply(___, 2, Box.test, lag = ___, type = ___)
# Apply the Ljung-Box test to absolute values of all returns in djall
___(___)