- # NOTE: if predict_at does not cut days at midnight, exogenous vars need to be shifted
- exo_hat = as.data.frame( exo_df[
- ifelse(predict_at>0,max(1,i-1),i) , (1+nb_exos+1):(1+2*nb_exos) ] )
- exo = as.data.frame( exo_df[ ifelse(predict_at>0,max(1,i-1),i) , 2:(1+nb_exos) ] )
- level = mean(serie, na.rm=TRUE)
- centered_serie = serie - level
- #data$append(time, centered_serie, level, exo_hat, exo_Jm1) #too slow; TODO: use R6 class
- data[[length(data)+1]] = list("time"=time, "serie"=centered_serie, "level"=level,
- "exo_hat"=exo_hat, "exo"=exo)
+ exo = as.data.frame( exo_df[i,2:(1+nb_exos)] )
+ exo_hat =
+ if (i < nrow(exo_df))
+ as.data.frame( exo_df[i+1,(1+nb_exos+1):(1+2*nb_exos)] )
+ else
+ NA #exogenous prediction for next day are useless on last day
+ data$append(time, serie, exo, exo_hat)