predict_baseline: Creates the forecast of the baseline of sales based on...

View source: R/Predictor.R

predict_baselineR Documentation

Creates the forecast of the baseline of sales based on historical data

Description

This function enables to create the baseline sales forecast based on historical sales data. It generates a historical baseline, considers a multitude of models and selects the model that had the best performance on the testing set.

Usage

predict_baseline(sales_data, frequency = 52, start = c(2014, 1),
  end = c(2019, 12), forecast_horizon = 52, size.te.set = 52,
  promo_done = FALSE, criterion = "accuracy", sizeroll = 11,
  smoother = "mean")

Arguments

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.

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.

smoother

The smoother that should be considered when using the baseline() function. It can be "mean", "median" or "loess".

Value

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.

Author(s)

Grandadam Patrik

Examples

data("mydata")
my_baseline <- predict_baseline(mydata, promo_done = TRUE, criterion = "MAPE")
my_baseline$selected_model$PLOT # the plot of the selected model
my_baseline$selected_model$FORECAST # the forecast of the selected model
my_baseline$selected_model$ACCURACIES # the accuracies of the selected model

Upsylon/predictor documentation built on June 16, 2022, 4:48 p.m.