Skip to contents

This function is a wrapper around the logs_sample() function from the scoringRules package.

The log score is the negative logarithm of the predictive density evaluated at the observed value.

The function should be used to score continuous predictions only. While the Log Score is in theory also applicable to discrete forecasts, the problem lies in the implementation: The function uses a kernel density estimation, which is not well defined with integer-valued Monte Carlo Samples. See the scoringRules package for more details and alternatives, e.g. calculating scores for specific discrete probability distributions.

Usage

logs_sample(observed, predicted, ...)

Arguments

observed

A vector with observed values of size n

predicted

nxN matrix of predictive samples, n (number of rows) being the number of data points and N (number of columns) the number of Monte Carlo samples. Alternatively, predicted can just be a vector of size n.

...

Additional arguments passed to logs_sample() from the scoringRules package.

Value

Vector with scores.

Input format

Overview of required input format for sample-based forecasts

References

Alexander Jordan, Fabian Krüger, Sebastian Lerch, Evaluating Probabilistic Forecasts with scoringRules, https://www.jstatsoft.org/article/view/v090i12

See also

Other log score functions: logs_nominal(), scoring-functions-binary

Examples

observed <- rpois(30, lambda = 1:30)
predicted <- replicate(200, rpois(n = 30, lambda = 1:30))
logs_sample(observed, predicted)
#>  [1] 2.415978 1.391162 2.876486 1.778651 1.990756 3.187023 2.735783 2.308400
#>  [9] 2.217484 2.403781 2.688615 2.813455 2.178733 2.080475 2.668287 2.773460
#> [17] 2.619100 2.600304 2.610290 3.177565 3.065729 2.454865 2.860266 2.676266
#> [25] 3.299807 2.918963 2.538826 2.698623 2.858104 2.869216