1. Residuals from regression model
From the two previous chapters we learned about time series modeling as well as regression modeling for predicting and understanding demand of products. Why not combine both of these types of modeling together? That is exactly what we are going to do in this chapter.
First we have to see where we went wrong after our regression models from the previous chapter. In other words, we need to examine our residuals.
2. Linear Regression
Remember back to when we had our linear regression model from the previous chapter. We wanted to minimize the sum of the squared values of our errors. That does mean that we have errors! We want to investigate these errors further.
3. Regression Residuals
You might be wondering how we can improve our estimates and forecasts of future demand. Essentially, how do we reduce our residuals even further?
There are two common ways to pull this off. The first one is easy. Just find more significant variables to add to the model. We saw this in chapter 2. Price wasn't the only thing that influenced demand. So did promotions, holidays, and any other things you might think influences demand.
The second way is to see if your residuals are related over time. If they are, we can use time series models to forecast the residuals themselves!
4. Examine Residuals
Before examining the residuals we need to get them! To do this we can use the residuals function on our regression model object from the previous chapter "model underscore M underscore hi underscore full". We will also want to convert these residuals into an xts object. You have seen this done plenty of times in the course already.
Perfect! Now it is time to view our residuals. Let's look at a histogram of them with a hist function. Let's also look at them over time with the plot function.
5. Residual Plots
From the histogram it appears that we have a rather symmetric distribution. Essentailly we don't have too many points far away from the middle more on one side than another. You might say we have a couple of large points on the right, but overall rather symmetric.
On the bottom plot we see our residuals over time. We expect these residuals to hover around zero due to the nature of linear regression. However, there might be a pattern over time in these residuals.
6. Let's practice!
We will explore that relationship over time in the next video. First you try examining your own residuals from the model you have been building.