**The Noonification: The Battle Between Proprietary and Open Source AI (11/3/2023)**

107 reads

by Sarem SeitzMay 18th, 2023

**Disclaimer:** Title heavily inspired by this great talk; Photo by

As the name implies, today we want to consider almost trivially simple models. Although the current trend points towards complex models, even for time-series models, I am still a big believer in simplicity. In particular, when your dataset is small, the subsequent ideas might be useful.

To be fair, this article will probably be most valuable for people who are just starting out with time-series analysis. Anyone else should check the table of contents first and decide for themselves if they want to continue.

Personally, I am still quite intrigued by how far you can push even the most simplistic time-series models. The upcoming paragraphs show some ideas and thoughts that I have been gathering on the topic over time.

We start with the simplest (probabilistic) way to model a (univariate) time-series. Namely, we want to look at plain **i**ndependently, **i**dentically, **d**istributed randomness:

This implies that all our observations follow the same distribution at any point in time (**identically** distributed). Even more importantly, we presume no interrelation between observations at all (**independently** distributed). Obviously, this precludes any autoregressive terms as well.

Probably your first question is if such models aren't too simplistic to be useful for real-world problems. Certainly, most time-series are unlikely to have no statistical relationship with their own past.

While those concerns are true by all means, we can nevertheless deduce the following:

Any time-series model that is more complex than a pure-noise model should also produce better forecasts than a pure-noise model.

In short, we can at least use random noise as a benchmark model. There is arguably no simpler approach to create baseline benchmarks than this one. Even smoothing techniques will likely require more parameters to be fitted.

Besides this rather obvious use-case, there is another potential application for i.i.d. noise. Due to their simplicity, noise models cand be useful for very small datasets. Consider this: If big, complex models require large datasets to prevent overfitting, then simple models require only a handful of data.

Of course, it is debatable what dataset size can be seen as 'small'.

Now, things are becoming more interesting. While raw i.i.d. noise cannot account for auto-correlation between observations, integrated noise can. Before we do a demonstration, let us introduce the *differencing operator*:

If you haven't heard about differencing for time-series problems yet - great! If you have, then you can hopefully still learn something new.

With the difference operator in our toolbox, we can now define an *integrated time-series*:

First, you probably noticed the concept of exponentiating the difference operator. You can simply think of this as performing the differentiation several times. For the squared difference operator, this would look as follows:

As we will see, multiple difference operators allow us to handle different time-series patterns at once.

Third, it is common convention to simply write

We will happily adopt this convention here. Also, we call such time-series *simply integrated* without referencing its order or seasonality.

Obviously, we also need to re-transform a difference representation back to its original domain. In our notation, this means we invert the difference transformation, i.e.

must hold for arbitrary difference transformations. If we expand this formula, we get

These simplifications follow from the fact the difference operator is a linear operator (we won't cover the details here). Technically, the last equation merely says that the next observation is a sum of this observation plus a delta.

In a forecasting problem, we will typically have a prediction for the change

Let's denote this prediction as

to stress that it is not the actual change, but a predicted one. Thus, the forecast for the integrated time-series is

Afterwards, we apply this logic recursively as far into the future as our forecast should go:

By now, you can probably imagine what is meant by an integrated noise model. In fact, we can come up with countless variants of an integrated noise model by just chaining some difference operators with random noise.

One possibility would be a simply integrated time-series, i.e.

It is an interesting exercise to simulate data from such a model using a plain standard normal distribution.

As it turns out, samples from this time-series appear to exhibit linear trends with potential change points. However, it is clear that these trends and change points occur completely at random.

This implies that simply fitting piece-wise linear functions to forecast such trends can be a dangerous approach. After all, if the changes are occurring at random, then all linear trend lines are mere artifacts of the random data-generating process.

As an important disclaimer, though, '*unpredictable*' means unpredictable from the time-series itself. An external feature might still be able to accurately forecast potential change points. Here, however, we presume that the time-series is our solely available source of information.

Below, you can see an example of the described phenomenon. While there appears to be a trend change at around t=50, this change is purely random. The upward trend after t=50 also stalls at around t=60. Imagine how your model would have performed if you extrapolated the upward trend after t=60.

Of course, the saying goes 'never say never', even in those settings. However, you should really know what you are doing if you apply such models.

Similarly to how a simple integration produceds trends, we can also create seasonal patterns:

Formally, we now need the s-th difference of our seasonal process to be a stationary process, e.g.

The inverse operation - transforming the i.i.d. process back to the seasonally integrated - works similarly to the one before:

You can think of the inverse operation of seasonal differencing as a *cumsum* operation over `s`

periods. Since I am not aware of a respective, native Python function, I decided to do `reshape->cumsum->reshape`

to get the desired outcome. Below is an example with `s=4`

:

As you can see, the generated time-series looks reasonably realistic. We could easily sell this as quarterly sales numbers of some product to an unsuspecting Data Scientist.

We could even combine both types of integration to generate a seasonal time-series with trending behavior:

At this point, you will probably realize that the title of this article was a little click-baity. Integrated time-series are, in fact, purely linear models. However, I believe that most people wouldn't consider a model with, more-or-less, zero parameters a typical linear model.

Another interesting property of integrated time-series is the ability to model memory effects.

This effect can be seen particularly well when there are larger shocks or outliers in our data. Consider the below example, which shows seasonal integration of order `s=12` over i.i.d. draws from a standard Cauchy distribution:

The first large shock in the i.i.d. Cauchy series at around t=20 is sustained over the whole integrated series on the right. Over time, more shocks occur, which are also sustained.

This memory property can be very useful in practice. For example, the economic shocks from the pandemic have caused persistent changes in many time-series.

Let us now use the *AirPassengers* dataset from Nixtla's neuralforecast for a quick evaluation of the above ideas. If you are regularly reading my articles, you might remember the general procedure from this one.

In order to obtain a stationary, i.i.d. series we perform the following transformation:

First, the square-root stabilizes the increasing variance. The two differencing operators then remove seasonality and trend. For the respective re-transformation, check the code further down below.

We can also check a histogram and density plot of the stabilized time-series:

Our stationary series looks also somewhat normally distributed, which is always a nice property.

Now, let us create the forecast for the test period. Presuming that we don't know the exact distribution of our i.i.d. series, we simply draw from the empirical distribution via the training data.

Hence, we simulate future values by reintegrating random samples from the empirical data:

This looks very good - the mean forecast is very close to the test data. In addition, our simulation allows us to empirically sample the whole forecast distribution. Therefore, we can also easily add confidence intervals.

Finally, let us see how our approach compares against rather complex time-series models. To do so, I went with Nixtla's implementation of NBEATS and NHITS:

Below are the respective *RMSEs* for the test set:

**Simple Model:**25.5021**NBEATS:**42.6277**NHITS:**62.6822-

As we can see, our almost trivial model has beaten two sophisticated time-series models by a fair margin. Of course, we need to emphasize that this doesn't allow to draw any general conclusions.

Rather, I'd expect the neural models to outperform our simple approach for larger datasets. Nevertheless, as a benchmark, those trivial models are always a worthwhile consideration.

As stated multiple times throughout this article:

A seemingly complex time-series could still follow a fairly simple data-generating process.

In the end, you might spend hours trying to fit an overly complex model even though the underlying problem is almost trivial. At some point, somebody could come along, fit a simple ARIMA(1,0,0), and still outperform your sophisticated neural model.

To avoid the above worst-case scenario, consider the following idea:

When starting out with a new time-series problem, always start with the simplest possible model and use it as a benchmark for all other models.

Although this is common knowledge in the Data Science community, I feel like it deserves particular emphasis in this context. Especially due to nowadays' (to some extent justified) hype around Deep Learning, it can be tempting to directly start with something fancy.

For many problems, this might just be the right way to go. Nobody today would consider a Hidden Markov Model for NLP today when LLM embeddings are available almost for free now.

Once your time-series becomes large, however, modern Machine Learning will likely be better. In particular, Gradient Boosted Trees are very popular for such large-scale problems.

A more controversial approach would be, you guessed it, Deep Learning for time-series. While some people believe that these models don't work as well here, their popularity at tech firms like Amazon probably speaks for itself.

**[1]** Hamilton, James Douglas. *Time series analysis*. Princeton university press, 2020.

**[2]** Hyndman, Rob J., & Athanasopoulos, George. *Forecasting: principles and practice*. OTexts, 2018.

L O A D I N G

. . . comments & more!

. . . comments & more!