0
$\begingroup$

Could someone please help me figure out how to adjust my code so that it gives better predictions? Right now they are way to high.

I'm wondering if it is something to do with the holiday lag. I'm not sure if I am using the lower_window and upper_window correctly. How can I adjust my code to have weekly seasonality and to reflect the holiday lags? Normally there is a surge in sales before the holiday and then sales lag after the holiday, so I wasn't sure how to create windows that reflect that.

#sales projections for CSD using Prophet
library(prophet)
library(dplyr)
memorial <- data_frame(
    holiday = 'memorialday',
    ds = as.Date(c('2015-05-25','2016-05-30','2017-05-29',
                   '2018-05-28','2019-05-27','2020-05-25',
                   '2021-05-31')),
    lower_window = -2,
    upper_window = 0
)
easter <- data_frame(
  holiday = 'easterday',
  ds = as.Date(c('2015-04-05','2016-03-27','2017-04-16',
                 '2018-04-01','2019-04-21','2020-04-12',
                 '2021-04-04')),
  lower_window = -2,
  upper_window = 0
)
labor <- data_frame(
  holiday = 'laborday',
  ds = as.Date(c('2015-09-07','2016-09-05','2017-09-04',
                 '2018-09-03','2019-09-02','2020-09-07',
                 '2021-09-06')),
  lower_window = -1,
  upper_window = 0

)
holidays <- bind_rows(memorial,easter,labor)
n <- prophet(holidays = holidays)
n <- add_country_holidays(n,country_name = 'US')
colnames(Group_8_sales_projection_input_data) = c('ds','y')
n <- fit.prophet(n,Group_8_sales_projection_input_data)
n$train.holiday.names
future <- make_future_dataframe(n,periods = 365)
forecast <- predict(n, future)
prophet_plot_components(n,forecast)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.