predict_sales | R Documentation |
This function enables to create forecasts based on historical sales data. It considers a multitude of models and selects the model that had the best performance on the testing set.
predict_sales(sales_data, frequency = 52, start = c(2014, 1), end = c(2019, 12), forecast_horizon = 52, size.te.set = 52, promo_done = FALSE, future_impactors = NA, criterion = "accuracy", sizeroll = 11)
sales_data |
A vector containing historical sales data. |
frequency |
A numerical value specifying the frequency of the seasonality. |
start |
A vector of length 2 with the date of the first observation. It contains first the year and then the day/week/month according to your data. |
end |
A vector of length 2 with the date of the last observation. It contains first the year and then the day/week/month according to your data. |
forecast_horizon |
An integer value specifying the number of observations to forecast. |
size.te.set |
An integer value specifying the size of the testing set. |
promo_done |
A logical variable specifying if promotions are done for the product. |
future_impactors |
To be inputted when using a dynamic model (when promo_done == TRUE). A matrix composed of multiple vectors. For promotions, the vector is composed of binary variables that are equal to 1 when there will be a promotion in the forecasting horizon and to 0 otherwise. Other vectors can also be inputted to take into account other impactors. |
criterion |
A string variable specifying the selection criterion that should be used to select the model ("ME", "RMSE", "MAE", "MPE", "MAPE", "MASE", "ACF1", "Theil's U"). "accuracy" can also be used to reflect the needs of the company. |
sizeroll |
The window of the moving average or moving median when using the baseline() function. |
A list containing the select model, the associated graphs, the predictions and the confidence intervals, the accuracy measures and the same elements for all other considered models.
Grandadam Patrik
data("mydata") my_predictions <- predict_sales(mydata, promo_done = TRUE, future_impactor = c(0,1,0, rep(c(rep(0,6),1), 7))) my_predictions my_predictions$selected_model$PLOT # the plot of the selected model my_predictions$selected_model$FORECAST # the forecast of the selected model my_predictions$all_models$arima # all components of the arima model
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.