Stock prices and white noise
As you learned in the video, white noise is a term that describes purely random data. You can conduct a Ljung-Box test using the function below to confirm the randomness of a series; a p-value greater than 0.05 suggests that the data are not significantly different from white noise.
> Box.test(pigs, lag = 24, fitdf = 0, type = "Ljung")
There is a well-known result in economics called the "Efficient Market Hypothesis" that states that asset prices reflect all available information. A consequence of this is that the daily changes in stock prices should behave like white noise (ignoring dividends, interest rates and transaction costs). The consequence for forecasters is that the best forecast of the future price is the current price.
You can test this hypothesis by looking at the goog
series, which contains the closing stock price for Google over 1000 trading days ending on February 13, 2017. This data has been loaded into your workspace.
This is a part of the course
“Forecasting in R”
Exercise instructions
- First plot the
goog
series usingautoplot()
. - Using the
diff()
function withautoplot()
, plot the daily changes in Google stock prices. - Use the
ggAcf()
function to check if these daily changes look like white noise. - Fill in the pre-written code to do a Ljung-Box test on the daily changes using 10 lags.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Plot the original series
___
# Plot the differenced series
___
# ACF of the differenced series
___
# Ljung-Box test of the differenced series
___(___, lag = ___, type = "Ljung")