title: Forecast using auto.arima with help of dplyr groupby function
body: <p>I need to forecast the demand of some products (10 products) in 100 stores for 150 days. In this I need to groupby PRODUCT and STORE, and fit a arima model and forecast it. Also some products may have less stores. I need to use auto.arima as there are 10000 subsets. I have written a code which computes fit but am not able to forecast it.</p>
  
  <pre><code>data &lt;- read.csv("data.csv")
  dat &lt;- data.frame(data)
  library(dplyr)
  library(forecast)
  model_fit &lt;- group_by(dat, PRODUCT,STORE) %&gt;% do({fit=auto.arima(.$DEMAND)})
  </code></pre>
  
  <p>Till here the code works fine with some warnings like "Unable to fit final model using maximum likelihood. AIC value approximated". I hope its ok, pls let me know if not and why.</p>
  
  <p>Now I need to forecast it into a column Forecast
  I am new to R, so by online material I felt this would work.</p>
  
  <pre><code>dat[,"Forecast"] &lt;- NULL
  model_fit &lt;- group_by(dat, PRODUCT,STORE) %&gt;% do({fit=auto.arima(.$DEMAND) Forecast = forecast(fit)})
  write.csv(dat,"Forecast.csv",row.names = FALSE)
  </code></pre>
  
  <p>This part is not working. Please let me know the problem of this code. Thanks.</p>