return (NA)
# Determine indices of no-NAs days followed by no-NAs tomorrows
- fdays = getNoNA2(data, max(today-memory,1), today-1)
+ # Indices of similar days for cross-validation; TODO: 45 = magic number
+ fdays = intersect(
+ getNoNA2(data, max(today-memory,1), today-1)
+ getSimilarDaysIndices(today, limit=45, same_season=TRUE) )
# Get optional args
kernel = ifelse(hasArg("kernel"), list(...)$kernel, "Gauss") #or "Epan"
fdays, today, horizon, list(...)$h_window, kernel, TRUE) )
}
-
- # Indices of similar days for cross-validation; TODO: 45 = magic number
- # TODO: ici faut une sorte de "same_season==TRUE" --> mois similaires epandage
- sdays = getSimilarDaysIndices(today, limit=45, same_season=FALSE)
-
-
# Function to optimize h : h |--> sum of prediction errors on last 45 "similar" days
errorOnLastNdays = function(h, kernel)
{
error = 0
nb_jours = 0
- for (i in intersect(fdays,sdays))
+ for (day in fdays)
{
# mix_strategy is never used here (simtype != "mix"), therefore left blank
- prediction = private$.predictShapeAux(data, fdays, i, horizon, h, kernel, FALSE)
+ prediction = private$.predictShapeAux(data,fdays,day,horizon,h,kernel,FALSE)
if (!is.na(prediction[1]))
{
nb_jours = nb_jours + 1
}
# h :: only for endo in this variation
- h_best_endo = optimize(errorOnLastNdays, c(0,10), kernel=kernel)$minimum
-
- return (private$.predictShapeAux(data, fdays, today, horizon, h_best, kernel, TRUE))
+ h_best = optimize(errorOnLastNdays, c(0,10), kernel=kernel)$minimum
+ return (private$.predictShapeAux(data,fdays,today,horizon,h_best,kernel,TRUE))
}
),
private = list(
u
}
+
# EXOGENS: distances computations are enough
# TODO: search among similar concentrations....... at this stage ?!
M = matrix( nrow=1+length(fdays), ncol=1+length(data$getExo(today)) )
ppv <- sort(distances2, index.return=TRUE)$ix[1:10] #..............
#PPV pour endo ?
+
similarities =
if (simtype == "exo")
simils_exo
{
private$.params$weights <- similarities
private$.params$indices <- fdays
- private$.params$window <-
- if (simtype=="endo")
- h_endo
- else if (simtype=="exo")
- h_exo
- else #mix
- c(h_endo,h_exo)
+ private$.params$window <- h
}
return (prediction)