[MUSIC PLAYING] Welcome to Business Analytics Using Forecasting. In the last videos, we talked about the moving average, a type of smoothing method. In this video, we're going to talk about the operation of differencing, which is a little bit different.
Where as in the moving average we were adding values up, here we're actually going to look at differences between values. What does it mean to difference a time series? The idea is very simple.
We're going to try to remove trend and/or seasonality by taking the differences between values in the series. This is going to be useful if we want to, for example, use a moving average to forecast a series that has a trend or has seasonality. We saw that the moving average can't really capture those patterns.
So differencing will help us remove these patterns beforehand. The difference in operation is very simple. And that's why, again, you'll find that it's pretty popular.
The key concept in differencing is called the lag, and we're going to talk about what it means. So first, what does it mean to difference a series? The differencing operation means taking the difference between two values in a time series.
The lag tells us how far apart these two values are going to be. Here's some popular lags and their uses. Lag-1 differencing means taking the difference between each two neighboring values.
This is useful for removing trend from a series, since the series of differences or jumps between values will no longer contain a trend. Another useful type of differencing is of Lag-M, where M is the number of seasons in our data. Lag-M differencing means subtracting the value from the same season in the previous cycle.
This is useful for removing seasonality. The different series will no longer display seasonality. Finally, we can do the differencing operation twice, and that is called double differencing.
You difference once, and then you apply differencing to the different series. This will be useful if we want to remove both trend and seasonality. Let's see an example of differencing a time series.
Recall the series of monthly ridership on Amtrak trains. By now you probably remember that the series exhibits both a trend and seasonality. So let's try to remove these two components by differencing.
Here's the raw series. We can take a Lag-1 difference, and then our resulting series will no longer display the trend that we see in the original series. Or we can take our raw series and take a Lag-12.
Now we see that the seasonality-- the 12 month seasonality is gone, but the trend remains. So we can actually double difference. Take the series, difference it once by Lag-12, and then difference it again by Lag-1.
This will give us a double difference series, where we no longer see a trend and we no longer see seasonality. The bottom line in differencing is that some forecasting methods can't really deal with trends or seasonality. So we can use differencing as an initial step to remove these patterns.
And then we can use the difference series to forecast with methods such as the moving average. Notice that differencing is useful both when our pattern is global, meaning that it extends in the same way throughout the series, or if it's local if the trend changes throughout the series. Because we're taking local differences, then we can handle both types of these trends or seasonalities.
With this, we finish discussing about differencing. But please remember that this is a useful initial step before some of the other methods that we will be discussing soon. In the next videos, we'll talk about exponential smoothing.