crps: Continuous Ranked Probability Score

View source: R/crps.R

crpsR Documentation

Continuous Ranked Probability Score

Description

This function calculates the Continuous Ranked Probability Score (CRPS) given observations of a univariate variable and samples of a predictive distribution.

Usage

crps(y, x, method = "ens", na.action = na.omit, aggregate = FALSE, ...)

Arguments

y

vector of observations

x

matrix of samples of a predictive distribution (depending on y; see details)

method

character; "ens" and "sml". Default: "ens" (see details)

na.action

function to handle the NA's. Default: na.omit.

aggregate

logical or function for aggregating the single scores, e.g. sum, mean, weighted.mean, .... Default: FALSE, i.e. no aggregation function.

...

further arguments passed to the aggregate function.

Details

For a vector y of length n, x should be given as matrix with n rows, where the i-th entry of y belongs to the i-th row of x. The columns of x represent the samples of a predictive distribution.

If method "ens" is specified, the CRPS values are calculated for given ensemble forecasts in x (Grimit et al., 2006). If method "sml" is specified, the CRPS values are calculated for a "small" number of given ensemble forecasts in x (Ferro et al., 2008).

A lower CRPS indicates a better forecast.

Value

Vector of score value(s).

Author(s)

David Jobst

References

Matheson, J. Winkler, R. (1976). Scoring Rules for Continuous Probability Distributions. 22(10), 1087-1096.

Ferro, C., Richardson, D. and Weigel, A. (2008). On the effect of ensemble size on the discrete and continuous ranked probability scores. Meteorological Applications, 15, 19-24.

Grimit, E., Gneiting, T., Berrocal, V. and Johnson, N. (2006). The continuous ranked probability score for circular variables and its applications to mesoscale forecast ensemble verification. Quarterly Journal of the Royal Meteorological Society, 132, 2925-2942.

Examples

# simulated data
n <- 30
m1 <- 50
m2 <- 3
m3 <- 10000
y <- rnorm(n)
x1 <- matrix(rnorm(n*m1), ncol = m1)
x2 <- matrix(rnorm(n*m2), ncol = m2)
x3 <- matrix(rnorm(n*m3), ncol = m3)

# crps calculation
crps(y = y, x = x1, method = "ens")
crps(y = y, x = x1, method = "ens", aggregate = mean)

crps(y = y, x = x2, method = "sml")
crps(y = y, x = x2, method = "sml", aggregate = mean)


jobstdavid/eppverification documentation built on May 13, 2024, 5:20 p.m.