Forecasting with regression

Forecasting Product Demand in R

Aric LaBarr, Ph.D.

Senior Data Scientist, Elder Research

Forecasting with Time Series

Forecasting Product Demand in R

Forecasting with Regression

Forecasting Product Demand in R

Future Input Variables

  • How to "predict" future input variables?
    • Holidays and Promotions: NO WORRIES - we know these ahead of time
  • Prices - Possible problem!
    • Prices set ahead of time (our assumption)
    • Forecast future prices with time series!
Forecasting Product Demand in R

Future Input Variables Example

v.dates_v <- as.Date("2017-02-12")

valentine_v <- as.xts(1, order.by = v.dates_v) dates_valid <- seq(as.Date("2017-01-01"), length = 22, by = "weeks")
valentine_v <- merge(valentine_v, dates_valid, fill = 0)
l_M_hi_p_valid <- log(bev_xts_valid[,"M.hi.p"])
model_M_valid <- data.frame(as.vector(l_M_hi_p_valid), as.vector(valentine_v)) colnames(model_M_valid) <- c("log_price", "valentine")
Forecasting Product Demand in R

Future Regression Example

pred_M_hi <- predict(model_M_hi_full, model_M_valid)

head(pred_M_hi)
       1        2        3        4        5        6 
6.128652 6.129163 5.975786 6.030943 6.048169 6.099596
pred_M_hi <- exp(pred_M_hi)

head(pred_M_hi)
       1        2        3        4        5        6 
458.8170 459.0519 393.7775 416.1070 423.3371 445.6778
Forecasting Product Demand in R

Let's practice!

Forecasting Product Demand in R

Preparing Video For Download...