0

I have retail sales data from Jul'17 to Jul'18, and would like to extend the series to the period Jan'17 ~ Jun'17, for which I don't have any data.

Since this is retail data I want to use the prophet package, as it accounts holidays and monthly/yearly trends. However I can't seen to make it predict past data, as I can't call make_future_dataframe to give me a past period.

I can't share data, so in my example y was generated from rnorm()

data = structure(list(ds = structure(c(17683, 17652, 17622, 17591, 17563, 
17532, 17501, 17471, 17440, 17410, 17379, 17348), class = "Date"), 
y = c(104.668732663406, 98.3902718818212, 109.061616978181, 
109.838504824619, 111.732728009024, 102.108143707743, 99.4680518699638, 
84.228075141372, 110.844516862675, 92.5728013090567, 80.8504745693786, 
108.721168531315)), .Names = c("ds", "y"), row.names = c(NA, 
-12L), class = "data.frame")

m <- prophet(data,seasonality.mode = "multiplicative",yearly.seasonality = T)
future <- make_future_dataframe(m, periods = 6, freq = "1 month")
forecast <- predict(m, future)  %>% data.table() 

Is there a way I can make prophet give me past predictions without having to fill in fake dates?

Thanks

Fino
  • 1,774
  • 11
  • 21

1 Answers1

0

If anyone stumbles upon this later, the solution is to create the future dataframe manually:

future = data.frame(
  "ds" = as.Date(c(
  "01/01/2017", #No Data
  "02/01/2017", #No Data
  "03/01/2017", #No Data
  "04/01/2017", #No Data
  "05/01/2017", #No Data
  "06/01/2017", #No Data
  "07/01/2017", #Data
  "08/01/2017", #Data
  "09/01/2017", #Data
  "10/01/2017", #Data
  "11/01/2017", #Data    
  "12/01/2017", #Data
  "01/01/2018", #Data
  "02/01/2018", #Data
  "03/01/2018", #Data
  "04/01/2018", #Data
  "05/01/2018", #Data
  "06/01/2018"),
  format = "%m/%d/%Y"
  )
)

predict() will return the forecast for all periods, even if you only provide data for the "future".

Fino
  • 1,774
  • 11
  • 21