Forecasting with regression

R로 제품 수요 예측하기

Aric LaBarr, Ph.D.

Senior Data Scientist, Elder Research

Forecasting with Time Series

R로 제품 수요 예측하기

Forecasting with Regression

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!
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")
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
R로 제품 수요 예측하기

Let's practice!

R로 제품 수요 예측하기

Preparing Video For Download...