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

#Setting up working directory

#Reading the data

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

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

  #Forecasting using autoarima
  #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
  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

  #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)
  arima_mean_metrics[,i]<-matrix(c(MAPE_Actuals,MAD_Actuals,MSE_Actuals),nrow=3,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.com Jun 27 '16 at 11:59

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

  • $\begingroup$ The R code for the ARIMA model has been added $\endgroup$ – Abhas Jain Jun 27 '16 at 6:29
  • 2
    $\begingroup$ This post should be moved to CrossValidated $\endgroup$ – Altons Jun 27 '16 at 7:57
  • $\begingroup$ 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. $\endgroup$ – Stephan Kolassa Jun 27 '16 at 13:11
  • $\begingroup$ Finally, I have posted some answers on forecasting daily demands. Some of these may be helpful for you. Good luck! $\endgroup$ – Stephan Kolassa Jun 27 '16 at 13:11

Your Answer

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