#' these have to be set in the "prm" argument. The stepping process will follow
#' these have to be set in the "prm" argument. The stepping process will follow
#' the input selection described above.
#' the input selection described above.
#'
#'
#' In case of missing values, especially in combination with auto-regressive
#' models, it can be very important to make sure that only complete cases are
#' included when calculating the score. By providing the `fitfun` argument then
#' the score will be calculated using only the complete cases across horizons
#' and models in each step, see the last examples.
#'
#' @title Forward and backward model selection
#' @title Forward and backward model selection
#' @param modelfull The full forecastmodel containing all inputs which will be
#' @param modelfull The full forecastmodel containing all inputs which will be
#' can be included in the selection.
#' can be included in the selection.
...
@@ -61,13 +67,27 @@
...
@@ -61,13 +67,27 @@
#' @param modelstart A forecastmodel. If it's set then it will be used as the
#' @param modelstart A forecastmodel. If it's set then it will be used as the
#' selected model from the first step of the stepping. It should be a sub
#' selected model from the first step of the stepping. It should be a sub
#' model of the full model.
#' model of the full model.
#' @param optimfun The function which will carry out the optimization in each step.
#' @param keepinputs If TRUE no inputs can be removed in a step, if FALSE then
#' any input can be removed. If given as a character vector with names of
#' inputs, then they cannot be removed in any step.
#' @param optimfun The function which will carry out the optimization in each
#' step.
#' @param fitfun A fit function, should be the same as used in optimfun(). If
#' provided, then the score is caculated with this function (instead of the
#' one called in optimfun(), hence the default is rls_fit(), which is called
#' in rls_optim()). Furthermore, information on complete cases are printed
#' and returned.
#' @param scorefun The score function used.
#' @param scorefun The score function used.
#' @param ... Additional arguments which will be passed on to optimfun. For example control how many steps
#' @param mc.cores The mc.cores argument of mclapply. If debugging it can be
#' nessecary to set it to 1 to stop execution.
#' @param ... Additional arguments which will be passed on to optimfun. For
#' example control how many steps
#'
#'
#' @return A list with the result of each step:
#' @return A list with the result of each step:
#' - '$model' is the model selected in each step
#' - '$model' is the model selected in each step
#' - '$result' the result return by the the optimfun
#' - '$score' is the score for the model selected in each step
#' - '$optimresult' the result return by the the optimfun
#' - '$completecases' a logical vector (NA if fitfun argument is not given) indicating which time points were complete across all horizons and models for the particular step.
# - Maybe have "cloneit" argument in optimfun, then don't clone inside optim.
# - Maybe have "cloneit" argument in optimfun, then don't clone inside optim.
# - Add argument controlling how much is kept in each iteration (e.g all fitted models)
# - Add argument controlling how much is kept in each iteration (e.g all fitted models)
# - Insert the inputs in the order they are in the full model, then cache might be more consistent (and the order is kept)
# - Is raised as an issue: For score make sure that only the same points are included for all models, or print warning if not!
# - For score make sure that only the same points are included for all models, or print warning if not!
# - With lm we should use have some regularization, so use AIC or BIC as the score
# - With lm we should use have some regularization, so use AIC or BIC as the score
# - Differentiate the parameters given to optimfun for the selected model and for the new models in each step. E.g. take more steps on the selected model.
# - Differentiate the parameters given to optimfun for the selected model and for the new models in each step. E.g. take more steps on the selected model.