crps.Beta: Methods for Evaluating the CRPS of Various Distributions

View source: R/crps.R

crps.BetaR Documentation

Methods for Evaluating the CRPS of Various Distributions

Description

Methods to the crps generic function from the scoringRules package for evaluating the (continuous) ranked probability score (CRPS) of many distribution objects from the distributions3 package.

Usage

## S3 method for class 'Beta'
crps(y, x, drop = TRUE, elementwise = NULL, ...)

## S3 method for class 'Bernoulli'
crps(y, x, drop = TRUE, elementwise = NULL, ...)

## S3 method for class 'Binomial'
crps(y, x, drop = TRUE, elementwise = NULL, ...)

## S3 method for class 'Erlang'
crps(y, x, drop = TRUE, elementwise = NULL, ...)

## S3 method for class 'Exponential'
crps(y, x, drop = TRUE, elementwise = NULL, ...)

## S3 method for class 'Gamma'
crps(y, x, drop = TRUE, elementwise = NULL, ...)

## S3 method for class 'GEV'
crps(y, x, drop = TRUE, elementwise = NULL, ...)

## S3 method for class 'Geometric'
crps(y, x, drop = TRUE, elementwise = NULL, ...)

## S3 method for class 'Gumbel'
crps(y, x, drop = TRUE, elementwise = NULL, ...)

## S3 method for class 'HyperGeometric'
crps(y, x, drop = TRUE, elementwise = NULL, ...)

## S3 method for class 'Logistic'
crps(y, x, drop = TRUE, elementwise = NULL, ...)

## S3 method for class 'LogNormal'
crps(y, x, drop = TRUE, elementwise = NULL, ...)

## S3 method for class 'NegativeBinomial'
crps(y, x, drop = TRUE, elementwise = NULL, ...)

## S3 method for class 'Normal'
crps(y, x, drop = TRUE, elementwise = NULL, ...)

## S3 method for class 'Poisson'
crps(y, x, drop = TRUE, elementwise = NULL, ...)

## S3 method for class 'StudentsT'
crps(y, x, drop = TRUE, elementwise = NULL, ...)

## S3 method for class 'Uniform'
crps(y, x, drop = TRUE, elementwise = NULL, ...)

Arguments

y

A distribution object, e.g., as created by Normal or Binomial.

x

A vector of elements whose CRPS should be determined given the distribution y.

drop

logical. Should the result be simplified to a vector if possible?

elementwise

logical. Should each distribution in y be evaluated at all elements of x (elementwise = FALSE, yielding a matrix)? Or, if y and x have the same length, should the evaluation be done element by element (elementwise = TRUE, yielding a vector)? The default of NULL means that elementwise = TRUE is used if the lengths match and otherwise elementwise = FALSE is used.

...

Currently not used.

Details

Methods for most univariate distributions are provided for which scoringRules provides a CRPS function and distributions3 provides a distribution object. For example, the crps method for Normal objects simply leverages crps_norm for objects of class Normal.

Value

In case of a single distribution object, either a numeric vector of length(x) (if drop = TRUE, default) or a matrix with length(x) columns (if drop = FALSE). In case of a vectorized distribution object, a matrix with length(x) columns containing all possible combinations.

Examples


set.seed(6020)

## three normal distributions X and observations x
library("distributions3")
X <- Normal(mu = c(0, 1, 2), sigma = c(2, 1, 1))
x <- c(0, 0, 1)

## evaluate crps using infrastructure from scoringRules
library("scoringRules")
crps(X, x)

## analogously for Poisson distribution
Y <- Poisson(c(0.5, 1, 2))
crps(Y, x)

topmodels documentation built on Sept. 10, 2022, 3 p.m.