Autoregressive and moving average models tend to capture different relationships. The nice thing is, you can get the best of both by adding them together. An autoregressive moving average is defined with a p and q. The p is the lag for the autoregression, the q is the lag for moving average. A variation of the autoregressive moving average is the autoregressive integrated moving average. This concept is used in a trading strategy called Pairs trading. First, let’s build some intuition that will help us when we study autoregressive integrated moving averages. Let’s say we want to describe the position of a turtle. The turtle is walking at a regular pace. So, its position goes from zero, then one, then two, and so on. We noticed that the turtle is moving at a regular pace. So, we can describe its speed, or the distance over time, as a single number. For example, this turtle is moving at one meter per second. If we plot the turtle’s position over time, it is not constant. Its position over time will look like a line that slopes upward. However, if we plot the turtle’s speed over time, it is a constant one meter per second. The plot of speed over time is a horizontal line. Now let’s think about how the turtle’s position is related to its speed. If we look at the turtle’s position over time, the slope of that line is its speed, or meters per second. Going the other way, we look at the plot of the turtle’s speed over time and take the cumulative sum. So, for instance, at each second, we add one meter. So, we get one meter, two meters, three meters, and so on. This is actually the area under the horizontal line, and is also the position of the turtle as time goes on. So, what did we learn here? In general, taking the difference between each period is called the time difference or item wise difference. If you take the time difference of your data, you may be able to describe your data more easily as a constant number. If you remember from calculus, taking the derivative of a straight line gives the slope of that line. This slope gives us a way to describe the line with a constant. To go from speed back to position, we can take the integral. This is finding the area under the curve or taking the cumulative sum. Taking the integral lets us translate from the speed back to position. We will now apply these concepts of time difference to learn about the autoregressive integrated moving average. Recall that regression-based time series models require the data to be stationary. When data is not stationary, the mean, variants, or co-variants may change over time, and it’s hard to use the past to predict the future. One way to get a stationary time series is by taking the difference between points in the time series. The time difference may also be called the rate of change or the item wise difference. We call that the rate of change between periods, or the rate of return, can be calculated by taking the ratio of the current price divided by the previous price. When you express your data in terms of logs, this ratio becomes a difference between your current log price and the previous log price. When working with financial data, we usually find that asset price time series have a property such that their time difference is stationary. In other words, we like working with returns and not prices because the time series are more stable. In math terms, we say that the original price data is integrated of order one. We also say that the log returns of this data is integrated of order zero. So, when working the time series, you can check if it is stationary using a statistical test called the augmented Dickey Fuller test. If the augmented Dickey Fuller test gives a p-value that is 0.05 or less, then we can assume that the time series is stationary. If the data is not stationary, we can take the time difference then run the augmented Dickey-Fuller test to see if the time difference is stationary. If it is stationary, then we can say that this time difference is integrated of order zero. We can also say that the original time series is integrated of order one. You may need to take the time difference multiple times. Then, once you find a time difference that is stationary, you refer to the original data as integrated of order d where d is the number of times that you had to take the time difference. Also, once we have a stationary time series, we can model it with an autoregressive moving average. Note that being familiar with the integrated order one and integrated ordered zero time series will help you as you learn about co-integration and pairs trading.