From 4154581b642e891628c36eb54eb82023d4bf1621 Mon Sep 17 00:00:00 2001 From: nikosbosse Date: Wed, 6 Sep 2023 11:40:47 +0200 Subject: [PATCH 1/4] Replace plot_correlation() by an S3 method for plot() --- NAMESPACE | 1 + NEWS.md | 16 +++++++--- R/correlations.R | 2 ++ R/plot.R | 31 +++++++++++++++---- .../R/00-standalone-Figure-replication.R | 2 +- inst/manuscript/manuscript.Rmd | 3 +- man/plot.scoringutils_correlation.Rd | 28 +++++++++++++++++ man/plot_correlation.Rd | 10 +++--- tests/testthat/test-plot_correlation.R | 4 +-- vignettes/scoringutils.Rmd | 2 +- 10 files changed, 77 insertions(+), 22 deletions(-) create mode 100644 man/plot.scoringutils_correlation.Rd diff --git a/NAMESPACE b/NAMESPACE index c4e3a3ad2..c68ab39a4 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,6 +1,7 @@ # Generated by roxygen2: do not edit by hand S3method(plot,scoringutils_available_forecasts) +S3method(plot,scoringutils_correlation) S3method(print,scoringutils_check) export(abs_error) export(add_coverage) diff --git a/NEWS.md b/NEWS.md index a3104d27d..d994fde70 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,11 +3,17 @@ This minor update addresses comments made by review from the Journal of Statistical Software (see preprint of the manuscript [here](https://arxiv.org/abs/2205.07090)). ## Package updates -- 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. + +### 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. + +### New S3 plotting methods +- `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. +- `plot_correlation()` has been deprecated in favour of an S3 method for `plot()`. An alias is still available, but will be removed in the future. + +### other - 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()`. diff --git a/R/correlations.R b/R/correlations.R index 5b8233576..00d02276a 100644 --- a/R/correlations.R +++ b/R/correlations.R @@ -49,6 +49,8 @@ correlation <- function(scores, keep.rownames = TRUE )[, metric := rn][, rn := NULL] + class(correlations) <- c("scoringutils_correlation", class(correlations)) + return(correlations[]) } diff --git a/R/plot.R b/R/plot.R index 52813d0f8..6527cbf65 100644 --- a/R/plot.R +++ b/R/plot.R @@ -1054,8 +1054,9 @@ plot_avail_forecasts <- function(available_forecasts, #' @description #' Plots a heatmap of correlations between different metrics #' -#' @param correlations A data.table of correlations between scores as produced -#' by [correlation()]. +#' @param x An S3 object with correlations between scores as produced by +#' [correlation()]. +#' @inheritParams print.scoringutils_check #' @return A ggplot2 object showing a coloured matrix of correlations #' between metrics #' @importFrom ggplot2 ggplot geom_tile geom_text aes scale_fill_gradient2 @@ -1067,13 +1068,13 @@ plot_avail_forecasts <- function(available_forecasts, #' correlations <- correlation( #' summarise_scores(scores) #' ) -#' plot_correlation(correlations) +#' plot(correlations) -plot_correlation <- function(correlations) { +plot.scoringutils_correlation <- function(x, ...) { - metrics <- names(correlations)[names(correlations) %in% available_metrics()] + metrics <- names(x)[names(x) %in% available_metrics()] - lower_triangle <- get_lower_tri(correlations[, .SD, .SDcols = metrics]) + lower_triangle <- get_lower_tri(x[, .SD, .SDcols = metrics]) rownames(lower_triangle) <- colnames(lower_triangle) # get plot data.frame @@ -1111,6 +1112,24 @@ plot_correlation <- function(correlations) { return(plot) } + +#' @title `r lifecycle::badge("deprecated")` Plot Correlation Between Metrics +#' +#' @description +#' Deprecated version of [plot.scoringutils_correlation()] for compatibility. +#' @inherit plot.scoringutils_correlation +#' @param correlations A data.table with correalations as produced by +#' [correlation()] +#' @export +plot_correlation <- function(correlations) { + lifecycle::deprecate_warn( + "1.2.2", "plot_correlation()", + "plot()" + ) + plot.scoringutils_correlation(x = correlations) +} + + #' @title Scoringutils ggplot2 theme #' #' @description diff --git a/inst/manuscript/R/00-standalone-Figure-replication.R b/inst/manuscript/R/00-standalone-Figure-replication.R index f6d801697..297b0c8b7 100644 --- a/inst/manuscript/R/00-standalone-Figure-replication.R +++ b/inst/manuscript/R/00-standalone-Figure-replication.R @@ -660,4 +660,4 @@ correlations |> glimpse() correlations |> - plot_correlation() + plot() diff --git a/inst/manuscript/manuscript.Rmd b/inst/manuscript/manuscript.Rmd index b0b14f728..97561113e 100644 --- a/inst/manuscript/manuscript.Rmd +++ b/inst/manuscript/manuscript.Rmd @@ -642,8 +642,7 @@ correlations <- example_quantile |> correlations |> glimpse() -correlations |> - plot_correlation() +plot(correlations) ``` ## Summary and discussion diff --git a/man/plot.scoringutils_correlation.Rd b/man/plot.scoringutils_correlation.Rd new file mode 100644 index 000000000..7e2c2480b --- /dev/null +++ b/man/plot.scoringutils_correlation.Rd @@ -0,0 +1,28 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/plot.R +\name{plot.scoringutils_correlation} +\alias{plot.scoringutils_correlation} +\title{Plot Correlation Between Metrics} +\usage{ +\method{plot}{scoringutils_correlation}(x, ...) +} +\arguments{ +\item{x}{An S3 object with correlations between scores as produced by +\code{\link[=correlation]{correlation()}}.} + +\item{...}{additional arguments (not used here)} +} +\value{ +A ggplot2 object showing a coloured matrix of correlations +between metrics +} +\description{ +Plots a heatmap of correlations between different metrics +} +\examples{ +scores <- score(example_quantile) +correlations <- correlation( + summarise_scores(scores) +) +plot(correlations) +} diff --git a/man/plot_correlation.Rd b/man/plot_correlation.Rd index 390c90f20..b44294571 100644 --- a/man/plot_correlation.Rd +++ b/man/plot_correlation.Rd @@ -2,25 +2,25 @@ % Please edit documentation in R/plot.R \name{plot_correlation} \alias{plot_correlation} -\title{Plot Correlation Between Metrics} +\title{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Plot Correlation Between Metrics} \usage{ plot_correlation(correlations) } \arguments{ -\item{correlations}{A data.table of correlations between scores as produced -by \code{\link[=correlation]{correlation()}}.} +\item{correlations}{A data.table with correalations as produced by +\code{\link[=correlation]{correlation()}}} } \value{ A ggplot2 object showing a coloured matrix of correlations between metrics } \description{ -Plots a heatmap of correlations between different metrics +Deprecated version of \code{\link[=plot.scoringutils_correlation]{plot.scoringutils_correlation()}} for compatibility. } \examples{ scores <- score(example_quantile) correlations <- correlation( summarise_scores(scores) ) -plot_correlation(correlations) +plot(correlations) } diff --git a/tests/testthat/test-plot_correlation.R b/tests/testthat/test-plot_correlation.R index 9d6280d6e..8a0e7e67b 100644 --- a/tests/testthat/test-plot_correlation.R +++ b/tests/testthat/test-plot_correlation.R @@ -1,6 +1,6 @@ -test_that("plot_correlation() works as expected", { +test_that("plot works as expected for correlation", { correlations <- correlation(summarise_scores(scores)) - p <- plot_correlation(correlations) + p <- plot(correlations) expect_s3_class(p, "ggplot") skip_on_cran() vdiffr::expect_doppelganger("plot__correlation", p) diff --git a/vignettes/scoringutils.Rmd b/vignettes/scoringutils.Rmd index b4dd0bf16..af5109438 100644 --- a/vignettes/scoringutils.Rmd +++ b/vignettes/scoringutils.Rmd @@ -376,7 +376,7 @@ example_quantile %>% score() %>% summarise_scores() %>% correlation() %>% - plot_correlation() + plot() ``` ### Scores by interval ranges From eb1de6ab2eb97f614ebc1be5c7c62fa36733e7c4 Mon Sep 17 00:00:00 2001 From: nikosbosse Date: Wed, 6 Sep 2023 12:16:36 +0200 Subject: [PATCH 2/4] Create plot S3 method for plot_pairwise_comparison --- NAMESPACE | 2 + NEWS.md | 1 + R/pairwise-comparisons.R | 4 +- R/plot.R | 49 ++++++++++++++++--- inst/manuscript/manuscript.Rmd | 2 +- man/pairwise_comparison.Rd | 2 +- ...ngutils_available_forecasts.Rd => plot.Rd} | 44 ++++++++++++++--- man/plot.scoringutils_correlation.Rd | 28 ----------- man/plot_correlation.Rd | 11 ----- man/plot_pairwise_comparison.Rd | 26 ++++++++-- .../testthat/test-plot_pairwise_comparison.R | 8 +-- vignettes/scoringutils.Rmd | 2 +- 12 files changed, 115 insertions(+), 64 deletions(-) rename man/{plot.scoringutils_available_forecasts.Rd => plot.Rd} (51%) delete mode 100644 man/plot.scoringutils_correlation.Rd diff --git a/NAMESPACE b/NAMESPACE index c68ab39a4..d2c28395a 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -2,6 +2,7 @@ S3method(plot,scoringutils_available_forecasts) S3method(plot,scoringutils_correlation) +S3method(plot,scoringutils_pairwise) S3method(print,scoringutils_check) export(abs_error) export(add_coverage) @@ -30,6 +31,7 @@ export(merge_pred_and_obs) export(pairwise_comparison) export(pit) export(pit_sample) +export(plot) export(plot_avail_forecasts) export(plot_correlation) export(plot_heatmap) diff --git a/NEWS.md b/NEWS.md index d994fde70..86956fdd5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -12,6 +12,7 @@ This minor update addresses comments made by review from the Journal of Statisti ### New S3 plotting methods - `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. - `plot_correlation()` has been deprecated in favour of an S3 method for `plot()`. An alias is still available, but will be removed in the future. +- `plot_pairwise_comparison()` has been deprecated in favour of an S3 method for `plot()`. An alias is still available, but will be removed in the future. ### other - the deprecated `..density..` was replaced with `after_stat(density)` in ggplot calls. diff --git a/R/pairwise-comparisons.R b/R/pairwise-comparisons.R index efce335eb..ced85e05d 100644 --- a/R/pairwise-comparisons.R +++ b/R/pairwise-comparisons.R @@ -58,7 +58,7 @@ #' pairwise <- pairwise_comparison(scores, by = "target_type") #' #' library(ggplot2) -#' plot_pairwise_comparison(pairwise, type = "mean_scores_ratio") + +#' plot(pairwise, type = "mean_scores_ratio") + #' facet_wrap(~target_type) pairwise_comparison <- function(scores, @@ -139,6 +139,8 @@ pairwise_comparison <- function(scores, out <- data.table::rbindlist(results) + class(out) <- c("scoringutils_pairwise", class(out)) + return(out[]) } diff --git a/R/plot.R b/R/plot.R index 6527cbf65..28b31b47d 100644 --- a/R/plot.R +++ b/R/plot.R @@ -1,3 +1,13 @@ +#' @title Various Plotting Methods for Outputs of scoringutils Functions +#' @param x S3 object to be plotted, as produced by various scoringutils +#' functions. +#' @param ... other arguments +#' @export +plot <- function(x, ...) { + UseMethod("plot") +} + + #' @title Plot Coloured Score Table #' #' @description @@ -687,18 +697,20 @@ plot_quantile_coverage <- function(scores, return(p2) } +#' @rdname plot #' @title Plot Heatmap of Pairwise Comparisons #' #' @description #' Creates a heatmap of the ratios or pvalues from a pairwise comparison #' between models #' -#' @param comparison_result A data.frame as produced by +#' @param x An S3 object as produced by #' [pairwise_comparison()] #' @param type character vector of length one that is either #' "mean_scores_ratio" or "pval". This denotes whether to #' visualise the ratio or the p-value of the pairwise comparison. #' Default is "mean_scores_ratio". +#' @inheritParams print.scoringutils_check #' @importFrom ggplot2 ggplot aes geom_tile geom_text labs coord_cartesian #' scale_fill_gradient2 theme_light element_text #' @importFrom data.table as.data.table setnames rbindlist @@ -710,12 +722,13 @@ plot_quantile_coverage <- function(scores, #' library(ggplot2) #' scores <- score(example_quantile) #' pairwise <- pairwise_comparison(scores, by = "target_type") -#' plot_pairwise_comparison(pairwise, type = "mean_scores_ratio") + +#' plot(pairwise, type = "mean_scores_ratio") + #' facet_wrap(~target_type) -plot_pairwise_comparison <- function(comparison_result, - type = c("mean_scores_ratio", "pval")) { - comparison_result <- data.table::as.data.table(comparison_result) +plot.scoringutils_pairwise <- function(x, + type = c("mean_scores_ratio", "pval"), + ...) { + comparison_result <- data.table::as.data.table(x) comparison_result[, model := reorder(model, -relative_skill)] levels <- levels(comparison_result$model) @@ -810,6 +823,28 @@ plot_pairwise_comparison <- function(comparison_result, } +#' @title `r lifecycle::badge("deprecated")` Plot Heatmap of Pairwise Comparisons +#' +#' @description +#' Deprecated version of [plot.scoringutils_pairwise()] +#' +#' @param comparison_result A data.frame as produced by +#' [pairwise_comparison()] +#' @inherit plot.scoringutils_pairwise +#' @export +plot_pairwise_comparison <- function(comparison_result, + type = c("mean_scores_ratio", "pval")) { + + lifecycle::deprecate_warn( + "1.2.2", "plot_pairwise_comparison()", + "plot()" + ) + + plot.scoringutils_pairwise(x = comparison_result, + type = type) +} + + #' @title PIT Histogram #' #' @description @@ -937,6 +972,7 @@ plot_pit <- function(pit, return(hist) } +#' @rdname plot #' @title Visualise Where Forecasts Are Available #' #' @description @@ -1048,7 +1084,7 @@ plot_avail_forecasts <- function(available_forecasts, - +#' @rdname plot #' @title Plot Correlation Between Metrics #' #' @description @@ -1117,7 +1153,6 @@ plot.scoringutils_correlation <- function(x, ...) { #' #' @description #' Deprecated version of [plot.scoringutils_correlation()] for compatibility. -#' @inherit plot.scoringutils_correlation #' @param correlations A data.table with correalations as produced by #' [correlation()] #' @export diff --git a/inst/manuscript/manuscript.Rmd b/inst/manuscript/manuscript.Rmd index 97561113e..c87026c91 100644 --- a/inst/manuscript/manuscript.Rmd +++ b/inst/manuscript/manuscript.Rmd @@ -527,7 +527,7 @@ Using the function \fct{plot\_pairwise\_comparison} we can visualise the mean sc score(example_quantile) |> pairwise_comparison(by = c("model", "target_type"), baseline = "EuroCOVIDhub-baseline") |> - plot_pairwise_comparison() + + plot() + facet_wrap(~ target_type) ``` diff --git a/man/pairwise_comparison.Rd b/man/pairwise_comparison.Rd index 4c14b975e..c796747b8 100644 --- a/man/pairwise_comparison.Rd +++ b/man/pairwise_comparison.Rd @@ -70,7 +70,7 @@ scores <- score(example_quantile) pairwise <- pairwise_comparison(scores, by = "target_type") library(ggplot2) -plot_pairwise_comparison(pairwise, type = "mean_scores_ratio") + +plot(pairwise, type = "mean_scores_ratio") + facet_wrap(~target_type) } \author{ diff --git a/man/plot.scoringutils_available_forecasts.Rd b/man/plot.Rd similarity index 51% rename from man/plot.scoringutils_available_forecasts.Rd rename to man/plot.Rd index f11e0dc5d..2e71e297e 100644 --- a/man/plot.scoringutils_available_forecasts.Rd +++ b/man/plot.Rd @@ -1,9 +1,16 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/plot.R -\name{plot.scoringutils_available_forecasts} +\name{plot} +\alias{plot} +\alias{plot.scoringutils_pairwise} \alias{plot.scoringutils_available_forecasts} -\title{Visualise Where Forecasts Are Available} +\alias{plot.scoringutils_correlation} +\title{Various Plotting Methods for Outputs of scoringutils Functions} \usage{ +plot(x, ...) + +\method{plot}{scoringutils_pairwise}(x, type = c("mean_scores_ratio", "pval"), ...) + \method{plot}{scoringutils_available_forecasts}( x, yvar = "model", @@ -12,10 +19,19 @@ show_numbers = TRUE, ... ) + +\method{plot}{scoringutils_correlation}(x, ...) } \arguments{ -\item{x}{an S3 object of class "scoringutils_available_forecasts" -as produced by \code{\link[=available_forecasts]{available_forecasts()}}} +\item{x}{An S3 object with correlations between scores as produced by +\code{\link[=correlation]{correlation()}}.} + +\item{...}{other arguments} + +\item{type}{character vector of length one that is either +"mean_scores_ratio" or "pval". This denotes whether to +visualise the ratio or the p-value of the pairwise comparison. +Default is "mean_scores_ratio".} \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".} @@ -29,17 +45,28 @@ 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 + +A ggplot2 object showing a coloured matrix of correlations +between metrics } \description{ +Creates a heatmap of the ratios or pvalues from a pairwise comparison +between models + Visualise Where Forecasts Are Available + +Plots a heatmap of correlations between different metrics } \examples{ library(ggplot2) +scores <- score(example_quantile) +pairwise <- pairwise_comparison(scores, by = "target_type") +plot(pairwise, type = "mean_scores_ratio") + + facet_wrap(~target_type) +library(ggplot2) available_forecasts <- available_forecasts( example_quantile, by = c("model", "target_type", "target_end_date") ) @@ -47,4 +74,9 @@ plot( available_forecasts, xvar = "target_end_date", show_numbers = FALSE ) + facet_wrap("target_type") +scores <- score(example_quantile) +correlations <- correlation( + summarise_scores(scores) +) +plot(correlations) } diff --git a/man/plot.scoringutils_correlation.Rd b/man/plot.scoringutils_correlation.Rd deleted file mode 100644 index 7e2c2480b..000000000 --- a/man/plot.scoringutils_correlation.Rd +++ /dev/null @@ -1,28 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/plot.R -\name{plot.scoringutils_correlation} -\alias{plot.scoringutils_correlation} -\title{Plot Correlation Between Metrics} -\usage{ -\method{plot}{scoringutils_correlation}(x, ...) -} -\arguments{ -\item{x}{An S3 object with correlations between scores as produced by -\code{\link[=correlation]{correlation()}}.} - -\item{...}{additional arguments (not used here)} -} -\value{ -A ggplot2 object showing a coloured matrix of correlations -between metrics -} -\description{ -Plots a heatmap of correlations between different metrics -} -\examples{ -scores <- score(example_quantile) -correlations <- correlation( - summarise_scores(scores) -) -plot(correlations) -} diff --git a/man/plot_correlation.Rd b/man/plot_correlation.Rd index b44294571..4fd75faf2 100644 --- a/man/plot_correlation.Rd +++ b/man/plot_correlation.Rd @@ -10,17 +10,6 @@ plot_correlation(correlations) \item{correlations}{A data.table with correalations as produced by \code{\link[=correlation]{correlation()}}} } -\value{ -A ggplot2 object showing a coloured matrix of correlations -between metrics -} \description{ Deprecated version of \code{\link[=plot.scoringutils_correlation]{plot.scoringutils_correlation()}} for compatibility. } -\examples{ -scores <- score(example_quantile) -correlations <- correlation( - summarise_scores(scores) -) -plot(correlations) -} diff --git a/man/plot_pairwise_comparison.Rd b/man/plot_pairwise_comparison.Rd index 71b5e77e8..d15e891e3 100644 --- a/man/plot_pairwise_comparison.Rd +++ b/man/plot_pairwise_comparison.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/plot.R \name{plot_pairwise_comparison} \alias{plot_pairwise_comparison} -\title{Plot Heatmap of Pairwise Comparisons} +\title{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} Plot Heatmap of Pairwise Comparisons} \usage{ plot_pairwise_comparison( comparison_result, @@ -18,14 +18,32 @@ plot_pairwise_comparison( visualise the ratio or the p-value of the pairwise comparison. Default is "mean_scores_ratio".} } +\value{ +ggplot object with a plot of interval coverage + +A ggplot2 object showing a coloured matrix of correlations +between metrics +} \description{ -Creates a heatmap of the ratios or pvalues from a pairwise comparison -between models +Deprecated version of \code{\link[=plot.scoringutils_pairwise]{plot.scoringutils_pairwise()}} } \examples{ library(ggplot2) scores <- score(example_quantile) pairwise <- pairwise_comparison(scores, by = "target_type") -plot_pairwise_comparison(pairwise, type = "mean_scores_ratio") + +plot(pairwise, type = "mean_scores_ratio") + facet_wrap(~target_type) +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") +scores <- score(example_quantile) +correlations <- correlation( + summarise_scores(scores) +) +plot(correlations) } diff --git a/tests/testthat/test-plot_pairwise_comparison.R b/tests/testthat/test-plot_pairwise_comparison.R index 4cd477e90..c4839a264 100644 --- a/tests/testthat/test-plot_pairwise_comparison.R +++ b/tests/testthat/test-plot_pairwise_comparison.R @@ -2,16 +2,16 @@ pairwise <- suppressMessages( pairwise_comparison(scores, by = "target_type") ) -test_that("plot_pairwise_comparison() works as expected", { - p <- plot_pairwise_comparison(pairwise) + +test_that("plot() for pairwise comparisons works as expected", { + p <- plot(pairwise) + ggplot2::facet_wrap(~target_type) expect_s3_class(p, "ggplot") skip_on_cran() vdiffr::expect_doppelganger("plot_pairwise_comparison", p) }) -test_that("plot_pairwise_comparison() works when showing p values", { - p <- plot_pairwise_comparison(pairwise, type = "pval") + +test_that("plot() for pairwise comparisons works when showing p values", { + p <- plot(pairwise, type = "pval") + ggplot2::facet_wrap(~target_type) expect_s3_class(p, "ggplot") skip_on_cran() diff --git a/vignettes/scoringutils.Rmd b/vignettes/scoringutils.Rmd index af5109438..80c2d1321 100644 --- a/vignettes/scoringutils.Rmd +++ b/vignettes/scoringutils.Rmd @@ -351,7 +351,7 @@ If using the `pairwise_comparison()` function, we can also visualise pairwise co example_quantile %>% score() %>% pairwise_comparison(by = c("model", "target_type")) %>% - plot_pairwise_comparison() + + plot() + facet_wrap(~ target_type) ``` From 9f256dd25db51a15e626988b3007c75d9466009d Mon Sep 17 00:00:00 2001 From: nikosbosse Date: Wed, 6 Sep 2023 14:33:33 +0200 Subject: [PATCH 3/4] update documentation --- NAMESPACE | 1 - R/avail_forecasts.R | 5 ++- R/correlations.R | 11 +++-- R/pairwise-comparisons.R | 5 ++- R/plot.R | 19 ++------ man/available_forecasts.Rd | 7 ++- man/correlation.Rd | 12 +++-- man/pairwise_comparison.Rd | 7 ++- ... plot.scoringutils_available_forecasts.Rd} | 44 +++---------------- man/plot.scoringutils_correlation.Rd | 28 ++++++++++++ man/plot.scoringutils_pairwise.Rd | 34 ++++++++++++++ man/plot_pairwise_comparison.Rd | 19 +------- 12 files changed, 111 insertions(+), 81 deletions(-) rename man/{plot.Rd => plot.scoringutils_available_forecasts.Rd} (51%) create mode 100644 man/plot.scoringutils_correlation.Rd create mode 100644 man/plot.scoringutils_pairwise.Rd diff --git a/NAMESPACE b/NAMESPACE index d2c28395a..02ff443b3 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -31,7 +31,6 @@ export(merge_pred_and_obs) export(pairwise_comparison) export(pit) export(pit_sample) -export(plot) export(plot_avail_forecasts) export(plot_correlation) export(plot_heatmap) diff --git a/R/avail_forecasts.R b/R/avail_forecasts.R index cef7f8605..cc318bf81 100644 --- a/R/avail_forecasts.R +++ b/R/avail_forecasts.R @@ -20,11 +20,14 @@ #' that a single forecast only gets counted once. #' #' @return A data.table with columns as specified in `by` and an additional -#' column "count" with the number of forecasts. +#' column "count" with the number of forecasts. In addition the output has class +#' `scoringutils_available_forecasts` and can e.g. be visualised +#' using [plot()] (which dispatches [plot.scoringutils_available_forecasts()]. #' #' @inheritParams score #' @importFrom data.table .I .N nafill #' @export +#' @seealso [plot.scoringutils_available_forecasts()] #' @keywords check-forecasts #' @examples #' data.table::setDTthreads(1) # only needed to avoid issues on CRAN diff --git a/R/correlations.R b/R/correlations.R index 00d02276a..580176e82 100644 --- a/R/correlations.R +++ b/R/correlations.R @@ -2,20 +2,25 @@ #' #' @description #' Calculate the correlation between different metrics for a data.frame of -#' scores as produced by [score()]. +#' scores as produced by [score()]. You can visualise results #' #' @param metrics A character vector with the metrics to show. If set to #' `NULL` (default), all metrics present in `scores` will #' be shown #' @inheritParams pairwise_comparison -#' @return A data.table with correlations for the different metrics +#' @return A data.table with correlations for the different metrics. In addition, +#' the output is of class `scoringutils_correlation` and can e.g. be visualised +#' using [plot()] (which dispatches [plot.scoringutils_correlation()]. +#' #' @importFrom data.table setDT #' @importFrom stats cor na.omit #' @export #' @keywords scoring +#' @seealso [plot.scoringutils_correlation()] #' @examples #' scores <- score(example_quantile) -#' correlation(scores) +#' corrs <- correlation(scores) +#' plot(corrs) correlation <- function(scores, metrics = NULL) { metrics <- check_metrics(metrics) diff --git a/R/pairwise-comparisons.R b/R/pairwise-comparisons.R index ced85e05d..ec94bcaba 100644 --- a/R/pairwise-comparisons.R +++ b/R/pairwise-comparisons.R @@ -43,7 +43,9 @@ #' model against which to compare other models. #' @param ... additional arguments for the comparison between two models. See #' [compare_two_models()] for more information. -#' @return A ggplot2 object with a coloured table of summarised scores +#' @return A data.table with pairwise comparisons. In addition, the output is +#' of class `scoringutils_pairwise` and can be visualised using [plot()] (which +#' dispatches [plot.scoringutils_pairwise()]. #' @importFrom data.table as.data.table data.table setnames copy #' @importFrom stats sd rbinom wilcox.test p.adjust #' @importFrom utils combn @@ -51,6 +53,7 @@ #' @author Nikos Bosse \email{nikosbosse@@gmail.com} #' @author Johannes Bracher, \email{johannes.bracher@@kit.edu} #' @keywords scoring +#' @seealso [plot.scoringutils_pairwise()] #' @examples #' data.table::setDTthreads(1) # only needed to avoid issues on CRAN #' diff --git a/R/plot.R b/R/plot.R index 28b31b47d..15079b195 100644 --- a/R/plot.R +++ b/R/plot.R @@ -1,13 +1,3 @@ -#' @title Various Plotting Methods for Outputs of scoringutils Functions -#' @param x S3 object to be plotted, as produced by various scoringutils -#' functions. -#' @param ... other arguments -#' @export -plot <- function(x, ...) { - UseMethod("plot") -} - - #' @title Plot Coloured Score Table #' #' @description @@ -697,7 +687,7 @@ plot_quantile_coverage <- function(scores, return(p2) } -#' @rdname plot + #' @title Plot Heatmap of Pairwise Comparisons #' #' @description @@ -711,6 +701,8 @@ plot_quantile_coverage <- function(scores, #' visualise the ratio or the p-value of the pairwise comparison. #' Default is "mean_scores_ratio". #' @inheritParams print.scoringutils_check +#' @return A data.table with pairwise comparisons. In addition, the output is +#' of class `scoringutils_pairwise` and can be visualised using [plot()]. #' @importFrom ggplot2 ggplot aes geom_tile geom_text labs coord_cartesian #' scale_fill_gradient2 theme_light element_text #' @importFrom data.table as.data.table setnames rbindlist @@ -972,7 +964,7 @@ plot_pit <- function(pit, return(hist) } -#' @rdname plot + #' @title Visualise Where Forecasts Are Available #' #' @description @@ -1083,10 +1075,7 @@ plot_avail_forecasts <- function(available_forecasts, } - -#' @rdname plot #' @title Plot Correlation Between Metrics -#' #' @description #' Plots a heatmap of correlations between different metrics #' diff --git a/man/available_forecasts.Rd b/man/available_forecasts.Rd index d851db41a..1c824b0ca 100644 --- a/man/available_forecasts.Rd +++ b/man/available_forecasts.Rd @@ -51,7 +51,9 @@ that a single forecast only gets counted once.} } \value{ A data.table with columns as specified in \code{by} and an additional -column "count" with the number of forecasts. +column "count" with the number of forecasts. In addition the output has class +\code{scoringutils_available_forecasts} and can e.g. be visualised +using \code{\link[=plot]{plot()}} (which dispatches \code{\link[=plot.scoringutils_available_forecasts]{plot.scoringutils_available_forecasts()}}. } \description{ Given a data set with forecasts, count the number of available forecasts @@ -67,4 +69,7 @@ available_forecasts(example_quantile, by = c("model", "target_type") ) } +\seealso{ +\code{\link[=plot.scoringutils_available_forecasts]{plot.scoringutils_available_forecasts()}} +} \keyword{check-forecasts} diff --git a/man/correlation.Rd b/man/correlation.Rd index 77de3a469..4e93d34bb 100644 --- a/man/correlation.Rd +++ b/man/correlation.Rd @@ -14,14 +14,20 @@ correlation(scores, metrics = NULL) be shown} } \value{ -A data.table with correlations for the different metrics +A data.table with correlations for the different metrics. In addition, +the output is of class \code{scoringutils_correlation} and can e.g. be visualised +using \code{\link[=plot]{plot()}} (which dispatches \code{\link[=plot.scoringutils_correlation]{plot.scoringutils_correlation()}}. } \description{ Calculate the correlation between different metrics for a data.frame of -scores as produced by \code{\link[=score]{score()}}. +scores as produced by \code{\link[=score]{score()}}. You can visualise results } \examples{ scores <- score(example_quantile) -correlation(scores) +corrs <- correlation(scores) +plot(corrs) +} +\seealso{ +\code{\link[=plot.scoringutils_correlation]{plot.scoringutils_correlation()}} } \keyword{scoring} diff --git a/man/pairwise_comparison.Rd b/man/pairwise_comparison.Rd index c796747b8..d94ec6e2e 100644 --- a/man/pairwise_comparison.Rd +++ b/man/pairwise_comparison.Rd @@ -36,7 +36,9 @@ model against which to compare other models.} \code{\link[=compare_two_models]{compare_two_models()}} for more information.} } \value{ -A ggplot2 object with a coloured table of summarised scores +A data.table with pairwise comparisons. In addition, the output is +of class \code{scoringutils_pairwise} and can be visualised using \code{\link[=plot]{plot()}} (which +dispatches \code{\link[=plot.scoringutils_pairwise]{plot.scoringutils_pairwise()}}. } \description{ Compute relative scores between different models making pairwise @@ -73,6 +75,9 @@ library(ggplot2) plot(pairwise, type = "mean_scores_ratio") + facet_wrap(~target_type) } +\seealso{ +\code{\link[=plot.scoringutils_pairwise]{plot.scoringutils_pairwise()}} +} \author{ Nikos Bosse \email{nikosbosse@gmail.com} diff --git a/man/plot.Rd b/man/plot.scoringutils_available_forecasts.Rd similarity index 51% rename from man/plot.Rd rename to man/plot.scoringutils_available_forecasts.Rd index 2e71e297e..f11e0dc5d 100644 --- a/man/plot.Rd +++ b/man/plot.scoringutils_available_forecasts.Rd @@ -1,16 +1,9 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/plot.R -\name{plot} -\alias{plot} -\alias{plot.scoringutils_pairwise} +\name{plot.scoringutils_available_forecasts} \alias{plot.scoringutils_available_forecasts} -\alias{plot.scoringutils_correlation} -\title{Various Plotting Methods for Outputs of scoringutils Functions} +\title{Visualise Where Forecasts Are Available} \usage{ -plot(x, ...) - -\method{plot}{scoringutils_pairwise}(x, type = c("mean_scores_ratio", "pval"), ...) - \method{plot}{scoringutils_available_forecasts}( x, yvar = "model", @@ -19,19 +12,10 @@ plot(x, ...) show_numbers = TRUE, ... ) - -\method{plot}{scoringutils_correlation}(x, ...) } \arguments{ -\item{x}{An S3 object with correlations between scores as produced by -\code{\link[=correlation]{correlation()}}.} - -\item{...}{other arguments} - -\item{type}{character vector of length one that is either -"mean_scores_ratio" or "pval". This denotes whether to -visualise the ratio or the p-value of the pairwise comparison. -Default is "mean_scores_ratio".} +\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".} @@ -45,28 +29,17 @@ 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 - -A ggplot2 object showing a coloured matrix of correlations -between metrics } \description{ -Creates a heatmap of the ratios or pvalues from a pairwise comparison -between models - Visualise Where Forecasts Are Available - -Plots a heatmap of correlations between different metrics } \examples{ library(ggplot2) -scores <- score(example_quantile) -pairwise <- pairwise_comparison(scores, by = "target_type") -plot(pairwise, type = "mean_scores_ratio") + - facet_wrap(~target_type) -library(ggplot2) available_forecasts <- available_forecasts( example_quantile, by = c("model", "target_type", "target_end_date") ) @@ -74,9 +47,4 @@ plot( available_forecasts, xvar = "target_end_date", show_numbers = FALSE ) + facet_wrap("target_type") -scores <- score(example_quantile) -correlations <- correlation( - summarise_scores(scores) -) -plot(correlations) } diff --git a/man/plot.scoringutils_correlation.Rd b/man/plot.scoringutils_correlation.Rd new file mode 100644 index 000000000..7e2c2480b --- /dev/null +++ b/man/plot.scoringutils_correlation.Rd @@ -0,0 +1,28 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/plot.R +\name{plot.scoringutils_correlation} +\alias{plot.scoringutils_correlation} +\title{Plot Correlation Between Metrics} +\usage{ +\method{plot}{scoringutils_correlation}(x, ...) +} +\arguments{ +\item{x}{An S3 object with correlations between scores as produced by +\code{\link[=correlation]{correlation()}}.} + +\item{...}{additional arguments (not used here)} +} +\value{ +A ggplot2 object showing a coloured matrix of correlations +between metrics +} +\description{ +Plots a heatmap of correlations between different metrics +} +\examples{ +scores <- score(example_quantile) +correlations <- correlation( + summarise_scores(scores) +) +plot(correlations) +} diff --git a/man/plot.scoringutils_pairwise.Rd b/man/plot.scoringutils_pairwise.Rd new file mode 100644 index 000000000..9b8090ed4 --- /dev/null +++ b/man/plot.scoringutils_pairwise.Rd @@ -0,0 +1,34 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/plot.R +\name{plot.scoringutils_pairwise} +\alias{plot.scoringutils_pairwise} +\title{Plot Heatmap of Pairwise Comparisons} +\usage{ +\method{plot}{scoringutils_pairwise}(x, type = c("mean_scores_ratio", "pval"), ...) +} +\arguments{ +\item{x}{An S3 object as produced by +\code{\link[=pairwise_comparison]{pairwise_comparison()}}} + +\item{type}{character vector of length one that is either +"mean_scores_ratio" or "pval". This denotes whether to +visualise the ratio or the p-value of the pairwise comparison. +Default is "mean_scores_ratio".} + +\item{...}{additional arguments (not used here)} +} +\value{ +A data.table with pairwise comparisons. In addition, the output is +of class \code{scoringutils_pairwise} and can be visualised using \code{\link[=plot]{plot()}}. +} +\description{ +Creates a heatmap of the ratios or pvalues from a pairwise comparison +between models +} +\examples{ +library(ggplot2) +scores <- score(example_quantile) +pairwise <- pairwise_comparison(scores, by = "target_type") +plot(pairwise, type = "mean_scores_ratio") + + facet_wrap(~target_type) +} diff --git a/man/plot_pairwise_comparison.Rd b/man/plot_pairwise_comparison.Rd index d15e891e3..a5e7bccab 100644 --- a/man/plot_pairwise_comparison.Rd +++ b/man/plot_pairwise_comparison.Rd @@ -19,10 +19,8 @@ visualise the ratio or the p-value of the pairwise comparison. Default is "mean_scores_ratio".} } \value{ -ggplot object with a plot of interval coverage - -A ggplot2 object showing a coloured matrix of correlations -between metrics +A data.table with pairwise comparisons. In addition, the output is +of class \code{scoringutils_pairwise} and can be visualised using \code{\link[=plot]{plot()}}. } \description{ Deprecated version of \code{\link[=plot.scoringutils_pairwise]{plot.scoringutils_pairwise()}} @@ -33,17 +31,4 @@ scores <- score(example_quantile) pairwise <- pairwise_comparison(scores, by = "target_type") plot(pairwise, type = "mean_scores_ratio") + facet_wrap(~target_type) -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") -scores <- score(example_quantile) -correlations <- correlation( - summarise_scores(scores) -) -plot(correlations) } From 8d65a8324f10c07a6f86e1c397c0f9b617722adb Mon Sep 17 00:00:00 2001 From: nikosbosse Date: Wed, 6 Sep 2023 14:50:27 +0200 Subject: [PATCH 4/4] add family tag to plotting functions --- R/plot.R | 11 +++++++++++ man/plot.scoringutils_available_forecasts.Rd | 14 ++++++++++++++ man/plot.scoringutils_correlation.Rd | 14 ++++++++++++++ man/plot.scoringutils_pairwise.Rd | 14 ++++++++++++++ man/plot_heatmap.Rd | 14 ++++++++++++++ man/plot_interval_coverage.Rd | 14 ++++++++++++++ man/plot_pairwise_comparison.Rd | 13 +++++++++++++ man/plot_pit.Rd | 14 ++++++++++++++ man/plot_predictions.Rd | 14 ++++++++++++++ man/plot_quantile_coverage.Rd | 14 ++++++++++++++ man/plot_ranges.Rd | 14 ++++++++++++++ man/plot_score_table.Rd | 14 ++++++++++++++ man/plot_wis.Rd | 14 ++++++++++++++ 13 files changed, 178 insertions(+) diff --git a/R/plot.R b/R/plot.R index 15079b195..cef3f3452 100644 --- a/R/plot.R +++ b/R/plot.R @@ -19,6 +19,7 @@ #' @importFrom ggplot2 ggplot aes element_blank element_text labs coord_cartesian coord_flip #' @importFrom data.table setDT melt #' @importFrom stats sd +#' @family plotting functions #' @export #' #' @examples @@ -148,6 +149,7 @@ plot_score_table <- function(scores, #' scale_fill_discrete #' theme theme_light unit guides guide_legend .data #' @export +#' @family plotting functions #' @examples #' library(ggplot2) #' scores <- score(example_quantile) @@ -233,6 +235,7 @@ plot_wis <- function(scores, #' @importFrom ggplot2 ggplot aes aes geom_point geom_line #' expand_limits theme theme_light element_text scale_color_continuous labs #' @export +#' @family plotting functions #' @examples #' library(ggplot2) #' scores <- score(example_quantile) @@ -296,6 +299,7 @@ plot_ranges <- function(scores, #' @importFrom ggplot2 ggplot aes geom_tile geom_text .data #' scale_fill_gradient2 labs element_text coord_cartesian #' @export +#' @family plotting functions #' @examples #' scores <- score(example_quantile) #' scores <- summarise_scores(scores, by = c("model", "target_type", "range")) @@ -352,6 +356,7 @@ plot_heatmap <- function(scores, #' @importFrom data.table dcast #' @importFrom ggdist geom_lineribbon #' @export +#' @family plotting functions #' @examples #' library(ggplot2) #' library(magrittr) @@ -581,6 +586,7 @@ make_na <- make_NA #' facet_wrap facet_grid geom_polygon #' @importFrom data.table dcast #' @export +#' @family plotting functions #' @examples #' data.table::setDTthreads(1) # only needed to avoid issues on CRAN #' scores <- score(example_quantile) @@ -637,6 +643,7 @@ plot_interval_coverage <- function(scores, #' scale_y_continuous #' @importFrom data.table dcast #' @export +#' @family plotting functions #' @examples #' scores <- score(example_quantile) #' scores <- summarise_scores(scores, by = c("model", "quantile")) @@ -710,6 +717,7 @@ plot_quantile_coverage <- function(scores, #' @importFrom ggplot2 labs coord_cartesian facet_wrap facet_grid theme #' element_text element_blank #' @export +#' @family plotting functions #' @examples #' library(ggplot2) #' scores <- score(example_quantile) @@ -860,6 +868,7 @@ plot_pairwise_comparison <- function(comparison_result, #' @importFrom stats as.formula #' @importFrom ggplot2 geom_col #' @importFrom stats density +#' @family plotting functions #' @return vector with the scoring values #' @examples #' data.table::setDTthreads(1) # only needed to avoid issues on CRAN @@ -986,6 +995,7 @@ plot_pit <- function(pit, #' geom_tile scale_fill_gradient .data #' @importFrom data.table dcast .I .N #' @export +#' @family plotting functions #' @examples #' library(ggplot2) #' available_forecasts <- available_forecasts( @@ -1088,6 +1098,7 @@ plot_avail_forecasts <- function(available_forecasts, #' element_text labs coord_cartesian theme element_blank #' @importFrom data.table setDT melt #' @export +#' @family plotting functions #' @examples #' scores <- score(example_quantile) #' correlations <- correlation( diff --git a/man/plot.scoringutils_available_forecasts.Rd b/man/plot.scoringutils_available_forecasts.Rd index f11e0dc5d..26cb3fda8 100644 --- a/man/plot.scoringutils_available_forecasts.Rd +++ b/man/plot.scoringutils_available_forecasts.Rd @@ -48,3 +48,17 @@ plot( ) + facet_wrap("target_type") } +\seealso{ +Other plotting functions: +\code{\link{plot.scoringutils_correlation}()}, +\code{\link{plot.scoringutils_pairwise}()}, +\code{\link{plot_heatmap}()}, +\code{\link{plot_interval_coverage}()}, +\code{\link{plot_pit}()}, +\code{\link{plot_predictions}()}, +\code{\link{plot_quantile_coverage}()}, +\code{\link{plot_ranges}()}, +\code{\link{plot_score_table}()}, +\code{\link{plot_wis}()} +} +\concept{plotting functions} diff --git a/man/plot.scoringutils_correlation.Rd b/man/plot.scoringutils_correlation.Rd index 7e2c2480b..f56e4eea2 100644 --- a/man/plot.scoringutils_correlation.Rd +++ b/man/plot.scoringutils_correlation.Rd @@ -26,3 +26,17 @@ correlations <- correlation( ) plot(correlations) } +\seealso{ +Other plotting functions: +\code{\link{plot.scoringutils_available_forecasts}()}, +\code{\link{plot.scoringutils_pairwise}()}, +\code{\link{plot_heatmap}()}, +\code{\link{plot_interval_coverage}()}, +\code{\link{plot_pit}()}, +\code{\link{plot_predictions}()}, +\code{\link{plot_quantile_coverage}()}, +\code{\link{plot_ranges}()}, +\code{\link{plot_score_table}()}, +\code{\link{plot_wis}()} +} +\concept{plotting functions} diff --git a/man/plot.scoringutils_pairwise.Rd b/man/plot.scoringutils_pairwise.Rd index 9b8090ed4..d4a4d5809 100644 --- a/man/plot.scoringutils_pairwise.Rd +++ b/man/plot.scoringutils_pairwise.Rd @@ -32,3 +32,17 @@ pairwise <- pairwise_comparison(scores, by = "target_type") plot(pairwise, type = "mean_scores_ratio") + facet_wrap(~target_type) } +\seealso{ +Other plotting functions: +\code{\link{plot.scoringutils_available_forecasts}()}, +\code{\link{plot.scoringutils_correlation}()}, +\code{\link{plot_heatmap}()}, +\code{\link{plot_interval_coverage}()}, +\code{\link{plot_pit}()}, +\code{\link{plot_predictions}()}, +\code{\link{plot_quantile_coverage}()}, +\code{\link{plot_ranges}()}, +\code{\link{plot_score_table}()}, +\code{\link{plot_wis}()} +} +\concept{plotting functions} diff --git a/man/plot_heatmap.Rd b/man/plot_heatmap.Rd index 8b1aac549..4c623e5f0 100644 --- a/man/plot_heatmap.Rd +++ b/man/plot_heatmap.Rd @@ -33,3 +33,17 @@ scores <- summarise_scores(scores, by = c("model", "target_type", "range")) plot_heatmap(scores, x = "target_type", metric = "bias") } +\seealso{ +Other plotting functions: +\code{\link{plot.scoringutils_available_forecasts}()}, +\code{\link{plot.scoringutils_correlation}()}, +\code{\link{plot.scoringutils_pairwise}()}, +\code{\link{plot_interval_coverage}()}, +\code{\link{plot_pit}()}, +\code{\link{plot_predictions}()}, +\code{\link{plot_quantile_coverage}()}, +\code{\link{plot_ranges}()}, +\code{\link{plot_score_table}()}, +\code{\link{plot_wis}()} +} +\concept{plotting functions} diff --git a/man/plot_interval_coverage.Rd b/man/plot_interval_coverage.Rd index 9c7da16fe..9aaa7b679 100644 --- a/man/plot_interval_coverage.Rd +++ b/man/plot_interval_coverage.Rd @@ -26,3 +26,17 @@ scores <- score(example_quantile) scores <- summarise_scores(scores, by = c("model", "range")) plot_interval_coverage(scores) } +\seealso{ +Other plotting functions: +\code{\link{plot.scoringutils_available_forecasts}()}, +\code{\link{plot.scoringutils_correlation}()}, +\code{\link{plot.scoringutils_pairwise}()}, +\code{\link{plot_heatmap}()}, +\code{\link{plot_pit}()}, +\code{\link{plot_predictions}()}, +\code{\link{plot_quantile_coverage}()}, +\code{\link{plot_ranges}()}, +\code{\link{plot_score_table}()}, +\code{\link{plot_wis}()} +} +\concept{plotting functions} diff --git a/man/plot_pairwise_comparison.Rd b/man/plot_pairwise_comparison.Rd index a5e7bccab..41b5b9579 100644 --- a/man/plot_pairwise_comparison.Rd +++ b/man/plot_pairwise_comparison.Rd @@ -32,3 +32,16 @@ pairwise <- pairwise_comparison(scores, by = "target_type") plot(pairwise, type = "mean_scores_ratio") + facet_wrap(~target_type) } +\seealso{ +Other plotting functions: +\code{\link{plot.scoringutils_available_forecasts}()}, +\code{\link{plot.scoringutils_correlation}()}, +\code{\link{plot_heatmap}()}, +\code{\link{plot_interval_coverage}()}, +\code{\link{plot_pit}()}, +\code{\link{plot_predictions}()}, +\code{\link{plot_quantile_coverage}()}, +\code{\link{plot_ranges}()}, +\code{\link{plot_score_table}()}, +\code{\link{plot_wis}()} +} diff --git a/man/plot_pit.Rd b/man/plot_pit.Rd index d0eceabd3..df4bec54c 100644 --- a/man/plot_pit.Rd +++ b/man/plot_pit.Rd @@ -48,3 +48,17 @@ plot_pit(pit, breaks = seq(0.1, 1, 0.1)) pit <- pit(example_integer,by = "model") plot_pit(pit) } +\seealso{ +Other plotting functions: +\code{\link{plot.scoringutils_available_forecasts}()}, +\code{\link{plot.scoringutils_correlation}()}, +\code{\link{plot.scoringutils_pairwise}()}, +\code{\link{plot_heatmap}()}, +\code{\link{plot_interval_coverage}()}, +\code{\link{plot_predictions}()}, +\code{\link{plot_quantile_coverage}()}, +\code{\link{plot_ranges}()}, +\code{\link{plot_score_table}()}, +\code{\link{plot_wis}()} +} +\concept{plotting functions} diff --git a/man/plot_predictions.Rd b/man/plot_predictions.Rd index 6464262fa..c079a687f 100644 --- a/man/plot_predictions.Rd +++ b/man/plot_predictions.Rd @@ -68,3 +68,17 @@ example_continuous \%>\% facet_wrap(~ location + target_type, scales = "free_y") + aes(fill = model, color = model) } +\seealso{ +Other plotting functions: +\code{\link{plot.scoringutils_available_forecasts}()}, +\code{\link{plot.scoringutils_correlation}()}, +\code{\link{plot.scoringutils_pairwise}()}, +\code{\link{plot_heatmap}()}, +\code{\link{plot_interval_coverage}()}, +\code{\link{plot_pit}()}, +\code{\link{plot_quantile_coverage}()}, +\code{\link{plot_ranges}()}, +\code{\link{plot_score_table}()}, +\code{\link{plot_wis}()} +} +\concept{plotting functions} diff --git a/man/plot_quantile_coverage.Rd b/man/plot_quantile_coverage.Rd index 2e6ef489e..e553ca9a2 100644 --- a/man/plot_quantile_coverage.Rd +++ b/man/plot_quantile_coverage.Rd @@ -25,3 +25,17 @@ scores <- score(example_quantile) scores <- summarise_scores(scores, by = c("model", "quantile")) plot_quantile_coverage(scores) } +\seealso{ +Other plotting functions: +\code{\link{plot.scoringutils_available_forecasts}()}, +\code{\link{plot.scoringutils_correlation}()}, +\code{\link{plot.scoringutils_pairwise}()}, +\code{\link{plot_heatmap}()}, +\code{\link{plot_interval_coverage}()}, +\code{\link{plot_pit}()}, +\code{\link{plot_predictions}()}, +\code{\link{plot_ranges}()}, +\code{\link{plot_score_table}()}, +\code{\link{plot_wis}()} +} +\concept{plotting functions} diff --git a/man/plot_ranges.Rd b/man/plot_ranges.Rd index a4a999ff2..e0acd3739 100644 --- a/man/plot_ranges.Rd +++ b/man/plot_ranges.Rd @@ -41,3 +41,17 @@ plot_ranges(scores, x = "model") + plot_ranges(scores, y = "dispersion", x = "model") + facet_wrap(~target_type) } +\seealso{ +Other plotting functions: +\code{\link{plot.scoringutils_available_forecasts}()}, +\code{\link{plot.scoringutils_correlation}()}, +\code{\link{plot.scoringutils_pairwise}()}, +\code{\link{plot_heatmap}()}, +\code{\link{plot_interval_coverage}()}, +\code{\link{plot_pit}()}, +\code{\link{plot_predictions}()}, +\code{\link{plot_quantile_coverage}()}, +\code{\link{plot_score_table}()}, +\code{\link{plot_wis}()} +} +\concept{plotting functions} diff --git a/man/plot_score_table.Rd b/man/plot_score_table.Rd index 9984e8000..492f5fd10 100644 --- a/man/plot_score_table.Rd +++ b/man/plot_score_table.Rd @@ -45,3 +45,17 @@ plot_score_table(scores, y = c("model", "target_type"), by = "target_type") } +\seealso{ +Other plotting functions: +\code{\link{plot.scoringutils_available_forecasts}()}, +\code{\link{plot.scoringutils_correlation}()}, +\code{\link{plot.scoringutils_pairwise}()}, +\code{\link{plot_heatmap}()}, +\code{\link{plot_interval_coverage}()}, +\code{\link{plot_pit}()}, +\code{\link{plot_predictions}()}, +\code{\link{plot_quantile_coverage}()}, +\code{\link{plot_ranges}()}, +\code{\link{plot_wis}()} +} +\concept{plotting functions} diff --git a/man/plot_wis.Rd b/man/plot_wis.Rd index 982ff1406..984c02126 100644 --- a/man/plot_wis.Rd +++ b/man/plot_wis.Rd @@ -46,3 +46,17 @@ plot_wis(scores, Bracher J, Ray E, Gneiting T, Reich, N (2020) Evaluating epidemic forecasts in an interval format. \url{https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1008618} } +\seealso{ +Other plotting functions: +\code{\link{plot.scoringutils_available_forecasts}()}, +\code{\link{plot.scoringutils_correlation}()}, +\code{\link{plot.scoringutils_pairwise}()}, +\code{\link{plot_heatmap}()}, +\code{\link{plot_interval_coverage}()}, +\code{\link{plot_pit}()}, +\code{\link{plot_predictions}()}, +\code{\link{plot_quantile_coverage}()}, +\code{\link{plot_ranges}()}, +\code{\link{plot_score_table}()} +} +\concept{plotting functions}