diff --git a/NAMESPACE b/NAMESPACE index e6c530dd3..97d7f8b63 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -31,8 +31,8 @@ export(crps_sample) export(dispersion) export(dss_sample) export(get_duplicate_forecasts) -export(get_forecast_unit) export(get_forecast_type) +export(get_forecast_unit) export(interval_coverage_deviation_quantile) export(interval_coverage_quantile) export(interval_coverage_sample) @@ -61,6 +61,7 @@ export(plot_ranges) export(plot_score_table) export(plot_wis) export(quantile_score) +export(quantile_to_interval) export(run_safely) export(sample_to_quantile) export(score) diff --git a/R/check-input-helpers.R b/R/check-input-helpers.R index 95869f02b..b745f55d1 100644 --- a/R/check-input-helpers.R +++ b/R/check-input-helpers.R @@ -5,7 +5,7 @@ #' @inheritDotParams checkmate::check_numeric #' @importFrom checkmate check_atomic_vector check_numeric #' @inherit document_check_functions return -#' @keywords internal +#' @keywords internal_input_check check_numeric_vector <- function(x, ...) { # check functions must return TRUE on success # and a custom error message otherwise @@ -36,7 +36,7 @@ check_numeric_vector <- function(x, ...) { #' #' @return None. Function errors if quantiles are invalid. #' -#' @keywords internal +#' @keywords internal_input_check check_quantiles <- function(quantiles, name = "quantiles", range = c(0, 1)) { if (any(quantiles < range[1]) || any(quantiles > range[2])) { stop(name, " must be between ", range[1], " and ", range[2]) @@ -57,7 +57,7 @@ check_quantiles <- function(quantiles, name = "quantiles", range = c(0, 1)) { #' @param expr an expression to be evaluated #' @importFrom checkmate assert assert_numeric check_matrix #' @inherit document_check_functions return -#' @keywords internal +#' @keywords internal_input_check check_try <- function(expr) { result <- try(expr, silent = TRUE) if (is.null(result)) { @@ -79,7 +79,7 @@ check_try <- function(expr) { #' @return The function returns `NULL`, but throws an error if the variable is #' missing. #' -#' @keywords internal +#' @keywords internal_input_check assert_not_null <- function(...) { vars <- list(...) varnames <- names(vars) @@ -112,7 +112,7 @@ assert_not_null <- function(...) { #' within another checking function. #' @inherit document_assert_functions return #' -#' @keywords internal +#' @keywords internal_input_check assert_equal_length <- function(..., one_allowed = TRUE, call_levels_up = 2) { @@ -161,7 +161,7 @@ assert_equal_length <- function(..., #' @param attribute The name of the attribute to check #' @param expected The expected value of the attribute #' @inherit document_check_functions return -#' @keywords internal +#' @keywords internal_input_check check_attribute_conflict <- function(object, attribute, expected) { existing <- attr(object, attribute) if (is.vector(existing) && is.vector(expected)) { @@ -188,8 +188,9 @@ check_attribute_conflict <- function(object, attribute, expected) { #' @description #' Check whether the data.table has a column called `model`. #' If not, a column called `model` is added with the value `Unspecified model`. +#' @inheritParams score #' @return The data.table with a column called `model` -#' @keywords internal +#' @keywords internal_input_check assure_model_column <- function(data) { if (!("model" %in% colnames(data))) { message( @@ -208,7 +209,7 @@ assure_model_column <- function(data) { #' returns TRUE and a string with an error message otherwise. #' @param forecast_unit Character vector denoting the unit of a single forecast. #' @inherit document_check_functions params return -#' @keywords internal +#' @keywords internal_input_check check_number_per_forecast <- function(data, forecast_unit) { # check whether there are the same number of quantiles, samples -------------- data[, scoringutils_InternalNumCheck := length(predicted), by = forecast_unit] @@ -235,7 +236,7 @@ check_number_per_forecast <- function(data, forecast_unit) { #' an error message, otherwise it returns TRUE. #' @inherit document_check_functions params return #' -#' @keywords internal +#' @keywords internal_input_check check_no_NA_present <- function(data, columns) { for (x in columns){ if (anyNA(data[[x]])) { @@ -253,20 +254,13 @@ check_no_NA_present <- function(data, columns) { } - - -# print stuff -diagnose <- function(data) { - -} - #' Check that there are no duplicate forecasts #' #' @description #' Runs [get_duplicate_forecasts()] and returns a message if an issue is encountered #' @inheritParams get_duplicate_forecasts #' @inherit document_check_functions return -#' @keywords internal +#' @keywords internal_input_check check_duplicates <- function(data, forecast_unit = NULL) { check_duplicates <- get_duplicate_forecasts(data, forecast_unit = forecast_unit) @@ -290,7 +284,7 @@ check_duplicates <- function(data, forecast_unit = NULL) { #' and returns a message with the first issue encountered. #' @inherit document_check_functions params return #' @importFrom checkmate assert_character -#' @keywords check-inputs +#' @keywords internal_input_check check_columns_present <- function(data, columns) { if (is.null(columns)) { return(TRUE) @@ -322,7 +316,7 @@ check_columns_present <- function(data, columns) { #' are present, the function returns TRUE. #' @inheritParams document_check_functions #' @return Returns TRUE if all columns are present and FALSE otherwise -#' @keywords internal +#' @keywords internal_input_check test_columns_present <- function(data, columns) { check <- check_columns_present(data, columns) return(is.logical(check)) @@ -334,7 +328,7 @@ test_columns_present <- function(data, columns) { #' more columns are present, the function returns FALSE. #' @inheritParams document_check_functions #' @return Returns TRUE if none of the columns are present and FALSE otherwise -#' @keywords internal +#' @keywords internal_input_check test_columns_not_present <- function(data, columns) { if (any(columns %in% colnames(data))) { return(FALSE) @@ -349,7 +343,7 @@ test_columns_not_present <- function(data, columns) { #' "quantile" and "sample_id" is present. #' @inherit document_check_functions params return #' @importFrom checkmate check_data_frame -#' @keywords check-inputs +#' @keywords internal_input_check check_data_columns <- function(data) { is_data <- check_data_frame(data, min.rows = 1) if (!is.logical(is_data)) { @@ -374,7 +368,7 @@ check_data_columns <- function(data) { #' @param object An object to be checked #' @param attribute name of an attribute to be checked #' @inherit document_check_functions return -#' @keywords check-inputs +#' @keywords internal_input_check check_has_attribute <- function(object, attribute) { if (is.null(attr(object, attribute))) { return( diff --git a/R/check-inputs-scoring-functions.R b/R/check-inputs-scoring-functions.R index 2c36071ad..e0c784ff2 100644 --- a/R/check-inputs-scoring-functions.R +++ b/R/check-inputs-scoring-functions.R @@ -10,7 +10,7 @@ #' vector of size N. #' @importFrom checkmate assert assert_numeric check_matrix #' @inherit document_assert_functions return -#' @keywords check-inputs +#' @keywords internal_input_check assert_input_sample <- function(observed, predicted) { assert_numeric(observed, min.len = 1) n_obs <- length(observed) @@ -30,7 +30,7 @@ assert_input_sample <- function(observed, predicted) { #' @title Check that inputs are correct for sample-based forecast #' @inherit assert_input_sample params description #' @inherit document_check_functions return -#' @keywords check-inputs +#' @keywords internal_input_check check_input_sample <- function(observed, predicted) { result <- check_try(assert_input_sample(observed, predicted)) return(result) @@ -54,7 +54,7 @@ check_input_sample <- function(observed, predicted) { #' FALSE. Whether the quantile levels are required to be unique or not. #' @importFrom checkmate assert assert_numeric check_matrix check_vector #' @inherit document_assert_functions return -#' @keywords internal +#' @keywords internal_input_check assert_input_quantile <- function(observed, predicted, quantile, unique_quantiles = TRUE) { assert_numeric(observed, min.len = 1) @@ -85,7 +85,7 @@ assert_input_quantile <- function(observed, predicted, quantile, #' @title Check that inputs are correct for quantile-based forecast #' @inherit assert_input_quantile params description #' @inherit check_input_sample return description -#' @keywords check-inputs +#' @keywords internal_input_check check_input_quantile <- function(observed, predicted, quantile) { result <- check_try(assert_input_quantile(observed, predicted, quantile)) return(result) @@ -106,7 +106,7 @@ check_input_quantile <- function(observed, predicted, quantile) { #' (25%, 75%) prediction interval. #' @importFrom rlang warn #' @inherit document_assert_functions return -#' @keywords internal +#' @keywords internal_input_check assert_input_interval <- function(observed, lower, upper, range) { assert(check_numeric_vector(observed, min.len = 1)) @@ -145,7 +145,7 @@ assert_input_interval <- function(observed, lower, upper, range) { #' @title Check that inputs are correct for interval-based forecast #' @inherit assert_input_interval params description #' @inherit check_input_sample return description -#' @keywords check-inputs +#' @keywords internal_input_check check_input_interval <- function(observed, lower, upper, range) { result <- check_try(assert_input_quantile(observed, lower, upper, range)) return(result) @@ -167,7 +167,7 @@ check_input_interval <- function(observed, lower, upper, range) { #' available factor level. #' @importFrom checkmate assert assert_factor #' @inherit document_assert_functions return -#' @keywords check-inputs +#' @keywords internal_input_check assert_input_binary <- function(observed, predicted) { assert_factor(observed, n.levels = 2, min.len = 1) assert_numeric(predicted, lower = 0, upper = 1) @@ -179,7 +179,7 @@ assert_input_binary <- function(observed, predicted) { #' @title Check that inputs are correct for binary forecast #' @inherit assert_input_binary params description #' @inherit document_check_functions return -#' @keywords check-inputs +#' @keywords internal_input_check check_input_binary <- function(observed, predicted) { result <- check_try(assert_input_binary(observed, predicted)) return(result) @@ -194,7 +194,7 @@ check_input_binary <- function(observed, predicted) { #' @param predicted Input to be checked. Should be a numeric vector with the #' predicted values of size n #' @inherit document_assert_functions return -#' @keywords check-inputs +#' @keywords internal_input_check assert_input_point <- function(observed, predicted) { assert(check_numeric(observed)) assert(check_numeric(predicted)) @@ -205,7 +205,7 @@ assert_input_point <- function(observed, predicted) { #' @title Check that inputs are correct for point forecast #' @inherit assert_input_point params description #' @inherit document_check_functions return -#' @keywords check-inputs +#' @keywords internal_input_check check_input_point <- function(observed, predicted) { result <- check_try(assert_input_point(observed, predicted)) return(result) @@ -224,7 +224,7 @@ check_input_point <- function(observed, predicted) { #' @inherit assert_input_binary #' @inherit document_assert_functions return #' @importFrom checkmate assert_vector check_matrix check_vector assert -#' @keywords check-inputs +#' @keywords internal_input_check assert_dims_ok_point <- function(observed, predicted) { assert_vector(observed, min.len = 1) n_obs <- length(observed) @@ -250,7 +250,7 @@ assert_dims_ok_point <- function(observed, predicted) { #' @title Check Inputs Have Matching Dimensions #' @inherit assert_dims_ok_point params description #' @inherit document_check_functions return -#' @keywords check-inputs +#' @keywords internal_input_check check_dims_ok_point <- function(observed, predicted) { result <- check_try(assert_dims_ok_point(observed, predicted)) return(result) diff --git a/R/documentation-templates.R b/R/documentation-templates.R index 087c77d4b..dc219755f 100644 --- a/R/documentation-templates.R +++ b/R/documentation-templates.R @@ -4,17 +4,20 @@ #' @return Returns TRUE if the check was successful and a string with an #' error message otherwise #' @name document_check_functions +#' @keywords internal NULL #' Documentation template for check functions #' @returns Returns NULL invisibly if the assertion was successful and throws an #' error otherwise. #' @name document_assert_functions +#' @keywords internal NULL #' Documentation template for test functions #' @returns Returns TRUE if the check was successful and FALSE otherwise #' @name document_test_functions +#' @keywords internal NULL #' Documentation template for scoring input data @@ -22,4 +25,5 @@ NULL #' specifications detailed in [score()]. #' @param scores A data.table of scores as produced by [score()]. #' @name document_score_data +#' @keywords internal NULL diff --git a/R/get_-functions.R b/R/get_-functions.R index 569fe8382..a2e0cb648 100644 --- a/R/get_-functions.R +++ b/R/get_-functions.R @@ -18,7 +18,7 @@ #' @return Character vector of length one with either "binary", "quantile", #' "sample" or "point". #' @export -#' @keywords check-forceasts +#' @keywords check-forecasts get_forecast_type <- function(data) { assert_data_frame(data) assert(check_columns_present(data, c("observed", "predicted"))) @@ -50,7 +50,7 @@ get_forecast_type <- function(data) { #' @inheritParams document_check_functions #' @importFrom checkmate test_factor test_numeric #' @return Returns TRUE if basic requirements are satisfied and FALSE otherwise -#' @keywords internal +#' @keywords internal_input_check test_forecast_type_is_binary <- function(data) { observed_correct <- test_factor(x = data$observed) predicted_correct <- test_numeric(x = data$predicted) @@ -61,7 +61,7 @@ test_forecast_type_is_binary <- function(data) { #' @description Checks type of the necessary columns. #' @inheritParams document_check_functions #' @return Returns TRUE if basic requirements are satisfied and FALSE otherwise -#' @keywords internal +#' @keywords internal_input_check test_forecast_type_is_sample <- function(data) { observed_correct <- test_numeric(x = data$observed) predicted_correct <- test_numeric(x = data$predicted) @@ -73,7 +73,7 @@ test_forecast_type_is_sample <- function(data) { #' @description Checks type of the necessary columns. #' @inheritParams document_check_functions #' @return Returns TRUE if basic requirements are satisfied and FALSE otherwise -#' @keywords internal +#' @keywords internal_input_check test_forecast_type_is_point <- function(data) { observed_correct <- test_numeric(x = data$observed) predicted_correct <- test_numeric(x = data$predicted) @@ -85,7 +85,7 @@ test_forecast_type_is_point <- function(data) { #' @description Checks type of the necessary columns. #' @inheritParams document_check_functions #' @return Returns TRUE if basic requirements are satisfied and FALSE otherwise -#' @keywords internal +#' @keywords internal_input_check test_forecast_type_is_quantile <- function(data) { observed_correct <- test_numeric(x = data$observed) predicted_correct <- test_numeric(x = data$predicted) @@ -100,13 +100,10 @@ test_forecast_type_is_quantile <- function(data) { #' of observed or predicted values). The function checks whether the input is #' a factor, or else whether it is integer (or can be coerced to integer) or #' whether it's continuous. -#' #' @param x Input used to get the type. -#' #' @return Character vector of length one with either "classification", #' "integer", or "continuous" -#' -#' @keywords internal +#' @keywords internal_input_check get_type <- function(x) { if (is.factor(x)) { return("classification") @@ -129,15 +126,11 @@ get_type <- function(x) { #' @title Get metrics that were used for scoring -#' #' @description Internal helper function to get the metrics that were used #' to score forecasts. -#' @param score A data.table with an attribute `metric_names` -#' +#' @param scores A data.table with an attribute `metric_names` #' @return Character vector with the metrics that were used for scoring. -#' -#' @keywords internal - +#' @keywords internal_input_check get_metrics <- function(scores) { metric_names <- attr(scores, "metric_names") if (is.null(metric_names)) { diff --git a/R/metrics-quantile.R b/R/metrics-quantile.R index 50f729f15..32f37162e 100644 --- a/R/metrics-quantile.R +++ b/R/metrics-quantile.R @@ -96,6 +96,7 @@ #' `wis()`: a numeric vector with WIS values of size n (one per observation), #' or a list with separate entries if `separate_results` is `TRUE`. #' @export +#' @keywords metric wis <- function(observed, predicted, quantile, @@ -160,6 +161,7 @@ wis <- function(observed, #' `overprediction()`, `underprediction()` and `dispersion()` #' @export #' @rdname wis +#' @keywords metric dispersion <- function(observed, predicted, quantile, ...) { args <- list(...) args$separate_results <- TRUE @@ -173,6 +175,7 @@ dispersion <- function(observed, predicted, quantile, ...) { #' observation) #' @export #' @rdname wis +#' @keywords metric overprediction <- function(observed, predicted, quantile, ...) { args <- list(...) args$separate_results <- TRUE @@ -186,6 +189,7 @@ overprediction <- function(observed, predicted, quantile, ...) { #' observation) #' @export #' @rdname wis +#' @keywords metric underprediction <- function(observed, predicted, quantile, ...) { args <- list(...) args$separate_results <- TRUE @@ -209,6 +213,7 @@ underprediction <- function(observed, predicted, quantile, ...) { #' corresponding prediction interval and FALSE otherwise. #' @name interval_coverage #' @export +#' @keywords metric #' @examples #' observed <- c(1, -15, 22) #' predicted <- rbind( @@ -282,6 +287,7 @@ interval_coverage_quantile <- function(observed, predicted, quantile, range = 50 #' @return A numeric vector of length n with the coverage deviation for each #' forecast (comprising one or multiple prediction intervals). #' @export +#' @keywords metric #' @examples #' observed <- c(1, -15, 22) #' predicted <- rbind( @@ -366,9 +372,9 @@ interval_coverage_deviation_quantile <- function(observed, predicted, quantile) #' @inheritParams bias_range #' @param na.rm logical. Should missing values be removed? #' @return scalar with the quantile bias for a single quantile prediction -#' @author Nikos Bosse \email{nikosbosse@@gmail.com} +#' @export +#' @keywords metric #' @examples -#' #' predicted <- c( #' 705.500, 1127.000, 4006.250, 4341.500, 4709.000, 4821.996, #' 5340.500, 5451.000, 5703.500, 6087.014, 6329.500, 6341.000, @@ -381,8 +387,6 @@ interval_coverage_deviation_quantile <- function(observed, predicted, quantile) #' observed <- 8062 #' #' bias_quantile(observed, predicted, quantile) -#' @export -#' @keywords metric bias_quantile <- function(observed, predicted, quantile, na.rm = TRUE) { assert_input_quantile(observed, predicted, quantile) n <- length(observed) @@ -408,6 +412,7 @@ bias_quantile <- function(observed, predicted, quantile, na.rm = TRUE) { #' the median is imputed as being the mean of the two innermost quantiles. #' @inheritParams bias_quantile #' @return scalar with the quantile bias for a single quantile prediction +#' @keywords internal bias_quantile_single_vector <- function(observed, predicted, quantile, na.rm) { assert_number(observed) diff --git a/R/summarise_scores.R b/R/summarise_scores.R index f71a0f7cc..6d166da43 100644 --- a/R/summarise_scores.R +++ b/R/summarise_scores.R @@ -181,6 +181,7 @@ summarize_scores <- summarise_scores #' returned. By default (`NULL`), relative skill will not be scaled with #' respect to a baseline model. #' @export +#' @keywords keyword scoring add_pairwise_comparison <- function(scores, by = NULL, relative_skill_metric = "auto", diff --git a/R/utils.R b/R/utils.R index 53a2d800e..4cec97ed1 100644 --- a/R/utils.R +++ b/R/utils.R @@ -218,6 +218,7 @@ remove_scoringutils_class <- function(object) { #' @param fun A function to execute #' @return The result of `fun` or `NULL` if `fun` errors #' @export +#' @keywords scoring #' @examples #' f <- function(x) {x} #' run_safely(2, fun = f) diff --git a/R/utils_data_handling.R b/R/utils_data_handling.R index 1b1302dbf..59f79c5f6 100644 --- a/R/utils_data_handling.R +++ b/R/utils_data_handling.R @@ -176,6 +176,8 @@ range_long_to_quantile <- function(data, #' and upper bounds of the 50% and 90% prediction intervals (corresponding to #' the 0.25 and 0.75 as well as the 0.05 and 0.095 quantiles). #' @param ... method arguments +#' @keywords data-handling +#' @export quantile_to_interval <- function(...) { UseMethod("quantile_to_interval") } @@ -199,6 +201,7 @@ quantile_to_interval <- function(...) { #' @importFrom data.table copy #' @export #' @rdname quantile_to_interval +#' @keywords data-handling quantile_to_interval.data.frame <- function(dt, format = "long", keep_quantile_col = FALSE, @@ -241,6 +244,7 @@ quantile_to_interval.data.frame <- function(dt, #' `forecast_id` and `range`. #' @export #' @rdname quantile_to_interval +#' @keywords data-handling quantile_to_interval.numeric <- function(observed, predicted, quantile, diff --git a/R/validate.R b/R/validate.R index d283f7aa8..5cd246fd0 100644 --- a/R/validate.R +++ b/R/validate.R @@ -27,13 +27,14 @@ #' @importFrom data.table ':=' is.data.table #' @importFrom checkmate assert_data_frame #' @export -#' @keywords validate +#' @keywords check-forecasts validate <- function(data, ...) { UseMethod("validate") } #' @rdname validate #' @export +#' @keywords check-forecasts validate.default <- function(data, ...) { assert(check_data_columns(data)) @@ -49,6 +50,7 @@ validate.default <- function(data, ...) { #' @rdname validate #' @export +#' @keywords check-forecasts validate.scoringutils_binary <- function(data, ...) { data <- validate_general(data) @@ -69,6 +71,7 @@ validate.scoringutils_binary <- function(data, ...) { #' @rdname validate #' @export +#' @keywords check-forecasts validate.scoringutils_point <- function(data, ...) { data <- validate_general(data) @@ -91,6 +94,7 @@ validate.scoringutils_quantile <- function(data, ...) { #' @rdname validate #' @export +#' @keywords check-forecasts validate.scoringutils_sample <- function(data, ...) { data <- validate_general(data) return(data[]) @@ -113,7 +117,7 @@ validate.scoringutils_sample <- function(data, ...) { #' @importFrom data.table ':=' is.data.table setattr #' @importFrom checkmate assert_data_table #' @export -#' @keywords validate +#' @keywords internal_input_check validate_general <- function(data) { # check that data is a data.table and that the columns look fine assert_data_table(data) @@ -162,7 +166,7 @@ validate_general <- function(data) { #' @param classname name of the class to be created #' @return An object of the class indicated by `classname` #' @export -#' @keywords validate +#' @keywords internal new_scoringutils <- function(data, classname) { data <- as.data.table(data) data <- assure_model_column(data) @@ -186,7 +190,7 @@ new_scoringutils <- function(data, classname) { #' @return A named list of metrics, with those filtered out that are not #' valid functions #' @importFrom checkmate assert_list test_list check_function - +#' @keywords internal_input_check validate_metrics <- function(metrics) { assert_list(metrics, min.len = 1, names = "named") diff --git a/_pkgdown.yml b/_pkgdown.yml index 8f21f55aa..ea4f1e2a0 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -21,14 +21,14 @@ reference: - title: Package documentation contents: - scoringutils - - title: Functions to check and analyse inputs + - title: Functions to analyse inputs and obtain useful information contents: - has_keyword("check-forecasts") - title: Functions for convenient forecast evaluation contents: - score - has_keyword("scoring") - - starts_with("score_") + - starts_with("score") - title: Lower-level scoring functions contents: - has_keyword("metric") @@ -37,9 +37,12 @@ reference: - has_keyword("data-handling") - title: Functions for plotting and data visualisation contents: - - starts_with("plot_") + - starts_with("plot") - has_keyword("plotting") - - title: Internal functions + - title: Internal input check functions + contents: + - has_keyword("internal_input_check") + - title: Misc internal functions contents: - has_keyword("internal") - title: Example data and information diff --git a/man/add_pairwise_comparison.Rd b/man/add_pairwise_comparison.Rd index 31777dbfc..75217069c 100644 --- a/man/add_pairwise_comparison.Rd +++ b/man/add_pairwise_comparison.Rd @@ -41,3 +41,5 @@ Relative skill will be calculated for the aggregation level specified in \code{by}. WRITE MORE INFO HERE. } +\keyword{keyword} +\keyword{scoring} diff --git a/man/assert_dims_ok_point.Rd b/man/assert_dims_ok_point.Rd index 4f6bd3bd0..e7534eb1b 100644 --- a/man/assert_dims_ok_point.Rd +++ b/man/assert_dims_ok_point.Rd @@ -37,4 +37,4 @@ Allowed options are therefore } } } -\keyword{check-inputs} +\keyword{internal_input_check} diff --git a/man/assert_equal_length.Rd b/man/assert_equal_length.Rd index 8b83b4c85..686209bf4 100644 --- a/man/assert_equal_length.Rd +++ b/man/assert_equal_length.Rd @@ -23,4 +23,4 @@ error otherwise. \description{ Check whether variables all have the same length } -\keyword{internal} +\keyword{internal_input_check} diff --git a/man/assert_input_binary.Rd b/man/assert_input_binary.Rd index 5b4d8b2bf..e1aae3621 100644 --- a/man/assert_input_binary.Rd +++ b/man/assert_input_binary.Rd @@ -27,4 +27,4 @@ error otherwise. Function assesses whether the inputs correspond to the requirements for scoring binary forecasts. } -\keyword{check-inputs} +\keyword{internal_input_check} diff --git a/man/assert_input_interval.Rd b/man/assert_input_interval.Rd index b8d2d93d0..4ab7025bc 100644 --- a/man/assert_input_interval.Rd +++ b/man/assert_input_interval.Rd @@ -28,4 +28,4 @@ error otherwise. Function assesses whether the inputs correspond to the requirements for scoring interval-based forecasts. } -\keyword{internal} +\keyword{internal_input_check} diff --git a/man/assert_input_point.Rd b/man/assert_input_point.Rd index f2f9434a9..c2ea48b7c 100644 --- a/man/assert_input_point.Rd +++ b/man/assert_input_point.Rd @@ -21,4 +21,4 @@ error otherwise. Function assesses whether the inputs correspond to the requirements for scoring point forecasts. } -\keyword{check-inputs} +\keyword{internal_input_check} diff --git a/man/assert_input_quantile.Rd b/man/assert_input_quantile.Rd index c9a499136..380cf5e6f 100644 --- a/man/assert_input_quantile.Rd +++ b/man/assert_input_quantile.Rd @@ -31,4 +31,4 @@ error otherwise. Function assesses whether the inputs correspond to the requirements for scoring quantile-based forecasts. } -\keyword{internal} +\keyword{internal_input_check} diff --git a/man/assert_input_sample.Rd b/man/assert_input_sample.Rd index 027899adf..52071391a 100644 --- a/man/assert_input_sample.Rd +++ b/man/assert_input_sample.Rd @@ -24,4 +24,4 @@ error otherwise. Function assesses whether the inputs correspond to the requirements for scoring sample-based forecasts. } -\keyword{check-inputs} +\keyword{internal_input_check} diff --git a/man/assert_not_null.Rd b/man/assert_not_null.Rd index 276615941..ce95cd10e 100644 --- a/man/assert_not_null.Rd +++ b/man/assert_not_null.Rd @@ -18,4 +18,4 @@ Check whether a certain variable is not \code{NULL} and return the name of that variable and the function call where the variable is missing. This function is a helper function that should only be called within other functions } -\keyword{internal} +\keyword{internal_input_check} diff --git a/man/assure_model_column.Rd b/man/assure_model_column.Rd index 456652df2..591588fea 100644 --- a/man/assure_model_column.Rd +++ b/man/assure_model_column.Rd @@ -6,6 +6,9 @@ \usage{ assure_model_column(data) } +\arguments{ +\item{data}{A data.frame or data.table with predicted and observed values.} +} \value{ The data.table with a column called \code{model} } @@ -13,4 +16,4 @@ The data.table with a column called \code{model} Check whether the data.table has a column called \code{model}. If not, a column called \code{model} is added with the value \verb{Unspecified model}. } -\keyword{internal} +\keyword{internal_input_check} diff --git a/man/bias_quantile.Rd b/man/bias_quantile.Rd index a5f4b6492..863853d9b 100644 --- a/man/bias_quantile.Rd +++ b/man/bias_quantile.Rd @@ -57,7 +57,6 @@ Bias can assume values between -1 and 1 and is 0 ideally (i.e. unbiased). } \examples{ - predicted <- c( 705.500, 1127.000, 4006.250, 4341.500, 4709.000, 4821.996, 5340.500, 5451.000, 5703.500, 6087.014, 6329.500, 6341.000, @@ -71,7 +70,4 @@ observed <- 8062 bias_quantile(observed, predicted, quantile) } -\author{ -Nikos Bosse \email{nikosbosse@gmail.com} -} \keyword{metric} diff --git a/man/bias_quantile_single_vector.Rd b/man/bias_quantile_single_vector.Rd index 26ac893b5..5d7ba030d 100644 --- a/man/bias_quantile_single_vector.Rd +++ b/man/bias_quantile_single_vector.Rd @@ -25,3 +25,4 @@ scalar with the quantile bias for a single quantile prediction Internal function to compute bias for a single observed value, a vector of predicted values and a vector of quantiles. } +\keyword{internal} diff --git a/man/check_attribute_conflict.Rd b/man/check_attribute_conflict.Rd index c01ac264e..588771565 100644 --- a/man/check_attribute_conflict.Rd +++ b/man/check_attribute_conflict.Rd @@ -24,4 +24,4 @@ an attribute \code{forecast_unit} is stored, but is different from the \code{forecast_unit} inferred from the data. The check is successful if the stored and the inferred value are the same. } -\keyword{internal} +\keyword{internal_input_check} diff --git a/man/check_columns_present.Rd b/man/check_columns_present.Rd index cfe76f064..392839b07 100644 --- a/man/check_columns_present.Rd +++ b/man/check_columns_present.Rd @@ -20,4 +20,4 @@ The functions loops over the column names and checks whether they are present. If an issue is encountered, the function immediately stops and returns a message with the first issue encountered. } -\keyword{check-inputs} +\keyword{internal_input_check} diff --git a/man/check_data_columns.Rd b/man/check_data_columns.Rd index 04fba0892..6115db266 100644 --- a/man/check_data_columns.Rd +++ b/man/check_data_columns.Rd @@ -18,4 +18,4 @@ Checks whether data is a data.frame, whether columns "observed" and "predicted" are present, and checks that only one of "quantile" and "sample_id" is present. } -\keyword{check-inputs} +\keyword{internal_input_check} diff --git a/man/check_dims_ok_point.Rd b/man/check_dims_ok_point.Rd index 1269a6725..b0fb82ab8 100644 --- a/man/check_dims_ok_point.Rd +++ b/man/check_dims_ok_point.Rd @@ -37,4 +37,4 @@ Allowed options are therefore } } } -\keyword{check-inputs} +\keyword{internal_input_check} diff --git a/man/check_duplicates.Rd b/man/check_duplicates.Rd index e4b0918ee..dff552eb5 100644 --- a/man/check_duplicates.Rd +++ b/man/check_duplicates.Rd @@ -20,4 +20,4 @@ error message otherwise \description{ Runs \code{\link[=get_duplicate_forecasts]{get_duplicate_forecasts()}} and returns a message if an issue is encountered } -\keyword{internal} +\keyword{internal_input_check} diff --git a/man/check_has_attribute.Rd b/man/check_has_attribute.Rd index 339e0d6d0..5111aac38 100644 --- a/man/check_has_attribute.Rd +++ b/man/check_has_attribute.Rd @@ -18,4 +18,4 @@ error message otherwise \description{ Checks whether an object has an attribute } -\keyword{check-inputs} +\keyword{internal_input_check} diff --git a/man/check_input_binary.Rd b/man/check_input_binary.Rd index 10d6c36ea..86d4d2f9e 100644 --- a/man/check_input_binary.Rd +++ b/man/check_input_binary.Rd @@ -27,4 +27,4 @@ error message otherwise Function assesses whether the inputs correspond to the requirements for scoring binary forecasts. } -\keyword{check-inputs} +\keyword{internal_input_check} diff --git a/man/check_input_interval.Rd b/man/check_input_interval.Rd index faa9e4db5..7b68f92f5 100644 --- a/man/check_input_interval.Rd +++ b/man/check_input_interval.Rd @@ -28,4 +28,4 @@ error message otherwise Function assesses whether the inputs correspond to the requirements for scoring interval-based forecasts. } -\keyword{check-inputs} +\keyword{internal_input_check} diff --git a/man/check_input_point.Rd b/man/check_input_point.Rd index 060b785b6..31e838db4 100644 --- a/man/check_input_point.Rd +++ b/man/check_input_point.Rd @@ -21,4 +21,4 @@ error message otherwise Function assesses whether the inputs correspond to the requirements for scoring point forecasts. } -\keyword{check-inputs} +\keyword{internal_input_check} diff --git a/man/check_input_quantile.Rd b/man/check_input_quantile.Rd index a2315aa2e..e0a9877b1 100644 --- a/man/check_input_quantile.Rd +++ b/man/check_input_quantile.Rd @@ -28,4 +28,4 @@ error message otherwise Function assesses whether the inputs correspond to the requirements for scoring quantile-based forecasts. } -\keyword{check-inputs} +\keyword{internal_input_check} diff --git a/man/check_input_sample.Rd b/man/check_input_sample.Rd index 607bebb5f..32724b8f7 100644 --- a/man/check_input_sample.Rd +++ b/man/check_input_sample.Rd @@ -24,4 +24,4 @@ error message otherwise Function assesses whether the inputs correspond to the requirements for scoring sample-based forecasts. } -\keyword{check-inputs} +\keyword{internal_input_check} diff --git a/man/check_no_NA_present.Rd b/man/check_no_NA_present.Rd index cf89ce468..bb742779d 100644 --- a/man/check_no_NA_present.Rd +++ b/man/check_no_NA_present.Rd @@ -20,4 +20,4 @@ Function checks whether any of the columns in a data.frame, as specified in \code{columns}, have NA values. If so, it returns a string with an error message, otherwise it returns TRUE. } -\keyword{internal} +\keyword{internal_input_check} diff --git a/man/check_number_per_forecast.Rd b/man/check_number_per_forecast.Rd index 4d0a18432..f15ef1a54 100644 --- a/man/check_number_per_forecast.Rd +++ b/man/check_number_per_forecast.Rd @@ -20,4 +20,4 @@ Function checks the number of quantiles or samples per forecast. If the number of quantiles or samples is the same for all forecasts, it returns TRUE and a string with an error message otherwise. } -\keyword{internal} +\keyword{internal_input_check} diff --git a/man/check_numeric_vector.Rd b/man/check_numeric_vector.Rd index 847bef940..1b736bc01 100644 --- a/man/check_numeric_vector.Rd +++ b/man/check_numeric_vector.Rd @@ -54,4 +54,4 @@ error message otherwise \description{ Helper function } -\keyword{internal} +\keyword{internal_input_check} diff --git a/man/check_quantiles.Rd b/man/check_quantiles.Rd index 7ddd0d2fc..3b3ae08b4 100644 --- a/man/check_quantiles.Rd +++ b/man/check_quantiles.Rd @@ -24,4 +24,4 @@ and contain no duplicates. This is used in \url{bias_range()} and \url{bias_quantile()} to provide informative errors to users. } -\keyword{internal} +\keyword{internal_input_check} diff --git a/man/check_try.Rd b/man/check_try.Rd index 87f479f66..94574cf48 100644 --- a/man/check_try.Rd +++ b/man/check_try.Rd @@ -19,4 +19,4 @@ see whether assertions fail when checking inputs (i.e. to convert an \verb{assert_*()} statement into a check). If the expression fails, the error message is returned. If the expression succeeds, \code{TRUE} is returned. } -\keyword{internal} +\keyword{internal_input_check} diff --git a/man/document_assert_functions.Rd b/man/document_assert_functions.Rd index ee0dbc967..c8046bf67 100644 --- a/man/document_assert_functions.Rd +++ b/man/document_assert_functions.Rd @@ -10,3 +10,4 @@ error otherwise. \description{ Documentation template for check functions } +\keyword{internal} diff --git a/man/document_check_functions.Rd b/man/document_check_functions.Rd index 6f7f7f677..256db46f5 100644 --- a/man/document_check_functions.Rd +++ b/man/document_check_functions.Rd @@ -15,3 +15,4 @@ error message otherwise \description{ Documentation template for check functions } +\keyword{internal} diff --git a/man/document_score_data.Rd b/man/document_score_data.Rd index 9e30190d3..9b8b19558 100644 --- a/man/document_score_data.Rd +++ b/man/document_score_data.Rd @@ -12,3 +12,4 @@ specifications detailed in \code{\link[=score]{score()}}.} \description{ Documentation template for scoring input data } +\keyword{internal} diff --git a/man/document_test_functions.Rd b/man/document_test_functions.Rd index 620cb1989..68fe7c7a5 100644 --- a/man/document_test_functions.Rd +++ b/man/document_test_functions.Rd @@ -9,3 +9,4 @@ Returns TRUE if the check was successful and FALSE otherwise \description{ Documentation template for test functions } +\keyword{internal} diff --git a/man/get_forecast_type.Rd b/man/get_forecast_type.Rd index 19d52d2b3..27c4e08b2 100644 --- a/man/get_forecast_type.Rd +++ b/man/get_forecast_type.Rd @@ -30,4 +30,4 @@ The function runs additional checks to make sure the data satisfies the requirements of the respective forecast type and throws an informative error if any issues are found. } -\keyword{check-forceasts} +\keyword{check-forecasts} diff --git a/man/get_metrics.Rd b/man/get_metrics.Rd index 438e6b8f5..aed3b5e81 100644 --- a/man/get_metrics.Rd +++ b/man/get_metrics.Rd @@ -7,7 +7,7 @@ get_metrics(scores) } \arguments{ -\item{score}{A data.table with an attribute \code{metric_names}} +\item{scores}{A data.table with an attribute \code{metric_names}} } \value{ Character vector with the metrics that were used for scoring. @@ -16,4 +16,4 @@ Character vector with the metrics that were used for scoring. Internal helper function to get the metrics that were used to score forecasts. } -\keyword{internal} +\keyword{internal_input_check} diff --git a/man/get_type.Rd b/man/get_type.Rd index bcce4b70a..596cf4c65 100644 --- a/man/get_type.Rd +++ b/man/get_type.Rd @@ -19,4 +19,4 @@ of observed or predicted values). The function checks whether the input is a factor, or else whether it is integer (or can be coerced to integer) or whether it's continuous. } -\keyword{internal} +\keyword{internal_input_check} diff --git a/man/interval_coverage.Rd b/man/interval_coverage.Rd index 74256cc77..3da7973cc 100644 --- a/man/interval_coverage.Rd +++ b/man/interval_coverage.Rd @@ -52,3 +52,4 @@ quantile <- c(0.1, 0.25, 0.5, 0.75, 0.9) interval_coverage_quantile(observed, predicted, quantile) interval_coverage_sample(observed, predicted) } +\keyword{metric} diff --git a/man/interval_coverage_deviation_quantile.Rd b/man/interval_coverage_deviation_quantile.Rd index 9a6029ec7..136afd8a2 100644 --- a/man/interval_coverage_deviation_quantile.Rd +++ b/man/interval_coverage_deviation_quantile.Rd @@ -73,3 +73,4 @@ predicted <- rbind( quantile <- c(0.1, 0.25, 0.5, 0.75, 0.9) interval_coverage_deviation_quantile(observed, predicted, quantile) } +\keyword{metric} diff --git a/man/new_scoringutils.Rd b/man/new_scoringutils.Rd index b2f83ff6a..e19feb989 100644 --- a/man/new_scoringutils.Rd +++ b/man/new_scoringutils.Rd @@ -22,4 +22,4 @@ Construct a class based on a data.frame or similar. The constructor \item assigns a class } } -\keyword{validate} +\keyword{internal} diff --git a/man/quantile_to_interval.Rd b/man/quantile_to_interval.Rd index e99cbadad..b61498eee 100644 --- a/man/quantile_to_interval.Rd +++ b/man/quantile_to_interval.Rd @@ -65,3 +65,4 @@ be characterised by one or multiple prediction intervals, e.g. the lower and upper bounds of the 50\% and 90\% prediction intervals (corresponding to the 0.25 and 0.75 as well as the 0.05 and 0.095 quantiles). } +\keyword{data-handling} diff --git a/man/run_safely.Rd b/man/run_safely.Rd index 9e673b061..b8c45751f 100644 --- a/man/run_safely.Rd +++ b/man/run_safely.Rd @@ -33,3 +33,4 @@ run_safely(2, y = 3, fun = f) run_safely(fun = f) run_safely(y = 3, fun = f) } +\keyword{scoring} diff --git a/man/test_columns_not_present.Rd b/man/test_columns_not_present.Rd index f55fe25b1..5f7b71994 100644 --- a/man/test_columns_not_present.Rd +++ b/man/test_columns_not_present.Rd @@ -19,4 +19,4 @@ The function checks whether all column names are NOT present. If none of the columns are present, the function returns TRUE. If one or more columns are present, the function returns FALSE. } -\keyword{internal} +\keyword{internal_input_check} diff --git a/man/test_columns_present.Rd b/man/test_columns_present.Rd index ed5076417..1931ca59c 100644 --- a/man/test_columns_present.Rd +++ b/man/test_columns_present.Rd @@ -19,4 +19,4 @@ The function checks whether all column names are present. If one or more columns are missing, the function returns FALSE. If all columns are present, the function returns TRUE. } -\keyword{internal} +\keyword{internal_input_check} diff --git a/man/test_forecast_type_is_binary.Rd b/man/test_forecast_type_is_binary.Rd index de6b0501c..79c952e17 100644 --- a/man/test_forecast_type_is_binary.Rd +++ b/man/test_forecast_type_is_binary.Rd @@ -15,4 +15,4 @@ Returns TRUE if basic requirements are satisfied and FALSE otherwise \description{ Checks type of the necessary columns. } -\keyword{internal} +\keyword{internal_input_check} diff --git a/man/test_forecast_type_is_point.Rd b/man/test_forecast_type_is_point.Rd index 00cb9dd2c..ad1c624fc 100644 --- a/man/test_forecast_type_is_point.Rd +++ b/man/test_forecast_type_is_point.Rd @@ -15,4 +15,4 @@ Returns TRUE if basic requirements are satisfied and FALSE otherwise \description{ Checks type of the necessary columns. } -\keyword{internal} +\keyword{internal_input_check} diff --git a/man/test_forecast_type_is_quantile.Rd b/man/test_forecast_type_is_quantile.Rd index 214a86d32..7f77043f3 100644 --- a/man/test_forecast_type_is_quantile.Rd +++ b/man/test_forecast_type_is_quantile.Rd @@ -15,4 +15,4 @@ Returns TRUE if basic requirements are satisfied and FALSE otherwise \description{ Checks type of the necessary columns. } -\keyword{internal} +\keyword{internal_input_check} diff --git a/man/test_forecast_type_is_sample.Rd b/man/test_forecast_type_is_sample.Rd index 4568ed93e..be7fea95c 100644 --- a/man/test_forecast_type_is_sample.Rd +++ b/man/test_forecast_type_is_sample.Rd @@ -15,4 +15,4 @@ Returns TRUE if basic requirements are satisfied and FALSE otherwise \description{ Checks type of the necessary columns. } -\keyword{internal} +\keyword{internal_input_check} diff --git a/man/validate.Rd b/man/validate.Rd index 88badf49a..910f0d4aa 100644 --- a/man/validate.Rd +++ b/man/validate.Rd @@ -52,4 +52,4 @@ To summarise, the data should come in one of four different formats: \item A quantile-based format (see \link{example_quantile}) } } -\keyword{validate} +\keyword{check-forecasts} diff --git a/man/validate_general.Rd b/man/validate_general.Rd index 548fa0322..e379c5a0f 100644 --- a/man/validate_general.Rd +++ b/man/validate_general.Rd @@ -25,4 +25,4 @@ forecast type. The function for all forecasts } } -\keyword{validate} +\keyword{internal_input_check} diff --git a/man/validate_metrics.Rd b/man/validate_metrics.Rd index 9ce9eda87..d373eaa58 100644 --- a/man/validate_metrics.Rd +++ b/man/validate_metrics.Rd @@ -21,3 +21,4 @@ of valid functions. The function is used in \code{\link[=score]{score()}} to make sure that all metrics are valid functions } +\keyword{internal_input_check} diff --git a/man/wis.Rd b/man/wis.Rd index 65f099757..5cb8b998a 100644 --- a/man/wis.Rd +++ b/man/wis.Rd @@ -141,3 +141,4 @@ can control the behvaviour with the \code{count_median_twice}-argument. WIS components can be computed individually using the functions \code{overprediction}, \code{underprediction}, and \code{dispersion.} } +\keyword{metric}