business-science / modeltime

Modeltime unlocks time series forecast models and machine learning in one framework
https://business-science.github.io/modeltime/
Other
522 stars 79 forks source link

Add external regressors #59

Closed ghost closed 3 years ago

ghost commented 3 years ago

Thanks, Matt for this amazing package! I'm a big fan of tidymodels and when I saw your package I couldn't wait to try it.

I took a look at the doc, and I could not find an example with external regressors, is it possible to do that?

Something of the type you'll do in dynlm:

dfm1 <- dynlm(consumption ~ gnp + L(consumption), data = USDistLag)

Where L is the lag operator that can be say 1...n

mdancho84 commented 3 years ago

Hi @mrepetto94,

External Regressors are essential to ML. We do this in one of 2 ways:

  1. Workflow Method - We process the data either with recipe or when extending into the future and adding lags, rolling features. We then use a workflow to add the model, recipe, and fit() to the data.
  2. Parnsip Method - We create a parsnip model_spec and train using a formula interface with fit(). E.g. model_spec %>% fit(consumption ~ gnp + L(consumption), data = USDistLag).

I teach how to do all of this in my High-Performance Time Series Forecasting Course. The advantage to taking the course is that you will learn specifically how to analyze time series in 3 parts:

  1. Feature Engineering - How to generate important features
  2. Machine Learning - How to create models, tune models, ensemble models, and scale a single model to many time series.
  3. Deep Learning - How to develop deep learning models that scale to many time series.

This is a paid course, but it may be worth it if your organization depends on your ability to forecast. They may even pay for it. But that's the ultimate resource if you are interested in using modeltime to further your forecasting.

ghost commented 3 years ago

Thank you Matt for the fast response! I will definitely do your course in the summer period :-)