-
Notifications
You must be signed in to change notification settings - Fork 36
Open
Description
sensible_forecasts <-
function(forecasts,
force_signal = c("positive", "negative"),
max_iterations = 1000,
threshold = 0,
nodes,
groups,
weights = NULL,
algorithms = c("lu", "cg","chol", "recursive", "slm"),
prose = FALSE)
{
counter = 1
if (force_signal == "positve") {
comparisson = `>=`
rounding_function = ceiling
} else {
comparisson = `<=`
rounding_function = floor
}
transformation <- function(x) ifelse(comparisson(x,0),x,0)
repeat {
forecasts <- transformation(forecasts)
y_f <- combinef(forecasts,nodes,groups,weights,algorithms)
forecasts <- aggts(y_f) %>% rounding_function()
counter = counter + 1
if (all(comparisson(forecasts,threshold)) | counter == max_iterations ) {
forecasts <- transformation(forecasts)
if (prose == TRUE) {print(paste0("Number of attempts", counter)) }
break
}
}
return(forecasts)
}
Metadata
Metadata
Assignees
Labels
No labels