unit8co / darts

A python library for user-friendly forecasting and anomaly detection on time series.
https://unit8co.github.io/darts/
Apache License 2.0
7.96k stars 866 forks source link

[Question] Theta parameter in Theta method confusing #810

Open manujosephv opened 2 years ago

manujosephv commented 2 years ago

First off, let me congratulate for creating a wonderful and easy to use package for time series forecasting. I am featuring this in a new book I'm writing currently.

Now, coming to my question. I saw that the implementation is using the derivations from Unmasking the Theta method by Rob Hyndman et al. I haven't really sat down and broken down that paper, but if my understanding is correct, the SES + drift derivation is only valid for the specific combination of theta values (0 and 2) that was used in the M4 competition.

But I was confused when I saw a theta parameter in the darts implementation. And in the source code, I saw that it is just being used to dampen the trend coefficient in a way.

Am I right in assuming that the theta parameter in the implementation has a very different interpretation and not the theta lines the original paper is talking about? If yes, isn't it confusing to have the parameter as theta?

madtoinou commented 1 year ago

Hi @manujosephv,

Sorry for the delay, I hope that you made great progress on your book.

I agree with your interpretation of the paper and darts implementation:

However, the (0 and 2) combination was used for the M3 competition. For M4, E. Spiliotis and V. Assimakopoulos used the 4Theta method which is also implemented in darts (as FourTheta). This new method allows for an arbitrary integer values of theta, which theta line is modeled using the "theta line 2" before combining it with "theta line 0" (original Theta method).

My guess is that the theta parameter was added to the Theta method because of the theta parameter in the FourTheta model.

Overall, I agree with you that the theta variable of line 120-124 should be changed to something like trend_weight and should be 0 < trend_weight < 1 whereas the theta argument could maybe be changed to theta_line, 0 corresponding to the trend alone, 1 to SES alone and 2 to the default behavior (or simply removed). WDYT @dennisbader ?

Note: I tried to look at the statsmodels implementation, they claim to support arbitrary value of theta using another expression of $\hat{X}$ (equation 5) which rely on the theta values 0 and 2.

manujosephv commented 1 year ago

Thank you for the revert. And glad to see that my understanding is right..

And yes, the book was completed and released last December.

It's here if you want to check it out.

Modern Time Series Forecasting with Python: Explore industry-ready time series forecasting using modern machine learning and deep learning https://amzn.eu/d/eWBPzvF