Skip to content

Commit

Permalink
Update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
nikosbosse committed Dec 6, 2023
1 parent 38fe49a commit 1af728e
Show file tree
Hide file tree
Showing 6 changed files with 153 additions and 16 deletions.
11 changes: 10 additions & 1 deletion R/metrics-quantile.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,15 @@
#' or a list with separate entries if `separate_results` is `TRUE`.
#' @export
#' @keywords metric
#' @examples
#' observed <- c(1, -15, 22)
#' predicted <- rbind(
#' c(-1, 0, 1, 2, 3),
#' c(-2, 1, 2, 2, 4),
#' c(-2, 0, 3, 3, 4)
#' )
#' quantile <- c(0.1, 0.25, 0.5, 0.75, 0.9)
#' wis(observed, predicted, quantile)
wis <- function(observed,
predicted,
quantile,
Expand Down Expand Up @@ -522,7 +531,7 @@ ae_median_quantile <- function(observed, predicted, quantile) {
#' @description
#' Proper Scoring Rule to score quantile predictions. Smaller values are better.
#' The quantile score is
#' closely related to the Interval score (see [interval_score()]) and is
#' closely related to the Interval score (see [wis()]) and is
#' the quantile equivalent that works with single quantiles instead of
#' central prediction intervals.
#'
Expand Down
3 changes: 0 additions & 3 deletions man/bias_quantile.Rd

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

113 changes: 113 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/quantile_score.Rd

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

21 changes: 21 additions & 0 deletions man/wis.Rd

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

19 changes: 8 additions & 11 deletions vignettes/scoring-forecasts-directly.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -203,16 +203,13 @@ the Interval Score converges to the CRPS for increasing number of quantiles.


```{r}
observed <- rnorm(30, mean = 1:30)
interval_range <- 90
alpha <- (100 - interval_range) / 100
lower <- qnorm(alpha / 2, rnorm(30, mean = 1:30))
upper <- qnorm((1 - alpha / 2), rnorm(30, mean = 11:40))
interval_score(
observed = observed,
lower = lower,
upper = upper,
interval_range = interval_range
observed <- c(1, -15, 22)
predicted <- rbind(
c(-1, 0, 1, 2, 3),
c(-2, 1, 2, 2, 4),
c(-2, 0, 3, 3, 4)
)
quantile <- c(0.1, 0.25, 0.5, 0.75, 0.9)
wis(observed, predicted, quantile)
```

0 comments on commit 1af728e

Please sign in to comment.