Reputation: 1
I am trying to predict the sales of 4 products from different brands.
I tried using ARIMA model and SARIMA but I am wondering if it is possible (and how) to include external factors say for instance tax increase, import/export policies change etc.
The data I have is only the quantity sold over the past 5 years (monthly).
The ARIMA model returned a MAPE value =14% and The SARIMA model returned a MAPE value of 11%
I am thinking of adding external factors to tune the forecast even further.
Any ideas on how to proceed?
Is it possible to determine the weight/ impact of the external factors using assumptions then proceed to see the effect on the forecasted values and check multiple results depending on the different scenarios of the external factors? (tax increase by 2%, entry of new competitor, etc.)
How to formulate this and which learning method/ model is best to try?
Any suggestions will be much appreciated.
Thank you
Upvotes: 0
Views: 388
Reputation: 338
Consider using the Forecasting Practices and Principles package from Rob Hyndman. The book can be purchased on Amazon, or viewed for free from the author. I very highly recommend this book. He has an excellent example of scenario based forecasting at: https://otexts.com/fpp3/forecasting-regression.html
The method allows the user to create scenarios for a time series, allowing for different possible future values, and plotting the results. The possible future values can include external factors. I've created an example that is different from the one in the book, so there are two different solutions to consider (the book and this one):
Let's look at the data:
library(tidyverse)
library(fpp3)
head(us_change)
It reports quarterly results for Consumption, Income, Production, Savings, and Unemployment. Let's create an ARIMA model that predicts Savings in terms of external factors of Consumption, Income, and Unemployment:
fit_savings <- us_change %>%
model(
arima = ARIMA(Savings ~ Consumption + Income + Unemployment)
)
The next step is to create future scenarios of the model using these external factors. The model here uses different levels for each of the four quarters, for some of the features, hopefully that gives an idea of the power of this solution:
future_scenarios <- scenarios(
Increase = new_data(us_change, 4) %>%
mutate(Consumption=c(1, 0, 2, 3), Income=c(0.5, 1.5, 4, 6) , Unemployment=0),
Decrease = new_data(us_change, 4) %>%
mutate(Consumption=c(-1, -3, -9, -22), Income=c(-0.5, -3, -6, -18), Unemployment=c(0, -4, -7, -11)),
names_to = "Scenario")
I always like to look at the scenarios, just to make sure everything is good:
future_scenarios
Now all we need to do is create the forecast. I usually want to print out the values, in addition to a plot.
forecast_savings <- forecast(fit_savings, new_data = future_scenarios)
forecast_savings
us_change %>%
autoplot(Savings) +
autolayer(forecast_savings) +
facet_grid(~Scenario)
If you want to get a little more advanced, it's possible to run multiple models simultaneously using this system, for example (and it's possible to run as many as your system will allow, not just three models as demonstrated here):
fit_savings <- us_change %>%
model(
arima = ARIMA(Savings ~ Consumption + Income + Unemployment + season() + trend()),
ets = ETS(Savings),
linear = TSLM(Savings ~ Consumption + Income + Unemployment)
)
future_scenarios <- scenarios(
Increase = new_data(us_change, 4) %>%
mutate(Consumption=c(1, 0, 2, 3), Income=c(0.5, 1.5, 4, 6) , Unemployment=0),
Decrease = new_data(us_change, 4) %>%
mutate(Consumption=c(-1, -3, -9, -22), Income=c(-0.5, -3, -6, -18), Unemployment=c(0, -4, -7, -11)),
names_to = "Scenario")
forecast_savings <- forecast(fit_savings, new_data = future_scenarios)
forecast_savings
us_change %>%
autoplot(Savings) +
autolayer(forecast_savings) +
facet_grid(~Scenario + .model)
Upvotes: 1