0
$\begingroup$

I'm trying to use the code below mainly to run a loop that forecast an arima model one step ahead repeatedly, and append the one step ahead forecasts together. I'm also trying to use predictors for year, month, day of week, and hour of day. This code has worked with other predictors, but returns the error message below for this combination. It also returns this error rather quickly, like within 100 seconds. If anyone knows what the issue may be or can suggest settings in auto.arima that might solve the issue, I'd be grateful. I do currently have stepwise=FALSE and approximation=FALSE.

Error:

Error in search.arima(x, d, D, max.p, max.q, max.P, max.Q, max.order,  : 
No ARIMA model able to be estimated 
5.
stop("No ARIMA model able to be estimated") 
4.
search.arima(x, d, D, max.p, max.q, max.P, max.Q, max.order, 
stationary, ic, trace, approximation, xreg = xreg, offset = offset, 
allowdrift = allowdrift, allowmean = allowmean, parallel = parallel, 
num.cores = num.cores, ...) 
3.
auto.arima(FV_tsTrain1, lambda = lambda1, xreg = FV_xregTrain1, 
stepwise = FALSE, approximation = FALSE) 
2.
Model_Forecast(DataDF = VarDatadf, ForecastVariable = fVar, Predictors = predVar, 
ForecastLength = fLength, RF_Num = VarRF_Num) 
1.
PredCastLoop(DataDF = NewDataDf, ForecastVariable = "Field1", 
Predictors = names(NewDataDf[, !names(NewDataDf) %in% c("DayHourDTS","Field1"), 
ForecastLength = 1, RF_Num = AppendNum) 



Code:

PredCastLoop<-function(DataDF,ForecastVariable,Predictors,ForecastLength,RF_Num){

  Model_Forecast<-function(DataDF,ForecastVariable,Predictors=NULL,ForecastLength,RF_Num)
  {
    ##Partitioning Time Series
    FV_EndTrain1<-(length(DataDF[,ForecastVariable])-(RF_Num)*ForecastLength) 
    FV_ValStart1<-FV_EndTrain1+1
    FV_ValEnd1<-FV_ValStart1+(RF_Num)*ForecastLength-1 

    FV_tsTrain1 <-DataDF[,ForecastVariable][1:FV_EndTrain1] 
    FV_tsValidation<-DataDF[,ForecastVariable][FV_ValStart1:FV_ValEnd1]


    ##BoxCox

    lambda1 <- BoxCox.lambda(FV_tsTrain1)

    if ( is.null(Predictors) ) 
    { 
      ##Predictors
      FV_xreg1<-NULL
      FV_xregTrain1<-NULL
      FV_xregVal1<-NULL

      ##Train Model
      FV_Arima.fit <- auto.arima(FV_tsTrain1, lambda = lambda1,stepwise = FALSE,approximation = FALSE)

      ##Forecast Model

      FV_Acast<-forecast(FV_Arima.fit, h=ForecastLength) 


    }
    else {
      ##Predictors
      FV_xreg1<-DataDF[,names(DataDF)!=ForecastVariable] 
     FV_xregTrain1<-FV_xreg1[1:FV_EndTrain1,Predictors]
      FV_xregVal1<-FV_xreg1[FV_ValStart1:(FV_ValStart1+ForecastLength-1),Predictors] 


      ## With Predictors

      ##Checking effect of Total Patients in ED
      FV_Arima.fit <- auto.arima(FV_tsTrain1, lambda = lambda1, xreg=FV_xregTrain1,stepwise = FALSE,approximation = FALSE)

      ##Forecast Model

      FV_Acast<-forecast(FV_Arima.fit,xreg=FV_xregVal1, h=ForecastLength) 
    }

    MF_ReturnList<-list("FV_Model"=FV_Arima.fit,
                    "FV_Forescast"=FV_Acast$mean,
                    "FV_Validation"=FV_tsValidation, 
                    "FV_tsTrain1"=FV_tsTrain1,
                    "FV_xregTrain1"=FV_xregTrain1,
                    "FV_xregVal1"=FV_xregVal1,
                    "FV_xreg1"=FV_xreg1,
                    "Predictors"=Predictors,
                    "FV_Train"=DataDF[,ForecastVariable]) 

    MF_ReturnList
  }

  ##Roll_ACC Calculates rolling forecast

  ROll_Acc <- function (PredictorsDf=NULL,predictors=NULL,RA_Model,RA_Forecast,RA_Train, RA_Val, ForecastLength,RF_Num )
  {
    ##Empty Time-series to append forecasts into
    RF_ac <- ts()
    for(i in 1:RF_Num)
    {  
      EndTrain1<-(length(RA_Train)-RF_Num*ForecastLength)
      startTrain2<-1+i*ForecastLength
      EndTrain2<-EndTrain1+i*ForecastLength-1
      ValStart2<- EndTrain1+(i-1)*ForecastLength+1 
      ValEnd2<-ValStart2+ForecastLength-1


      if ( is.null(predictors) ) 
  { 


    RF_x <- RA_Train[startTrain2:EndTrain2] 
    RF_refit <- Arima(RF_x, model=RA_Model )
    RF_ac <- append(RF_ac, forecast(RF_refit, h=ForecastLength)$mean, after=i*ForecastLength)
    RF_fc<-ts(append(RA_Forecast,RF_ac[2:length(RF_ac)])) 
    RF_ACC<-accuracy(RF_fc,RA_Val)
  }
  else {
    ##Predictors
    xreg2<-PredictorsDf
    xregTrain2<-xreg2[startTrain2:EndTrain2,]
    xregVal2<-xreg2[ValStart2:ValEnd2,]

    RF_x <- RA_Train[startTrain2:EndTrain2] 
    RF_refit <- Arima(RF_x, model=RA_Model, xreg=xreg2[startTrain2:EndTrain2,predictors] )
    RF_ac <- append(RF_ac, forecast(RF_refit, h=ForecastLength, xreg=xreg2[ValStart2:ValEnd2,predictors] )$mean, after=i*ForecastLength)
    RF_fc<-ts(append(RA_Forecast,RF_ac[2:length(RF_ac)])) 
    RF_ACC<-accuracy(RF_fc,RA_Val) 
  }


     ReturnList<-list("FinalACC"=RF_ACC,"FinalForecast"=RF_fc) 
    }
    ReturnList
  }

  ## Passing variables in to ModelCast
  VarDatadf<-DataDF
  fVar<-ForecastVariable
  predVar<-Predictors
  fLength<-ForecastLength
  VarRF_Num<-RF_Num



  ModelCast<-Model_Forecast(DataDF=VarDatadf,ForecastVariable=fVar,Predictors=predVar,ForecastLength=fLength,RF_Num=VarRF_Num)

  RollACC1<-ROll_Acc(PredictorsDf=ModelCast$FV_xreg1,
                 predictors=ModelCast$Predictors,
                 RA_Model=ModelCast$FV_Model,
                 RA_Forecast=ModelCast$FV_Forescast,
                 RA_Train=ModelCast$FV_Train, 
                 RA_Val=ModelCast$FV_Validation,
                 ForecastLength=fLength,
                 RF_Num=(VarRF_Num-1))  

  RollACC1

}



## TestRun
AppendNum <-24

TestRun<-PredCastLoop(DataDF=NewDataDf,ForecastVariable="Field1",Predictors=names(NewDataDf[,!names(NewDataDf)%in%c("DayHourDTS","Field1")]),ForecastLength=1,RF_Num=AppendNum)





Data:

dput(droplevels(NewDataDf))
structure(list(DayHourDTS = structure(1:50, .Label = c("2015-01-01 00:00:00.000", 
"2015-01-01 01:00:00.000", "2015-01-01 02:00:00.000", "2015-01-01 03:00:00.000", 
"2015-01-01 04:00:00.000", "2015-01-01 05:00:00.000", "2015-01-01 06:00:00.000", 
"2015-01-01 07:00:00.000", "2015-01-01 08:00:00.000", "2015-01-01 09:00:00.000", 
"2015-01-01 10:00:00.000", "2015-01-01 11:00:00.000", "2015-01-01 12:00:00.000", 
"2015-01-01 13:00:00.000", "2015-01-01 14:00:00.000", "2015-01-01 15:00:00.000", 
"2015-01-01 16:00:00.000", "2015-01-01 17:00:00.000", "2015-01-01 18:00:00.000", 
"2015-01-01 19:00:00.000", "2015-01-01 20:00:00.000", "2015-01-01 21:00:00.000", 
"2015-01-01 22:00:00.000", "2015-01-01 23:00:00.000", "2015-01-02 00:00:00.000", 
"2015-01-02 01:00:00.000", "2015-01-02 02:00:00.000", "2015-01-02 03:00:00.000", 
"2015-01-02 04:00:00.000", "2015-01-02 05:00:00.000", "2015-01-02 06:00:00.000", 
"2015-01-02 07:00:00.000", "2015-01-02 08:00:00.000", "2015-01-02 09:00:00.000", 
"2015-01-02 10:00:00.000", "2015-01-02 11:00:00.000", "2015-01-02 12:00:00.000", 
"2015-01-02 13:00:00.000", "2015-01-02 14:00:00.000", "2015-01-02 15:00:00.000", 
"2015-01-02 16:00:00.000", "2015-01-02 17:00:00.000", "2015-01-02 18:00:00.000", 
"2015-01-02 19:00:00.000", "2015-01-02 20:00:00.000", "2015-01-02 21:00:00.000", 
"2015-01-02 22:00:00.000", "2015-01-02 23:00:00.000", "2015-01-03 00:00:00.000", 
"2015-01-03 01:00:00.000"), class = "factor"), Field1 = c(48, 
46, 45, 39, 31, 22, 21, 22, 23, 29, 33, 45, 52, 63, 74, 78, 82, 
84, 75, 81, 85, 82, 75, 68, 57, 48, 37, 27, 28, 28, 29, 27, 29, 
33, 42, 52, 69, 68, 81, 85, 91, 95, 100, 101, 97, 88, 90, 79, 
73, 63), Friday = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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June", 
"July", "Aug", "Sep", "Oct", "Nov", "Dec", "as.factor(years)2015", 
"as.factor(years)2016", "as.factor(years)2017", "S1", "S2", "S3", 
"S4", "S5", "S6", "S7", "S8", "S9", "S10", "S11", "S12", "S13", 
"S14", "S15", "S16", "S17", "S18", "S19", "S20", "S21", "S22", 
"S23"), row.names = c(NA, 50L), class = "data.frame")
$\endgroup$
  • $\begingroup$ Why the count-down from 5 to 1? Is this code in reverse? $\endgroup$ – Richard Hardy Mar 7 '17 at 7:34
  • $\begingroup$ Why do you use all the 12 months? Don't you have a problem of collinearity there? $\endgroup$ – Tommaso Guerrini Mar 7 '17 at 9:34
  • $\begingroup$ @RichardHardy Hi Richard, thank you for your reply. I just copied and pasted the trace back of the error. So I guess it does look like it's counting down, but I would follow it from 1 to 5. Hope that helps clear things up. $\endgroup$ – user3476463 Mar 7 '17 at 15:26
  • $\begingroup$ @TommasoGuerrini Hi Tommaso, thank you for getting back to me. If I think my data might have seasonality according to the month of the year, how would I create a predictor for the month that avoids collinearity? I've been able to create models similarly in the past using only predictors for the hour of day. Is the issue that I'm trying to do year, month, weekday, and hour? $\endgroup$ – user3476463 Mar 7 '17 at 15:35
  • $\begingroup$ @TommasoGuerrini Hi Tommaso, if I used fourier predictors instead for the year, month, weekday, and hour would that solve the collinearity issue? $\endgroup$ – user3476463 Mar 7 '17 at 15:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.