Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: scoringutils
Title: Utilities for Scoring and Assessing Predictions
Version: 1.1.2
Version: 1.1.3
Language: en-GB
Authors@R: c(
person(given = "Nikos",
Expand All @@ -23,7 +23,7 @@ Authors@R: c(
comment = c(ORCID = "0000-0002-3777-1410")),
person("Sebastian", "Funk",
email = "sebastian.funk@lshtm.ac.uk",
role = c("ctb")))
role = c("aut")))
Description:
Provides a collection of metrics and proper scoring rules
(Tilmann Gneiting & Adrian E Raftery (2007)
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ importFrom(ggplot2,ylab)
importFrom(lifecycle,deprecated)
importFrom(methods,hasArg)
importFrom(rlang,enexprs)
importFrom(rlang,warn)
importFrom(scoringRules,crps_sample)
importFrom(scoringRules,dss_sample)
importFrom(scoringRules,logs_sample)
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# scoringutils 1.1.3

## Package updates
- added a warning to `interval_score()` if the interval range is between 0 and 1. Thanks to @adrian-lison (see #277)

# scoringutils 1.1.2

## Feature updates
Expand Down
14 changes: 14 additions & 0 deletions R/interval_score.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#' `data.frame` instead, simply call [as.data.frame()] on the output.
#' @return vector with the scoring values, or a list with separate entries if
#' `separate_results` is `TRUE`.
#' @importFrom rlang warn
#' @inheritParams ae_median_sample
#' @examples
#' true_values <- rnorm(30, mean = 1:30)
Expand All @@ -67,6 +68,9 @@
#' interval_range = interval_range
#' )
#'
#' # gives a warning, as the interval_range should likely be 50 instead of 0.5
#' interval_score(true_value = 4, upper = 2, lower = 8, interval_range = 0.5)
#'
#' # example with missing values and separate results
#' interval_score(
#' true_values = c(true_values, NA),
Expand Down Expand Up @@ -109,6 +113,16 @@ interval_score <- function(true_values,
)
check_equal_length(true_values, lower, interval_range, upper)

if (any(interval_range < 0, na.rm = TRUE)) {
stop("interval ranges must be positive")
}
if (any(interval_range > 0 & interval_range < 1, na.rm = TRUE)) {
msg <- paste("Found interval ranges between 0 and 1. Are you sure that's right?",
"An interval range of 0.5 e.g. implies a (49.75%, 50.25%) prediction interval.",
"If you want to score a (25%, 75%) prediction interval, set interval_range = 50.")
rlang::warn(message = msg, .frequency = "once", .frequency_id = "small_interval_range")
}

# calculate alpha from the interval range
alpha <- (100 - interval_range) / 100

Expand Down
3 changes: 3 additions & 0 deletions man/interval_score.Rd

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

2 changes: 1 addition & 1 deletion man/scoringutils-package.Rd

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