Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

913: Functions for PIT histograms #949

Merged
merged 15 commits into from
Oct 22, 2024
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't it already of class sample and so this line isn't needed?

#' result <- get_pit_histogram(example, by = "model")
#' ggplot(result, aes(x = mid, y = density)) +
nikosbosse marked this conversation as resolved.
Show resolved Hide resolved
#' 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.

Loading