3 Replies Latest reply: Sep 5, 2017 4:18 AM by Bas van Reeuwijk RSS

    Calendar fields and TimeSeries function in R

    Jokke Ruokolainen

      I'm doing a demo on R integration on Sense and I've come across a problem with ts( start=c()) function.

      I can't get the start working in my dataset (I can drop the not wanted rows in load script), is there something I should take into consideration while generating the calendar for it to work with R timeseries functions?

       

      So in short the problem is that I'd like the forecast function to start forecasting from a spesific year instead of from the first date.

       

      Thx

      here's the script for clarification:

       

      R.ScriptEval('library(forecast);'&

          'data<-ts(na.omit(q$Variable1),frequency=12, start=c(1998,1));'&

          'fit<-auto.arima(data);'&

          'res<-forecast(fit, level=0.95, h=q$vForecastPeriods); '&

          'n <- length(q$Variable1); '&

          'fore <- append(q$Variable1[(q$vForecastPeriods - 1):n],res$mean,after= n - q$vForecastPeriods); '&

          'fore;',

          Sum(NoZerosco2) as Variable1,

          $(vForecastPeriods) as vForecastPeriods)