if (!opera)
tdays = setdiff(tdays, today) #always exclude current day
- # Shortcut if window is known
- if (hasArg("window"))
+ # Shortcut if window is known or local==TRUE && simtype==none
+ if (hasArg("window") || (local && simtype=="none"))
{
return ( private$.predictShapeAux(data, tdays, today, predict_from, horizon,
local, list(...)$window, simtype, opera, TRUE) )
if (local)
{
- # TODO: 60 == magic number
- tdays = getSimilarDaysIndices(today, data, limit=60, same_season=TRUE,
+ # limit=Inf to not censor any day (TODO: finite limit? 60?)
+ tdays = getSimilarDaysIndices(today, data, limit=Inf, same_season=TRUE,
days_in=tdays_cut, operational=opera)
# if (length(tdays) <= 1)
# return (NA)
}
return ( data$getSerie(tdays[1])[predict_from:horizon] )
}
+ max_neighbs = 12 #TODO: 12 = arbitrary number
+ if (length(tdays) > max_neighbs)
+ {
+ distances2 <- .computeDistsEndo(data, today, tdays, predict_from)
+ ordering <- order(distances2)
+ tdays <- tdays[ ordering[1:max_neighbs] ]
+ }
}
else
tdays = tdays_cut #no conditioning
window_endo = ifelse(simtype=="mix", window[1], window)
# Distances from last observed day to selected days in the past
+ # TODO: redundant computation if local==TRUE
distances2 <- .computeDistsEndo(data, today, tdays, predict_from)
- if (local)
- {
- max_neighbs = 12 #TODO: 12 = arbitrary number
- if (length(distances2) > max_neighbs)
- {
- ordering <- order(distances2)
- tdays <- tdays[ ordering[1:max_neighbs] ]
- distances2 <- distances2[ ordering[1:max_neighbs] ]
- }
- }
-
simils_endo <- .computeSimils(distances2, window_endo)
}