# Predicting millions of independent time series, using them to help each other

This is a very general problem faced by different types of companies. Predict future customer behavior over time.

Imagine that we have 1 million customers with their own resources over time, forming a time series. The classic techniques (statistics with ARIMA filters, Bayesian approach as FBprophet or purely computational as LSTM) here is not very suitable, as I would consider that each series is reasonably independent, many series are super sparse or have just started and treated them individually who train a model for each series. So that if we run individual forecasts it would be very bad.

The most conservative approach asks a first classifier to understand what the time series is like (like a grouper species), so we have curves with the same seasonality and trends and then normalize so that the level is the same. We train the models for each of these groups and then go back to the old level and have an individual forecast.

I would like to know if there is a more suitable technique or a canonical solution for the model to understand and predict all series more accurately, using "knowledge of the group" (of the time series that are more similar) in a more scientific and scalable way.

• Can you clarify what you mean by "I would consider that each series team is completely independent". First, what is a series team. Second, is th eproblem you are trying to solve one where we assume each series is independent or not? Feb 12 at 14:19
• Thanks for the comment. I believe it was a translation problem. I will remove the word team. and switch from completely independent to reasonably independent. Feb 12 at 17:14
• So what you are saying is you have a large number of time series, most time series are independent from one another, but for a given time series it likely depends on a few others? Feb 12 at 18:52
• Imagine that each time series is a store. They are independent, but some may share some trends that the model can use to help each other's predictions. For example, it may be that part of these stores sell sweets and another part sell furniture. There is no feature that defines this other than the behavior of the time series itself. Feb 13 at 12:12
• I have responded below, your question is very broad so I have attempted to point you towards two different ways to approach this problem that will give you interpretable models. Feb 15 at 22:30

There are two general forecasting techniques I will point you towards.

The first is hierarchical forecasting. This is a good method if you data has a structure where you need to forecast individual series, but also aggregated series (for example forecast each individual item in a store, plus each store's sales). Rob Hyndman has published quite a few papers on this I would point you to this textbook chapter Hierarchical Forecasting - Hyndman (2019), as well as this paper Coherent Probabilistic Forecasts for Hierarchical Time Series - Hyndman (2017). Also along the lines of this is the M5 Forecasting Competition (2020) which took place last year.

The second is vector autoregression with sparsity. It seems from your question that there is some dependence between the time series, but only a small subset of the time series will affect any given series. An example of this can be found in the following paper Sparse Vector Autoregressive Modeling - Davis et. al (2012) or Structured Regularization for Large Vector Autoregressions with Exogenous Variables. In both papers they seek to fit a VAR model where the coefficient matricies are relatively sparse; this is similar to how in standard regression introducing regularization can sometimes improve performance.

A good resource on how to implement these models is the CRAN Task View: Time Series Analysis. As you will be able to see under the heading Multivariate Time Series Models there are a few R packages that can do this type of time series analysis.

• Excellent answers, thank you very much. Could you share any python implementation? Feb 16 at 21:36
• From my knowledge Python has the basics, but not much beyond that. Fitting a simple VAR model can be done in statsmodels statsmodels.org/dev/vector_ar.html. Feb 17 at 2:39

Could use a Bayesian hierarchical model where each person is a different level.

• Thanks for the reply Mathew, it seems like a really good approach. Some points. What would you use as a hierarchy since the series are independent? As it is a Bayesian method, would it be feasible to run simulations for millions of series? Feb 11 at 18:13