diff --git a/NAMESPACE b/NAMESPACE index 97d7f8b63..d05f4258d 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,6 +1,5 @@ # Generated by roxygen2: do not edit by hand -S3method(plot,scoringutils_available_forecasts) S3method(print,scoringutils_check) S3method(quantile_to_interval,data.frame) S3method(quantile_to_interval,numeric) @@ -19,8 +18,6 @@ export(add_coverage) export(add_pairwise_comparison) export(ae_median_quantile) export(ae_median_sample) -export(avail_forecasts) -export(available_forecasts) export(available_metrics) export(bias_quantile) export(bias_range) @@ -31,6 +28,7 @@ export(crps_sample) export(dispersion) export(dss_sample) export(get_duplicate_forecasts) +export(get_forecast_counts) export(get_forecast_type) export(get_forecast_unit) export(interval_coverage_deviation_quantile) @@ -49,8 +47,8 @@ export(overprediction) export(pairwise_comparison) export(pit) export(pit_sample) -export(plot_avail_forecasts) export(plot_correlation) +export(plot_forecast_counts) export(plot_heatmap) export(plot_interval_coverage) export(plot_pairwise_comparison) @@ -88,6 +86,7 @@ importFrom(checkmate,assert_list) importFrom(checkmate,assert_logical) importFrom(checkmate,assert_number) importFrom(checkmate,assert_numeric) +importFrom(checkmate,assert_string) importFrom(checkmate,assert_vector) importFrom(checkmate,check_atomic_vector) importFrom(checkmate,check_data_frame) diff --git a/NEWS.md b/NEWS.md index 0faf9eaf2..4067c6d9f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -25,10 +25,10 @@ The update introduces breaking changes. If you want to keep using the older vers - `add_coverage()` was reworked completely. It's new purpose is now to add coverage information to the raw forecast data (essentially fulfilling some of the functionality that was previously covered by `score_quantile()`) - The function `find_duplicates()` was renamed to `get_duplicate_forecasts()` - Changes to `avail_forecasts()` and `plot_avail_forecasts()`: - - The function `avail_forecasts()` was renamed to `available_forecasts()` for consistency with `available_metrics()`. The old function, `avail_forecasts()` is still available as an alias, but will be removed in the future. - - For clarity, the output column in `avail_forecasts()` was renamed from "Number forecasts" to "count". - - `available_forecasts()` now also displays combinations where there are 0 forecasts, instead of silently dropping corresponding rows. - - `plot_avail_forecasts()` has been deprecated in favour of an S3 method for `plot()`. An alias is still available, but will be removed in the future. + - The function `avail_forecasts()` was renamed to `get_forecast_counts()`. This represents a change in the naming convention where we aim to name functions that provide the user with additional useful information about the data with a prefix "get_". Sees Issue #403 and #521 and PR #511 by @nikosbosse and reviewed by @seabbs for details. + - For clarity, the output column in `get_forecast_counts()` was renamed from "Number forecasts" to "count". + - `get_forecast_counts()` now also displays combinations where there are 0 forecasts, instead of silently dropping corresponding rows. + - `plot_avail_forecasts()` was renamed `plot_forecast_counts()` in line with the change in the function name. The `x` argument no longer has a default value, as the value will depend on the data provided by the user. - The deprecated `..density..` was replaced with `after_stat(density)` in ggplot calls. - Files ending in ".Rda" were renamed to ".rds" where appropriate when used together with `saveRDS()` or `readRDS()`. - added documentation for the return value of `summarise_scores()`. @@ -188,7 +188,7 @@ to a function `summarise_scores()` - New function `check_forecasts()` to analyse input data before scoring - New function `correlation()` to compute correlations between different metrics - New function `add_coverage()` to add coverage for specific central prediction intervals. -- New function `available_forecasts()` allows to visualise the number of available forecasts. +- New function `avail_forecasts()` allows to visualise the number of available forecasts. - New function `find_duplicates()` to find duplicate forecasts which cause an error. - All plotting functions were renamed to begin with `plot_`. Arguments were simplified. diff --git a/R/available_forecasts.R b/R/available_forecasts.R index 17418b0a6..8225620d3 100644 --- a/R/available_forecasts.R +++ b/R/available_forecasts.R @@ -31,10 +31,10 @@ #' @examples #' data.table::setDTthreads(1) # only needed to avoid issues on CRAN #' -#' available_forecasts(example_quantile, +#' get_forecast_counts(example_quantile, #' by = c("model", "target_type") #' ) -available_forecasts <- function(data, +get_forecast_counts <- function(data, by = NULL, collapse = c("quantile", "sample_id")) { @@ -58,7 +58,7 @@ available_forecasts <- function(data, data <- data[data[, .I[1], by = collapse_by]$V1] # count number of rows = number of forecasts - out <- data[, .(`count` = .N), by = by] + out <- data[, .(count = .N), by = by] # make sure that all combinations in "by" are included in the output (with # count = 0). To achieve that, take the unique values in data and expand grid @@ -70,23 +70,5 @@ available_forecasts <- function(data, out <- merge(out, out_empty, by = by, all.y = TRUE) out[, count := nafill(count, fill = 0)] - class(out) <- c("scoringutils_available_forecasts", class(out)) - return(out[]) } - -#' @title Count Number of Available Forecasts `r lifecycle::badge("deprecated")` -#' @details `r lifecycle::badge("deprecated")` Deprecated in 1.2.2. Use -#' [available_forecasts()] instead. -#' @inherit available_forecasts -#' @keywords check-forecasts -#' @export -avail_forecasts <- function(data, - by = NULL, - collapse = c("quantile", "sample")) { - lifecycle::deprecate_warn( - "1.2.2", "avail_forecasts()", - "available_forecasts()" - ) - available_forecasts(data, by, collapse) -} diff --git a/R/plot.R b/R/plot.R index 0ec4bb8c1..1527ef8e6 100644 --- a/R/plot.R +++ b/R/plot.R @@ -470,7 +470,7 @@ plot_predictions <- function(data, # it separately here to deal with the case when only the median is provided # (in which case ggdist::geom_lineribbon() will fail) if (0 %in% range) { - select_median <- (forecasts$range %in% 0 & forecasts$boundary == "lower") + select_median <- (forecasts$range == 0 & forecasts$boundary == "lower") median <- forecasts[select_median] if (nrow(median) > 0) { @@ -941,54 +941,58 @@ plot_pit <- function(pit, #' #' @description #' Visualise Where Forecasts Are Available -#' @inheritParams print.scoringutils_check -#' @param x an S3 object of class "scoringutils_available_forecasts" -#' as produced by [available_forecasts()] -#' @param yvar character vector of length one that denotes the name of the column +#' @param forecast_counts a data.table (or similar) with a column `count` +#' holding forecast counts, as produced by [get_forecast_counts()] +#' @param x character vector of length one that denotes the name of the column +#' to appear on the x-axis of the plot. +#' @param y character vector of length one that denotes the name of the column #' to appear on the y-axis of the plot. Default is "model". -#' @param xvar character vector of length one that denotes the name of the column -#' to appear on the x-axis of the plot. Default is "forecast_date". -#' @param make_xvar_factor logical (default is TRUE). Whether or not to convert +#' @param x_as_factor logical (default is TRUE). Whether or not to convert #' the variable on the x-axis to a factor. This has an effect e.g. if dates #' are shown on the x-axis. -#' @param show_numbers logical (default is `TRUE`) that indicates whether +#' @param show_counts logical (default is `TRUE`) that indicates whether #' or not to show the actual count numbers on the plot #' @return ggplot object with a plot of interval coverage #' @importFrom ggplot2 ggplot scale_colour_manual scale_fill_manual #' geom_tile scale_fill_gradient .data #' @importFrom data.table dcast .I .N +#' @importFrom checkmate assert_string assert_logical assert #' @export #' @examples #' library(ggplot2) -#' available_forecasts <- available_forecasts( +#' forecast_counts <- get_forecast_counts( #' example_quantile, by = c("model", "target_type", "target_end_date") #' ) -#' plot( -#' available_forecasts, xvar = "target_end_date", show_numbers = FALSE +#' plot_forecast_counts( +#' forecast_counts, x = "target_end_date", show_counts = FALSE #' ) + #' facet_wrap("target_type") -plot.scoringutils_available_forecasts <- function(x, - yvar = "model", - xvar = "forecast_date", - make_xvar_factor = TRUE, - show_numbers = TRUE, - ...) { - x <- as.data.table(x) - - if (make_xvar_factor) { - x[, eval(xvar) := as.factor(get(xvar))] +plot_forecast_counts <- function(forecast_counts, + x, + y = "model", + x_as_factor = TRUE, + show_counts = TRUE) { + + forecast_counts <- ensure_data.table(forecast_counts) + assert_string(y) + assert_string(x) + assert(check_columns_present(forecast_counts, c(y, x))) + assert_logical(x_as_factor) + assert_logical(show_counts) + + if (x_as_factor) { + forecast_counts[, eval(x) := as.factor(get(x))] } - setnames(x, old = "count", new = "Count") + setnames(forecast_counts, old = "count", new = "Count") plot <- ggplot( - x, - aes(y = .data[[yvar]], x = .data[[xvar]]) + forecast_counts, + aes(y = .data[[y]], x = .data[[x]]) ) + geom_tile(aes(fill = `Count`), - width = 0.97, height = 0.97 - ) + + width = 0.97, height = 0.97) + scale_fill_gradient( low = "grey95", high = "steelblue", na.value = "lightgrey" @@ -1001,54 +1005,14 @@ plot.scoringutils_available_forecasts <- function(x, ) ) + theme(panel.spacing = unit(2, "lines")) - - if (show_numbers) { + if (show_counts) { plot <- plot + geom_text(aes(label = `Count`)) } - return(plot) } -#' @title Visualise Where Forecasts Are Available `r lifecycle::badge("deprecated")` -#' -#' @description -#' Old version of [plot.scoringutils_available_forecasts()] for compatibility. -#' @inheritParams plot.scoringutils_available_forecasts -#' @param available_forecasts an S3 object of class "scoringutils_available_forecasts" -#' as produced by [available_forecasts()] -#' @param y character vector of length one that denotes the name of the column -#' to appear on the y-axis of the plot. Default is "model". -#' @param x character vector of length one that denotes the name of the column -#' to appear on the x-axis of the plot. Default is "forecast_date". -#' @param make_x_factor logical (default is TRUE). Whether or not to convert -#' the variable on the x-axis to a factor. This has an effect e.g. if dates -#' are shown on the x-axis. -#' @export -plot_avail_forecasts <- function(available_forecasts, - y = "model", - x = "forecast_date", - make_x_factor = TRUE, - show_numbers = TRUE) { - - lifecycle::deprecate_warn( - "1.2.2", "plot_avail_forecasts()", - "plot()" - ) - - plot.scoringutils_available_forecasts( - x = available_forecasts, - yvar = y, - xvar = x, - make_xvar_factor = make_x_factor, - show_numbers = show_numbers - ) -} - - - - #' @title Plot Correlation Between Metrics #' #' @description diff --git a/R/validate.R b/R/validate.R index 5cd246fd0..075abaa0b 100644 --- a/R/validate.R +++ b/R/validate.R @@ -111,7 +111,7 @@ validate.scoringutils_sample <- function(data, ...) { #' - checks there are no duplicate forecasts #' - if appropriate, checks the number of samples / quantiles is the same #' for all forecasts -#' @inheritParams available_forecasts +#' @inheritParams get_forecast_counts #' @return returns the input, with a few new attributes that hold additional #' information, messages and warnings #' @importFrom data.table ':=' is.data.table setattr @@ -162,7 +162,7 @@ validate_general <- function(data) { #' - makes sure that a column called `model` exists and if not creates one #' - assigns a class #' -#' @inheritParams available_forecasts +#' @inheritParams get_forecast_counts #' @param classname name of the class to be created #' @return An object of the class indicated by `classname` #' @export diff --git a/inst/manuscript/R/00-standalone-Figure-replication.R b/inst/manuscript/R/00-standalone-Figure-replication.R index 3b1b66b9c..373f25ec4 100644 --- a/inst/manuscript/R/00-standalone-Figure-replication.R +++ b/inst/manuscript/R/00-standalone-Figure-replication.R @@ -537,7 +537,7 @@ p2 + p1 + p_true + available_forecasts(data = example_integer, by = c("model", "target_type", "forecast_date")) |> plot_available_forecasts(x = "forecast_date", - show_numbers = FALSE) + + show_counts = FALSE) + facet_wrap(~ target_type) + labs(y = "Model", x = "Forecast date") diff --git a/inst/manuscript/manuscript.Rmd b/inst/manuscript/manuscript.Rmd index e907defac..782dc468d 100644 --- a/inst/manuscript/manuscript.Rmd +++ b/inst/manuscript/manuscript.Rmd @@ -432,7 +432,7 @@ library("ggplot2") available_forecasts(data = example_integer, by = c("model", "target_type", "forecast_date")) |> plot_available_forecasts(x = "forecast_date", - show_numbers = FALSE) + + show_counts = FALSE) + facet_wrap(~ target_type) + labs(y = "Model", x = "Forecast date") ``` diff --git a/man/avail_forecasts.Rd b/man/avail_forecasts.Rd deleted file mode 100644 index 57d47c5cf..000000000 --- a/man/avail_forecasts.Rd +++ /dev/null @@ -1,47 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/available_forecasts.R -\name{avail_forecasts} -\alias{avail_forecasts} -\title{Count Number of Available Forecasts \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}}} -\usage{ -avail_forecasts(data, by = NULL, collapse = c("quantile", "sample")) -} -\arguments{ -\item{data}{A data.frame or data.table with predicted and observed values.} - -\item{by}{character vector or \code{NULL} (the default) that denotes the -categories over which the number of forecasts should be counted. -By default (\code{by = NULL}) this will be the unit of a single forecast (i.e. -all available columns (apart from a few "protected" columns such as -'predicted' and 'observed') plus "quantile" or "sample_id" where present).} - -\item{collapse}{character vector (default is \verb{c("quantile", "sample_id"}) -with names of categories for which the number of rows should be collapsed to -one when counting. For example, a single forecast is usually represented by a -set of several quantiles or samples and collapsing these to one makes sure -that a single forecast only gets counted once. Setting \code{collapse = c()} -would mean that all quantiles / samples would be counted as individual -forecasts.} -} -\value{ -A data.table with columns as specified in \code{by} and an additional -column "count" with the number of forecasts. -} -\description{ -Given a data set with forecasts, count the number of available forecasts -for arbitrary grouping (e.g. the number of forecasts per model, or the -number of forecasts per model and location). -This is useful to determine whether there are any missing forecasts. -} -\details{ -\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Deprecated in 1.2.2. Use -\code{\link[=available_forecasts]{available_forecasts()}} instead. -} -\examples{ -data.table::setDTthreads(1) # only needed to avoid issues on CRAN - -available_forecasts(example_quantile, - by = c("model", "target_type") -) -} -\keyword{check-forecasts} diff --git a/man/available_forecasts.Rd b/man/get_forecast_counts.Rd similarity index 91% rename from man/available_forecasts.Rd rename to man/get_forecast_counts.Rd index 3c214a1e3..1ed71aac7 100644 --- a/man/available_forecasts.Rd +++ b/man/get_forecast_counts.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/available_forecasts.R -\name{available_forecasts} -\alias{available_forecasts} +\name{get_forecast_counts} +\alias{get_forecast_counts} \title{Count Number of Available Forecasts} \usage{ -available_forecasts(data, by = NULL, collapse = c("quantile", "sample_id")) +get_forecast_counts(data, by = NULL, collapse = c("quantile", "sample_id")) } \arguments{ \item{data}{A data.frame or data.table with predicted and observed values.} @@ -36,7 +36,7 @@ This is useful to determine whether there are any missing forecasts. \examples{ data.table::setDTthreads(1) # only needed to avoid issues on CRAN -available_forecasts(example_quantile, +get_forecast_counts(example_quantile, by = c("model", "target_type") ) } diff --git a/man/plot.scoringutils_available_forecasts.Rd b/man/plot.scoringutils_available_forecasts.Rd deleted file mode 100644 index f11e0dc5d..000000000 --- a/man/plot.scoringutils_available_forecasts.Rd +++ /dev/null @@ -1,50 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/plot.R -\name{plot.scoringutils_available_forecasts} -\alias{plot.scoringutils_available_forecasts} -\title{Visualise Where Forecasts Are Available} -\usage{ -\method{plot}{scoringutils_available_forecasts}( - x, - yvar = "model", - xvar = "forecast_date", - make_xvar_factor = TRUE, - show_numbers = TRUE, - ... -) -} -\arguments{ -\item{x}{an S3 object of class "scoringutils_available_forecasts" -as produced by \code{\link[=available_forecasts]{available_forecasts()}}} - -\item{yvar}{character vector of length one that denotes the name of the column -to appear on the y-axis of the plot. Default is "model".} - -\item{xvar}{character vector of length one that denotes the name of the column -to appear on the x-axis of the plot. Default is "forecast_date".} - -\item{make_xvar_factor}{logical (default is TRUE). Whether or not to convert -the variable on the x-axis to a factor. This has an effect e.g. if dates -are shown on the x-axis.} - -\item{show_numbers}{logical (default is \code{TRUE}) that indicates whether -or not to show the actual count numbers on the plot} - -\item{...}{additional arguments (not used here)} -} -\value{ -ggplot object with a plot of interval coverage -} -\description{ -Visualise Where Forecasts Are Available -} -\examples{ -library(ggplot2) -available_forecasts <- available_forecasts( - example_quantile, by = c("model", "target_type", "target_end_date") -) -plot( - available_forecasts, xvar = "target_end_date", show_numbers = FALSE -) + - facet_wrap("target_type") -} diff --git a/man/plot_avail_forecasts.Rd b/man/plot_avail_forecasts.Rd deleted file mode 100644 index c10035012..000000000 --- a/man/plot_avail_forecasts.Rd +++ /dev/null @@ -1,34 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/plot.R -\name{plot_avail_forecasts} -\alias{plot_avail_forecasts} -\title{Visualise Where Forecasts Are Available \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}}} -\usage{ -plot_avail_forecasts( - available_forecasts, - y = "model", - x = "forecast_date", - make_x_factor = TRUE, - show_numbers = TRUE -) -} -\arguments{ -\item{available_forecasts}{an S3 object of class "scoringutils_available_forecasts" -as produced by \code{\link[=available_forecasts]{available_forecasts()}}} - -\item{y}{character vector of length one that denotes the name of the column -to appear on the y-axis of the plot. Default is "model".} - -\item{x}{character vector of length one that denotes the name of the column -to appear on the x-axis of the plot. Default is "forecast_date".} - -\item{make_x_factor}{logical (default is TRUE). Whether or not to convert -the variable on the x-axis to a factor. This has an effect e.g. if dates -are shown on the x-axis.} - -\item{show_numbers}{logical (default is \code{TRUE}) that indicates whether -or not to show the actual count numbers on the plot} -} -\description{ -Old version of \code{\link[=plot.scoringutils_available_forecasts]{plot.scoringutils_available_forecasts()}} for compatibility. -} diff --git a/man/plot_forecast_counts.Rd b/man/plot_forecast_counts.Rd new file mode 100644 index 000000000..c5285c9dd --- /dev/null +++ b/man/plot_forecast_counts.Rd @@ -0,0 +1,47 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/plot.R +\name{plot_forecast_counts} +\alias{plot_forecast_counts} +\title{Visualise Where Forecasts Are Available} +\usage{ +plot_forecast_counts( + forecast_counts, + x, + y = "model", + x_as_factor = TRUE, + show_counts = TRUE +) +} +\arguments{ +\item{forecast_counts}{a data.table (or similar) with a column \code{count} +holding forecast counts, as produced by \code{\link[=get_forecast_counts]{get_forecast_counts()}}} + +\item{x}{character vector of length one that denotes the name of the column +to appear on the x-axis of the plot.} + +\item{y}{character vector of length one that denotes the name of the column +to appear on the y-axis of the plot. Default is "model".} + +\item{x_as_factor}{logical (default is TRUE). Whether or not to convert +the variable on the x-axis to a factor. This has an effect e.g. if dates +are shown on the x-axis.} + +\item{show_counts}{logical (default is \code{TRUE}) that indicates whether +or not to show the actual count numbers on the plot} +} +\value{ +ggplot object with a plot of interval coverage +} +\description{ +Visualise Where Forecasts Are Available +} +\examples{ +library(ggplot2) +forecast_counts <- get_forecast_counts( + example_quantile, by = c("model", "target_type", "target_end_date") +) +plot_forecast_counts( + forecast_counts, x = "target_end_date", show_counts = FALSE +) + + facet_wrap("target_type") +} diff --git a/tests/testthat/test-available_forecasts.R b/tests/testthat/test-available_forecasts.R index f8e0ad0c7..ffa9e4f9e 100644 --- a/tests/testthat/test-available_forecasts.R +++ b/tests/testthat/test-available_forecasts.R @@ -1,6 +1,6 @@ -test_that("available_forecasts() works as expected", { +test_that("get_forecast_counts() works as expected", { af <- suppressMessages( - available_forecasts(example_quantile, + get_forecast_counts(example_quantile, by = c("model", "target_type", "target_end_date") ) ) @@ -8,12 +8,12 @@ test_that("available_forecasts() works as expected", { expect_type(af$target_type, "character") expect_type(af$`count`, "integer") expect_equal(nrow(af[is.na(`count`)]), 0) - af <- available_forecasts(example_quantile, by = "model") + af <- get_forecast_counts(example_quantile, by = "model") expect_equal(nrow(af), 4) expect_equal(af$`count`, c(256, 256, 128, 247)) # Setting `collapse = c()` means that all quantiles and samples are counted - af <- available_forecasts( + af <- get_forecast_counts( example_quantile, by = "model", collapse = c() ) @@ -21,13 +21,13 @@ test_that("available_forecasts() works as expected", { expect_equal(af$`count`, c(5888, 5888, 2944, 5681)) # setting by = NULL, the default, results in by equal to forecast unit - af <- available_forecasts(example_quantile) + af <- get_forecast_counts(example_quantile) expect_equal(nrow(af), 50688) # check whether collapsing also works for model-based forecasts - af <- available_forecasts(example_integer, by = "model") + af <- get_forecast_counts(example_integer, by = "model") expect_equal(nrow(af), 4) - af <- available_forecasts(example_integer, by = "model", collapse = c()) + af <- get_forecast_counts(example_integer, by = "model", collapse = c()) expect_equal(af$count, c(10240, 10240, 5120, 9880)) }) diff --git a/tests/testthat/test-plot_avail_forecasts.R b/tests/testthat/test-plot_avail_forecasts.R index 9f2efea6b..f131a6d7a 100644 --- a/tests/testthat/test-plot_avail_forecasts.R +++ b/tests/testthat/test-plot_avail_forecasts.R @@ -1,11 +1,10 @@ -test_that("plot_available_forecasts() works as expected", { - available_forecasts <- suppressMessages( - available_forecasts(example_quantile, - by = c("model", "target_type", "target_end_date") - ) +test_that("plot.forecast_counts() works as expected", { + available_forecasts <- get_forecast_counts( + example_quantile, + by = c("model", "target_type", "target_end_date") ) - p <- plot(available_forecasts, - xvar = "target_end_date", show_numbers = FALSE + p <- plot_forecast_counts(available_forecasts, + x = "target_end_date", show_counts = FALSE ) + facet_wrap("target_type") expect_s3_class(p, "ggplot") diff --git a/vignettes/scoringutils.Rmd b/vignettes/scoringutils.Rmd index 4ae09b2ac..05ea4b365 100644 --- a/vignettes/scoringutils.Rmd +++ b/vignettes/scoringutils.Rmd @@ -35,7 +35,7 @@ Most of the time, the `score()` function will be able to do the entire evaluatio ```{r, echo=FALSE} requirements <- data.table( - "Format" = c( + Format = c( "quantile-based", "sample-based", "binary", "pairwise-comparisons" ), `Required columns` = c( @@ -79,10 +79,10 @@ The output of `validate()` can later be directly used as input to `score()` (oth ## Showing available forecasts -The function `available_forecasts()` may also be helpful to determine where forecasts are available. Using the `by` argument you can specify the level of summary. For example, to see how many forecasts there are per model and target_type, we can run +The function `get_forecast_counts()` may also be helpful to determine where forecasts are available. Using the `by` argument you can specify the level of summary. For example, to see how many forecasts there are per model and target_type, we can run ```{r} -available_forecasts(example_quantile, by = c("model", "target_type")) +get_forecast_counts(example_quantile, by = c("model", "target_type")) ``` We see that 'epiforecasts-EpiNow2' has some missing forecasts for the deaths forecast target and that UMass-MechBayes has no case forecasts. @@ -91,8 +91,8 @@ This information can also be visualised using `plot()`: ```{r, fig.width=11, fig.height=6} example_quantile %>% - available_forecasts(by = c("model", "forecast_date", "target_type")) %>% - plot() + + get_forecast_counts(by = c("model", "forecast_date", "target_type")) %>% + plot_forecast_counts(x = "forecast_date") + facet_wrap(~ target_type) ```