0 Replies Latest reply on Nov 18, 2019 2:24 AM by koushik reddy

    error message while forecasting package in tableau

    koushik reddy

      unable to complete action with external services

      Error in ts(Train$Quantity, frequency = 7) : 'ts' object must have one or more observations

      SCRIPT_INT('

      rm(list=ls());

      library(forecast);

      result = data.frame(Quantity = .arg1,

                                     Date = .arg2,

                                    Holiday = .arg3,

                                   WeekDay = .arg4,

                                   WeekEnd = .arg5)

      result$Date = as.Date(result$Date, format = "%m/%d/%Y")

      result = result[which(result$Date <="11/04/2019"),]

      Train = result[which(result$Date <= "01/01/2019"),]

      Test = result[which(result$Date > "01/01/2019"),]

       

      y <- ts(Train$Quantity, frequency=7)  

      z <- fourier(ts(Train, frequency=365.25), K=5)

      zf <- fourier(ts(Test, frequency=365.25), K=5, h=150)

      fit <- auto.arima(y, xreg=cbind(z,Train$Holiday,Train$WeekDay), seasonal=TRUE)

      fc <- forecast(fit, xreg=cbind(zf,Test$Holiday,Test$WeekDay), h=150)

      fcData=data.frame(fc) 

      output <- c(result$Quantity, fcData$Point.Forecast)',

      SUM([Quantity]),ATTR([Date]),ATTR([Holiday]),ATTR([WeekDay]),ATTR([WeekEnd]))