Description Usage Arguments Author(s) Examples
RAnEnExtra::verifyBrier computes the Brier score and its decomposition for each all lead times available. This function used the NCAR verification package.
1 2 3 4 5 6 7 8 9 | verifyBrier(
anen.ver,
obs.ver,
threshold,
ensemble.func = stop("Ensemble function missing. If it is not an ensemble, set baseline = T"),
baseline = F,
...
)
|
anen.ver |
A 4-dimensional array for analogs. |
obs.ver |
A 3-dimensional array for observations. |
threshold |
The numeric threshold for computing the brier score.
Observation larger than or equal to the threshold
will be converted to 1. Analog values will not be processed with this
threshold value because it is assumed that the ensemble function |
ensemble.func |
A function that takes a vector as input and then
converts the ensemble members (the 4th dimension of analogs) into a scalar.
This scalar is usually a probability within |
baseline |
TRUE if the anen.ver is an one-member forecast array. This is usually used for deterministic baseline model. |
... |
Extra parameters for the ensemble.func. |
Weiming Hu weiming@psu.edu
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | # Create synthetic datasets from different distributions
# with 10 stations, 2 test days, 5 lead times, and
# 50 ensemble members.
#
anen.ver <- array(rnorm(5000), dim = c(10, 2, 5, 50))
obs.ver <- array(runif(100, min = -5, max = 5), dim = c(10, 2, 5))
# Set the threshold for observation. Values larger
# than or equal to this value will be converted to 1, otherwise
# to 0.
#
threshold <- 0.5
# This is the function that takes the ensemble value vector
# as input and output a probability. For example, here I count
# how many values in the member are larger than or equal to
# the split value. You can define your own function to compute
# a probability from the ensemble.
#
ensemble.func <- function(v, split) {return(
length(which(v >= split)) / length(v)
)}
# Calculate the Brier score.
# Don't forget to pass the additional threshold to your ensemble
# function. Otherwise you will receive an error complaining
# about a missing argument.
#
score <- verifyBrier(anen.ver, obs.ver, threshold, ensemble.func, split = threshold)
print(score)
if (all(c('ggplot2', 'reshape2') %in% installed.packages())) {
# Use ggplot2
library(reshape2)
library(ggplot2)
# Unpivot the score table
colnames(score) <- c('Brier', 'Skill', "Reliability", 'Resolution')
melted <- melt(data = score)
colnames(melted) <- c('FLT', 'Type', 'Value')
# Generate ggplot
ggplot(data = melted) +
theme_bw() +
geom_bar(mapping = aes(x = FLT, y = Value, group = Type, fill = Type),
stat = 'identity', position = 'dodge') +
scale_fill_brewer(palette = 'Paired', direction = -1) +
geom_text(mapping = aes(x = FLT, y = Value, label = round(Value, digits = 3),
group = Type), position = position_dodge(0.9), vjust = -0.2) +
labs(y = 'Score') +
theme(legend.position = 'top')
} else {
# Use the base graphics
barplot(score[, 'bs'], ylab = 'Brier')
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.