0

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!!!

1 Answers1

0

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

Econ_matrix
  • 405
  • 3
  • 9