4 Replies Latest reply: May 25, 2016 6:48 AM by Ashvin Ramiah RSS

    How to do Arima Forecasting of R ?

    Prashant Sharma

      Below is my code from which i am trying to read and do the forecast and then write that forecast into a file.

       

      sub test

       

      'create a COM object representing R

      Set R = CreateObject("StatConnectorSrv.StatConnector")

      R.Init "R"

       

      'Pass data to R from csv

      R.EvaluateNoReturn "setwd('C:\\R\\')"

      R.EvaluateNoReturn "RSAS<-read.csv('RSAS.csv')"

       

      R.EvaluateNoReturn "attach(RSAS)"

      R.EvaluateNoReturn "'(R_fit <- auto.arima(RSAS$R))'"

      R.EvaluateNoReturn "'(R_forecast <- forecast(R_fit, h=10))'"

      R.EvaluateNoReturn "'(RMean<-R_forecast$mean)'"

      R.EvaluateNoReturn "'(RMean1<-RMean$Point.Forecast)'"

      R.EvaluateNoReturn "'(DisplayResult<-data.frame(RMean1))'"

       

      R.EvaluateNoReturn "write.csv(DisplayResult,'Rmean2.csv')"

       

      Thanks,

      Prashant