Why do we care?
Understanding and predicting time series can help us make better decisions. Better decisions can lead to more profit, or less losses, or less wasting of natural resources, and other benefits.
How can we predict the unpredictable?
By breaking down the problem into parts we know how to deal with.
We know how to deal with independent and identically distributed values:
- Draw a histogram and get summary statistics.
- Fit a distribution that makes sense.
- Assume that the distribution will continue to make sense into the future.
Thus, if we can get to i.i.d. values, or something close enough, then we can make predictions.
We predict that the random, patternless noise is going to keep going according to the same distribution as it has in the past.
But what about the patterns?
We can only predict patternless noise, so we:
- get rid of the patterns to get to the noise,
- predict the noise,
- put back the patterns in the reverse order of how we got rid of them.
Models for stationary series
The closest thing to patternless noise (also called white noise) but that isn’t patternless, is stationarity. A stationary time series is one that has patterns but those patterns are at least flat in the long run - they don’t keep going up or keep going down, they instead keep coming back to the same middle ground. Also important is that the patterns don’t change over time.
If we have a stationary time series then we can fit a model for a stationary time series and get the residuals. If we fit the right model then the residuals will be white noise.
The most popular model for a stationary series is the Autoregressive Moving Average (ARMA) model. We will focus on this model the most.
What about trends, seasons and cycles?
- A trend is a long term movement in a time series. It’s when a series keeps going up, or if it keeps going down, but not both.
- A seasonal pattern is when the series moves both up and down with a regular period. The gaps between ups stays the same over time.
- A cycle is when the series moves both up and down in the long run but with a changing period. You don’t know when it will go up again.
All of these make a series non-stationary and have to be individually removed before trying to fit a model for a stationary time series.
If a series is varying around the previous values of the series then we can try to detrend the series using differencing. That’s where you subtract previous values of the series from the current values of the series in an effort to make it stable.
If a series is varying around a line or curve of some kind, then we must try to model this line or curve, and then remove it by obtaining the model residuals.
Each of these methods have their benefits and drawbacks. It’s important to use the correct approach for the series you are working on.
What about the variance?
All of the methods above assume that the variance of the series is constant. If the variance is not constant around the patterns then we must find a way to make it constant around the patterns first.
- Make sure the variance is constant.
- Get the series stationary.
- Fit a model for the stationary series.
- Fit a distribution to the residuals.
- Use your distribution to make intervals for the future uncertainty.
- Add back your stationary model.
- Reverse what you did to get the series stationary, and reverse what you did to get the variance constant.
- Report your predictions and intervals on the original scale.
(If you did nothing at a step then there’s nothing to reverse.)