Skip to content

Commit

Permalink
add plotting examples for pit histogram
Browse files Browse the repository at this point in the history
  • Loading branch information
sbfnk committed Oct 21, 2024
1 parent 643c297 commit ee34257
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions R/get-pit-histogram.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#' Generate a Probability Integral Transformation (PIT) histogram for
#' validated forecast objects.
#'
#' See the examples for how to plot the result of this function.
#'
#' @inherit score params
#' @param num_bins The number of bins in the PIT histogram. For sample-based
#' forecasts, the default is 10 bins. For quantile-based forecasts, the
Expand All @@ -24,12 +26,22 @@
#' @inheritParams pit_histogram_sample
#' @return A data.table with density values for each bin in the PIT histogram.
#' @examples
#' library("ggplot2")
#'
#' example <- as_forecast_sample(example_sample_continuous)
#' result <- get_pit_histogram(example, by = "model")
#' ggplot(result, aes(x = mid, y = density)) +
#' geom_col() +
#' facet_wrap(. ~ model) +
#' labs(x = "Quantile", "Density")
#'
#' # example with quantile data
#' example <- as_forecast_quantile(example_quantile)
#' result <- get_pit_histogram(example, by = "model")
#' ggplot(result, aes(x = mid, y = density)) +
#' geom_col() +
#' facet_wrap(. ~ model) +
#' labs(x = "Quantile", "Density")
#' @export
#' @keywords scoring
#' @references
Expand Down
12 changes: 12 additions & 0 deletions man/get_pit_histogram.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ee34257

Please sign in to comment.