简体   繁体   中英

How to create a baseline forecast with sales data that includes (non-promotional and promotional) sales?

I have a df with a sales column and another column (Base/Promo) coding 1 or 0. I'd like to create a baseline forecast. So I have to exclude/ignore the promotional sales. By doing this there will be multiple gaps in my time-series... Is there a method to forecast baseline sales based on sales data with promotional weeks included?

Here is a reproducible df:

df <- data.frame(Sales =c(50,75,450,56,65,790,45,59,49,63,750,65,49,57,695,834,76,58,69,71,540,830,43), 
Non-Promo/Promo=c(0,0,0,1,0,0,1,0,0,0,0,1,0,0,0,1,1,0,0,0,0,1,1,0))             
df

I hope you can help with this problem, as I'm out of ideas. Many thanks!!!

Let's assume you have weekly data, my_sales , and promotion are promo .

my_sales = ts(c(50,75,450,56,65,790,45,59,49,63,750,65,49,57,695,834,76,58,69,71,
             540,830,43), frequency = 52, start = c(2020,1))

promo = as.data.frame( c(0,0,0,1,0,0,1,0,0,0,0,1,0,0,0,1,1,0,0,0,0,1,1))          

colnames(promo) <- "xreg"

We fit an arima model including promotions as following:

library(forecast)

fit <- auto.arima(my_sales, xreg = as.matrix(promo))

To forecast you need to know future events. So I just created this future_promo example for 11 weeks ahead from your example

future_promo = as.data.frame(c(0,0,0,1,0,0,1,0,0,0,0))

colnames(future_promo) <- "xreg"

fc <- forecast(fit, xreg = as.matrix(future_promo))
plot(fc)
fc

fc$mean is your 11 weeks ahead point forecast

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM