Forecasting Product Demand in R
Aric LaBarr, Ph.D.
Senior Data Scientist, Elder Research
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")
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