# Demand Forecasting Models

I want to forecast demand of various products using time series data of 2 years (using loops on products in R), frequency is daily and demand is to be forecasted for next 90 days

I have used the following models till now

1. ARIMA
2. SImple Exponential Model
3. Holt Exponential Model (with trend)
4. Holt Winters Exponential Model (with trend and seasonality)

My ARIMA results gave same point forecasts for many products for all 90 days, while the Exponential models are giving high errors (seen through MAPE)

1. Why does ARIMA model give same point forecast for all 90 days.
2. What other models can be used for time series forecasting other than these four
3. Should ARCH-GARCH models or sarima be used??
   #  Demand Forecasting - ARIMA model- Weekly Demand Forecasting for next 13 weeks using 104 weeks data- 27-6-2016

#Required libraries
library(forecast)
require(forecast)
library(MASS)
require(MASS)

#Setting up working directory
getwd()
setwd("C:/Users/21202/Desktop/ARIMA_27-6")
getwd()

#Checking for the no. of products in the data
nproducts<-ncol(weeklyproductdemand)-1 # -1 because first column is product code
nproducts

product <- matrix(c(rep(1, nproducts*117)), nrow = 117, ncol = nproducts)
forecastoutput <- matrix(c(rep(1, nproducts*13)), nrow = 13, ncol = nproducts)
actualdata <- matrix(c(rep(1, nproducts*13)), nrow = 13, ncol = nproducts)
arima_error_metrics <- matrix(c(rep(1,nproducts*13)), nrow = 13, ncol = nproducts)
arima_pcerror_metrics <- matrix(c(rep(1,nproducts*13)), nrow = 13, ncol = nproducts)
arima_mean_metrics <- matrix(c(rep(1,nproducts*3)), nrow = 3, ncol = nproducts)

for (i in 1:nproducts)
{
product[,i] <- as.numeric(as.matrix(weeklyproductdemand[,i+1])) #fetching the weekly demand of the required product
NonNAindex <- which(!is.na(product[,i]))
#FirstnonNA <- min(NonNAindex)
LastnonNA <- max(NonNAindex)
#product[,i]<-product[is.finite(product[,i])] # cleans up the NA in the end of the array
Aproduct<-as.matrix(product[1:(LastnonNA - 13), i]) # cleans up the NA in the end of the array and filters out the last 13 values of the array

#Plotting the weekly demand of the required product
product_rawdata<-ts(Aproduct)
ts.plot(product_rawdata)

#Forecasting using autoarima
product_forecast<-auto.arima(product_rawdata)
product_forecast
summary(product_forecast)
#acf(Aproduct, ylim = c(-0.999,0.999))
#pacf(Aproduct, ylim = c(-0.999,0.999))

#Estimating MAPE,MAD and MSE

#Checking for actual Q12016 values vs. Q1 predicted values
predictedvalues<-data.frame(forecast(product_rawdata,h=13))
#predictedvalues
#predictedvalues<-data.frame(AForecast)
#predictedvalues<-as.matrix(AForecast)
actualvalues<-tail(product[(1:LastnonNA), i],13)
error <- actualvalues-predictedvalues$Point.Forecast #Calculating deviation perror <- error/actualvalues # Calculating percentage deviation perror <-perror[!is.infinite(perror)] #filters out the 'Inf' perror <-perror[is.finite(perror)] #Retains only the numerical values MAPE_Actuals<- mean(abs(perror))# Calcuating Mean Average Percentage Error MAD_Actuals<-mean(error)#Calculating Mean Average Deviation MSE_Actuals<-mean(error^2)#Calculating Mean square of errors MSE_Actuals MAPE_Actuals MAD_Actuals #storing the product forecast forecastoutput[,i]<- predictedvalues$Point.Forecast
actualdata[,i] <- actualvalues
arima_error_metrics[,i]<-matrix(error,nrow=13,ncol = 1)
arima_pcerror_metrics[,i]<-matrix(perror,nrow=13,ncol = 1)
}

#Exporting to .csv
write.csv(forecastoutput,file="20160627 13weeks_Forecast_ARIMA_v0.2.csv")
write.csv(actualdata,file="20160627 13weeks_Actual_v0.2.csv")
write.csv(arima_error_metrics,file="20160627 13weeks_Error_Metrics_ARIMA v0.2.csv")
write.csv(arima_pcerror_metrics,file="20160627 13weeks_pcError_Metrics_ARIMA v0.2.csv")
write.csv(arima_mean_metrics,file="20160627 13weeks_Actual_Mean-Error_Metrics_v0.2.csv")


## migrated from stackoverflow.comJun 27 '16 at 11:59

This question came from our site for professional and enthusiast programmers.

• The R code for the ARIMA model has been added – Abhas Jain Jun 27 '16 at 6:29
• This post should be moved to CrossValidated – Altons Jun 27 '16 at 7:57
• Without your actual data, there is little we can do. Plus, I doubt anyone will want to dig through all your code. I'd recommend you post sample data and focus your question more. Apart from that, it seems like you have NAs in your data, which is always problematic. Plus, daily demands almost certainly have weekly seasonality, but your models can't model this unless you tell them there is a cycle of length 7 in your data, so best to use frequency=7 in your calls to ts(). You may also have year-over-year seasonalities, in which case msts and tbats may be helpful. – Stephan Kolassa Jun 27 '16 at 13:11
• Finally, I have posted some answers on forecasting daily demands. Some of these may be helpful for you. Good luck! – Stephan Kolassa Jun 27 '16 at 13:11