A Comprehensive Guide on Interaction Terms in Time Series Forecasting | by Eryk Lewinson | Aug, 2023

Learn how to improve the fit of your linear models by making them more flexible to trend changes

Modeling time series data can be challenging (and fascinating) due to its inherent complexity and unpredictability. For example, long-term trends in time series can change drastically due to certain events. Recall the beginning of the global pandemic, when businesses such as airlines or brick-and-mortar shops saw a quick decline in the number of customers and sales. In contrast, e-commerce businesses continued to operate with less disruption.

Interaction terms can help with modeling of such patterns. They capture complex relationships between variables and, as a result, lead to more accurate predictions.

This post explores:

  • Interaction terms in the context of time series forecasting
  • Benefits of interaction terms when modeling complex relationships
  • How to effectively implement interaction terms in your models

Interaction terms enable you to investigate whether the relationship between the target and a feature changes depending on the value of another feature. For more details, please refer to my previous article.

Figure 1 shows a scatterplot that represents the relationship between miles per gallon (target) and the weight of a vehicle (feature). The relationship is quite different depending on the transmission type (another feature).

Figure 1. Best fit lines for vehicle transmission type, including interaction terms

Without using interaction terms, a linear model would not be able to capture such a complex relationship. Effectively, it would assign the same coefficient for the weight feature, regardless of the type of transmission. Figure 1 shows the coefficients (slope of the line) by weight feature, which are drastically different for different transmission types.

To overcome this fallacy and make the linear model more flexible, we can interaction terms. In…

Source link

Leave a Comment