Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Forecasting (Revenue for S&P 500 Companies)
Using the baselineforecast Package
by Konstantin Golyaev
Microsoft Azure Machi...
Motivation
• “Prediction is very difficult, especially about the future”
• © Niels Bohr (allegedly)
• We want to:
• Foreca...
Two Ways to Forecast
1. Time-series methods (ARIMA, ETS, STL, etc.)
• Great for modeling trend and seasonality
2. Regressi...
Konstantin Golyaev, useR! 2016, Stanford, CA 46/30/2016
Illustration
• Take small window of series
𝑦1
𝑦2
𝑦3
𝑦4
𝑦5
𝑦6
𝑦7
𝑦8
⋮
Konstantin Golyaev, useR! 2016, Stanford, CA 56/30/20...
Illustration
• Take small window of series
• Fit a model to it, make
forecasts few steps ahead
𝑦1
𝑦2
𝑦3
𝑦4
𝑦5
𝑦6
𝑦7
𝑦8
⋮
𝑓...
Illustration
• Take small window of series
• Fit a model to it, make
forecasts few steps ahead
• Move the window forward
𝑦...
Illustration
• Take small window of series
• Fit a model to it, make
forecasts few steps ahead
• Move the window forward
•...
Illustration
• Take small window of series
• Fit a model to it, make
forecasts few steps ahead
• Move the window forward
•...
What Else Can We Do?
Konstantin Golyaev, useR! 2016, Stanford, CA 106/30/2016
Date-Based Features
Examples:
• Year
• Quarter
• Month
• Week
• Holidays
• Etc…
Konstantin Golyaev, useR! 2016, Stanford, ...
Lags or Other Functions of 𝑦𝑡
• R does not compute lags
correctly when series has gaps
in its index
(e.g. missing months/d...
External Series as Features
• This is very much problem-specific
• What we used in various projects:
• Macroeconomic data ...
Implementation
• All code is combined into baselineforecast R package
• Function ConstructDataset() takes series 𝑦𝑡 and
ex...
Future Work
• Exploratory Data Analysis
• Computing Prediction Intervals
• Decide on the license/distribution model
Have q...
Upcoming SlideShare
Loading in …5
×

Forecasting Multiple Time Series Using the baselineforecast R Package

863 views

Published on

Slides for Konstantin Golyaev's useR! 2016 lightning talk: http://schedule.user2016.org/event/7BYE/forecasting-revenue-for-sp-500-companies-using-the-baselineforecast-package

Published in: Data & Analytics
  • Be the first to comment

  • Be the first to like this

Forecasting Multiple Time Series Using the baselineforecast R Package

  1. 1. Forecasting (Revenue for S&P 500 Companies) Using the baselineforecast Package by Konstantin Golyaev Microsoft Azure Machine Learning Konstantin Golyaev, useR! 2016, Stanford, CA 16/30/2016
  2. 2. Motivation • “Prediction is very difficult, especially about the future” • © Niels Bohr (allegedly) • We want to: • Forecast multiple time series at different horizons • Leverage useful external information, when available • Employ state-of-the-art methods Note: won’t show any results due to five-minute time constraint  Konstantin Golyaev, useR! 2016, Stanford, CA 26/30/2016
  3. 3. Two Ways to Forecast 1. Time-series methods (ARIMA, ETS, STL, etc.) • Great for modeling trend and seasonality 2. Regression-based methods (elastic net, random forest, boosted regression trees, etc.) • Derive power from external information (features) Can we get the best of both worlds? Konstantin Golyaev, useR! 2016, Stanford, CA 36/30/2016
  4. 4. Konstantin Golyaev, useR! 2016, Stanford, CA 46/30/2016
  5. 5. Illustration • Take small window of series 𝑦1 𝑦2 𝑦3 𝑦4 𝑦5 𝑦6 𝑦7 𝑦8 ⋮ Konstantin Golyaev, useR! 2016, Stanford, CA 56/30/2016
  6. 6. Illustration • Take small window of series • Fit a model to it, make forecasts few steps ahead 𝑦1 𝑦2 𝑦3 𝑦4 𝑦5 𝑦6 𝑦7 𝑦8 ⋮ 𝑓7|6 𝑓8|6 ⋮ Konstantin Golyaev, useR! 2016, Stanford, CA 66/30/2016
  7. 7. Illustration • Take small window of series • Fit a model to it, make forecasts few steps ahead • Move the window forward 𝑦1 𝑦2 𝑦3 𝑦4 𝑦5 𝑦6 𝑦7 𝑦8 ⋮ Konstantin Golyaev, useR! 2016, Stanford, CA 76/30/2016
  8. 8. Illustration • Take small window of series • Fit a model to it, make forecasts few steps ahead • Move the window forward • Repeat the process 𝑦1 𝑦2 𝑦3 𝑦4 𝑦5 𝑦6 𝑦7 𝑦8 ⋮ 𝑓8|7 𝑓9|7 ⋮ Konstantin Golyaev, useR! 2016, Stanford, CA 86/30/2016
  9. 9. Illustration • Take small window of series • Fit a model to it, make forecasts few steps ahead • Move the window forward • Repeat the process • Continue until out of data, combine results when done 𝑦7 𝑓7|6 𝑦8 𝑓8|6 𝑦8 𝑦9 ⋮ 𝑓8|7 𝑓9|7 ⋮ Konstantin Golyaev, useR! 2016, Stanford, CA 96/30/2016
  10. 10. What Else Can We Do? Konstantin Golyaev, useR! 2016, Stanford, CA 106/30/2016
  11. 11. Date-Based Features Examples: • Year • Quarter • Month • Week • Holidays • Etc… Konstantin Golyaev, useR! 2016, Stanford, CA 116/30/2016
  12. 12. Lags or Other Functions of 𝑦𝑡 • R does not compute lags correctly when series has gaps in its index (e.g. missing months/days) • So we implemented it Konstantin Golyaev, useR! 2016, Stanford, CA 126/30/2016
  13. 13. External Series as Features • This is very much problem-specific • What we used in various projects: • Macroeconomic data from Federal Reserve Economic Data (FRED) • Web search trends from Bing/Google/etc • Tweets scored for sentiments • External business drivers such as promotions Konstantin Golyaev, useR! 2016, Stanford, CA 136/30/2016
  14. 14. Implementation • All code is combined into baselineforecast R package • Function ConstructDataset() takes series 𝑦𝑡 and external data 𝑋𝑡, returns data frame with target and features • Function FitModel() interfaces with caret package to train any regression learning algorithm and perform time series cross-validation Konstantin Golyaev, useR! 2016, Stanford, CA 146/30/2016
  15. 15. Future Work • Exploratory Data Analysis • Computing Prediction Intervals • Decide on the license/distribution model Have questions? Ping me at Konstantin.Golyaev@Microsoft.com Konstantin Golyaev, useR! 2016, Stanford, CA 156/30/2016

×