Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time Series - Multiple regression (VAR, Vector Autoregression) #77

Open
coforfe opened this issue Mar 23, 2021 · 15 comments
Open

Time Series - Multiple regression (VAR, Vector Autoregression) #77

coforfe opened this issue Mar 23, 2021 · 15 comments
Labels
enhancement New feature or request

Comments

@coforfe
Copy link

coforfe commented Mar 23, 2021

Hi Matt,

First of all, thanks for all you are doing around modeltime. It's clearly a big step forward for TimeSeries modeling.

Perhaps it is already covered but I am not able to see if in modeltime is considered the case where you can put several time series together. Define one of them as a target and check how influencial are the rest (as predictors). What I have seen so far is how to model a univariant time series, by extracting different features and model it.

Thanks again,
Carlos Ortega.

@mdancho84
Copy link
Contributor

mdancho84 commented Mar 23, 2021

Hey @coforfe ,
Thanks for this. I'll add VAR to the roadmap. Just not completely sure what your needs are.

The core idea for modeltime is to allow the user to add regressors and developed scalable forecast models using any algorithm.

The VAR data format is, in its most basic form, just a regression. So you can do regression in modeltime already. For the VAR problem, just:

  1. Make a tibble() with each of your series
  2. Specify a target and predictors in a recipe.
  3. Model.
  4. Use the modeltime workflow to visualize the results.

The only thing I can think of possibly adding helpers around formatting the data as a VAR problem.

Also maybe adding feature importance tools down the road.

I'm interested to hear more of what your needs are so I can understand if I am on the right track.

References

Vector Autoregressions - Econometrics with R.

@mdancho84 mdancho84 changed the title Time Series - Multiple regression. Time Series - Multiple regression (VAR, Vector Autoregression) Mar 23, 2021
@coforfe
Copy link
Author

coforfe commented Mar 23, 2021

Hi Matt,

Thanks.
Well quite frankly I was not aware that already with modeltime it was possible to model a time series using another ones as predictors. I do not remember seeing an example of this in the vignettes or in the Youtube (the ones you did with Max and with Josh). If it is already available in your "Labs Pro", I will subscribe for that.

Thanks again,
Carlos.

@mdancho84
Copy link
Contributor

Yes, modeltime is designed for many features including using other time series as predictors. The challenge is that you need to know predict using the lags of the other series. We can now do this with recursive(), which is being actively worked on currently. Learning Labs PRO will have a full demonstration once it's ready.

Regarding learning more, here's where to go for topics.

Time Series Forecasting Course

The High-Performance Time Series Course teaches the main elements of the ecosystem in incredible depth.

image

Learning Labs PRO - Special Time Series Topics

We have a special time series section of labs that address special topics in Modeltime like panel forecasting, recursive() for a forecasting with lags, etc. We have more coming including the new additions such as modeltime.h2o and panel recursion.

image

@mdancho84 mdancho84 added the enhancement New feature or request label Mar 23, 2021
@coforfe
Copy link
Author

coforfe commented Mar 23, 2021

OK. Matt.
Thanks a lot for your clear references and I will forward to seeing this new functionality available in modeltime.
Thanks again,
Carlos.

@AlbertoAlmuinha
Copy link
Contributor

I think VAR can be implemented through recursive() function using lags as the transformation function, basically what we are doing is taking the previous lags of the xregs to fulfill the NA values and forecast.

Maybe we could explain the relation between recursive and VAR models to be more concise.

Regards,

@mdancho84
Copy link
Contributor

Yes, this is probably a Learning Lab where students can learn how to do this. We'll have learning labs on topics like:

  • Panel Recursion (using lags)
  • VAR (using lags of time series)
  • Gams (Once we build it)
  • Garch (Once we build it)

@GitHunter0
Copy link

GitHunter0 commented Jun 24, 2021

A fundamental method that is used a lot in Finance and Economics and generalizes VAR (vector autoregressive) is VECM (vector error-correction models).

Do you plan to incorporate it too? I believe it would be an important addition to modeltime.

As reference, you may check Stata's documentation (hyperlinks above) and Python's statsmodels

Thank you

@mdancho84
Copy link
Contributor

@GitHunter0 Thanks for this. VAR was added to the roadmap some time ago so we have on our radar. May take a bit but will try to get in soon.

For most up to date roadmap check out issue #5.

@GitHunter0
Copy link

GitHunter0 commented Jun 24, 2021

Thank you @mdancho84 , I know you are pretty busy right now, doing great work as always.

PS: A good thing about VECM methodology is that not only you can specify the system of equations (like VAR) but it can also handle non-stationary series. It is a well established method to forecast multiple time series that depend on each other and probably should be the baseline to test the performance of the new deep learning methods.

@mdancho84
Copy link
Contributor

@GitHunter0 Is there a preferred implementation in R?

@spsanderson
Copy link

@mdancho84 maybe this link will give some light:

https://www.r-econometrics.com/timeseries/vecintro/

@GitHunter0
Copy link

@mdancho84 , unfortunately I believe there are very few options of packages that handle VEC models in R, tsDyn must be the main/best one (although its focus is on more advanced (nonlinear) VAR/VEC versions). I couldn't find an R package that comes close to Stata's professional quality, clear API and well documented implementation (however it is a paid software). Therefore, I have very little experience working with VEC and VAR models in R, which is a shame since it opens up much more possibilities than Stata. timetk and modeltime are game changers in that regard, providing a unified and well designed system to work with time series. The more packages like yours evolve, the more users will be able to break free from proprietary software and take advantage of the fantastic capabilities that R offers.

@vidarsumo
Copy link

For VAR and VECM I would go for the vars package in R (https://cran.r-project.org/web/packages/vars/vignettes/vars.pdf). I've only used VAR/VECM to analyze impulse response functions. For forecasting I would always go for other methods, something that is already available in modeltime.

What I'm excited for is GPVAR (https://ts.gluon.ai/api/gluonts/gluonts.model.gpvar.html) which, if I understand it fully, allows you to model thousands of time series that are functions of each other. Something I think VAR would struggle with.

@mdancho84
Copy link
Contributor

The GPVAR might not be that bad. I'll have to take a look.

@Shafi2016
Copy link

Shafi2016 commented Sep 13, 2021

Hi, @mdancho84 It would be good to add DeepVAR(https://ts.gluon.ai/api/gluonts/gluonts.model.deepvar.html)
. DeepVAR estimator, which is a multivariate variant of DeepAR. I think this will solve our Xreg problem in DeepAR as most of us are interested in it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

7 participants