logs.numeric: Logarithmic Score for Parametric Forecast Distributions

View source: R/logs.numeric.R

logs.numericR Documentation

Logarithmic Score for Parametric Forecast Distributions

Description

Calculate the logarithmic score (LogS) given observations and parameters of a family of distributions.

Usage

## S3 method for class 'numeric'
logs(y, family, ...)

Arguments

y

Vector of realized values.

family

String which specifies the parametric family; current options: "2pexp", "2pnorm", "beta", "binom", "exp", "exp2", "exponential", "gamma", "gev", "gpd", "hyper", "lapl", "laplace", "llapl", "llogis", "lnorm", "log-laplace", "log-logistic", "log-normal", "logis", "logistic", "mixnorm", "mixture-normal", "nbinom", "negative-binomial", "norm", "normal", "pois", "poisson", "t", "tlogis", "tnorm", "tt", "two-piece-exponential", "two-piece-normal", "unif", "uniform".

...

Vectors of parameter values; expected input depends on the chosen family. See details below.

Details

The parameters supplied to each of the functions are numeric vectors:

  1. Distributions defined on the real line:

    • "laplace" or "lapl": location (real-valued location parameter), scale (positive scale parameter); see logs_lapl

    • "logistic" or "logis": location (real-valued location parameter), scale (positive scale parameter); see logs_logis

    • "normal" or "norm": mean, sd (mean and standard deviation); see logs_norm

    • "normal-mixture" or "mixture-normal" or "mixnorm": m (mean parameters), s (standard deviations), w (weights); see logs_mixnorm; note: matrix-input for parameters

    • "t": df (degrees of freedom), location (real-valued location parameter), scale (positive scale parameter); see logs_t

    • "two-piece-exponential" or "2pexp": location (real-valued location parameter), scale1, scale2 (positive scale parameters); see logs_2pexp

    • "two-piece-normal" or "2pnorm": location (real-valued location parameter), scale1, scale2 (positive scale parameters); see logs_2pnorm

  2. Distributions for non-negative random variables:

    • "exponential" or "exp": rate (positive rate parameter); see logs_exp

    • "gamma": shape (positive shape parameter), rate (positive rate parameter), scale (alternative to rate); see logs_gamma

    • "log-laplace" or "llapl": locationlog (real-valued location parameter), scalelog (positive scale parameter); see logs_llapl

    • "log-logistic" or "llogis": locationlog (real-valued location parameter), scalelog (positive scale parameter); see logs_llogis

    • "log-normal" or "lnorm": locationlog (real-valued location parameter), scalelog (positive scale parameter); see logs_lnorm

  3. Distributions with flexible support and/or point masses:

    • "beta": shape1, shape2 (positive shape parameters), lower, upper (lower and upper limits); see logs_beta

    • "uniform" or "unif": min, max (lower and upper limits); see logs_unif

    • "exp2": location (real-valued location parameter), scale (positive scale parameter); see logs_exp2

    • "gev": location (real-valued location parameter), scale (positive scale parameter), shape (real-valued shape parameter); see logs_gev

    • "gpd": location (real-valued location parameter), scale (positive scale parameter), shape (real-valued shape parameter); see logs_gpd

    • "tlogis": location (location parameter), scale (scale parameter), lower, upper (lower and upper limits); see logs_tlogis

    • "tnorm": location (location parameter), scale (scale parameter), lower, upper (lower and upper limits); see logs_tnorm

    • "tt": df (degrees of freedom), location (location parameter), scale (scale parameter), lower, upper (lower and upper limits); see logs_tt

  4. Distributions of discrete variables:

    • "binom": size (number of trials (zero or more)), prob (probability of success on each trial); see crps_binom

    • "hyper": m (the number of white balls in the urn), n (the number of black balls in the urn), k (the number of balls drawn from the urn); see crps_hyper

    • "negative-binomial" or "nbinom": size (positive dispersion parameter), prob (success probability), mu (mean, alternative to prob); see logs_nbinom

    • "poisson" or "pois": lambda (positive mean); see logs_pois

All numerical arguments should be of the same length. An exception are scalars of length 1, which will be recycled.

Value

Vector of score values. A lower score indicates a better forecast.

Author(s)

Alexander Jordan, Fabian Krueger, Sebastian Lerch

See Also

crps.numeric

Examples

logs(y = 1, family = "normal", mean = 0, sd = 2) 
logs(y = rnorm(20), family = "normal", mean = 1:20, sd = sqrt(1:20))

## Arguments can have different lengths:
logs(y = rnorm(20), family = "normal", mean = 0, sd = 2)
logs(y = 1, family = "normal", mean = 1:20, sd = sqrt(1:20))

## Mixture of normal distributions requires matrix input for parameters:
mval <- matrix(rnorm(20*50), nrow = 20)
sdval <- matrix(runif(20*50, min = 0, max = 2), nrow = 20)
weights <- matrix(rep(1/50, 20*50), nrow = 20)
logs(y = rnorm(20), family = "mixnorm", m = mval, s = sdval, w = weights)


scoringRules documentation built on Sept. 18, 2024, 5:09 p.m.