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")
This exercise is part of the course
Forecasting in R
Learn how to make predictions about the future using time series forecasting in R including ARIMA models and exponential smoothing methods.
The first thing to do in any data analysis task is to plot the data. Graphs enable many features of the data to be visualized, including patterns, unusual observations, and changes over time. The features that are seen in plots of the data must then be incorporated, as far as possible, into the forecasting methods to be used.
Exercise 1: Welcome to Forecasting Using RExercise 2: Creating time series objects in RExercise 3: Time series plotsExercise 4: Seasonal plotsExercise 5: Trends, seasonality, and cyclicityExercise 6: Autocorrelation of non-seasonal time seriesExercise 7: Autocorrelation of seasonal and cyclic time seriesExercise 8: Match the ACF to the time seriesExercise 9: White noiseExercise 10: Stock prices and white noiseWhat is DataCamp?
Learn the data skills you need online at your own pace—from non-coding essentials to data science and machine learning.