I am following the methodology provided by this professor here: https://robjhyndman.com/hyndsight/batch-forecasting/
Here, I am trying to get the forecast of multiple products at once, which has mostly similar trend, same features in real world. So, we can use same forecasting method for all the products.
So, I am trying to run a loop and do the same forecast technique for all the 50 products that I have.
Input: 2 years of data, total 104 weeks.
column 1: has the weeks, column 2 onwards the sales qty.
Issue: Code ran without error. But except 2 or 3 products, rest all the cases, the forecasted value for all 13 weeks is literally same. no variation, only constant value, it is definitely not correct.
please review the code and let me know, why the forecasted value is constant every week?Also, how do I add the holtwinters() in the code.
Here is the reprex code:
#set directory setwd("d:\\Users\\DemandPlanning") # load required packages library(readr) library(ggplot2) library(forecast) #> Registered S3 method overwritten by 'xts': #> method from #> as.zoo.xts zoo #> Registered S3 method overwritten by 'quantmod': #> method from #> as.zoo.data.frame zoo #> Registered S3 methods overwritten by 'forecast': #> method from #> fitted.fracdiff fracdiff #> residuals.fracdiff fracdiff library(reprex) Sales <- read.csv("DIY_Top 50_SKU_Sales.csv",header=FALSE) Sales <- ts(Sales[,-1],f=52) ns <- ncol(Sales) h <- 13 fcst <- matrix(NA,nrow=h,ncol=ns) for(i in 1:ns) fcst[,i] <- forecast(Sales[,i],h=h)$mean write(t(fcst),file="SalesFcstTop50.csv",sep=",",ncol=ncol(fcst))
Created on 2019-11-11 by the reprex package (v0.3.0)