Skip to contents

Computes the Brier Score for probabilistic forecasts of binary outcomes.

Usage

brier_score(true_values, predictions)

Arguments

true_values

A vector with the true observed values of size n with all values equal to either 0 or 1

predictions

A vector with a predicted probability that true_value = 1.

Value

A numeric value with the Brier Score, i.e. the mean squared error of the given probability forecasts

Details

The Brier score is a proper score rule that assesses the accuracy of probabilistic binary predictions. The outcomes can be either 0 or 1, the predictions must be a probability that the true outcome will be 1.

The Brier Score is then computed as the mean squared error between the probabilistic prediction and the true outcome.

$$ \textrm{Brier\_Score} = \frac{1}{N} \sum_{t = 1}^{n} (\textrm{prediction}_t - \textrm{outcome}_t)^2 $$

Examples

true_values <- sample(c(0, 1), size = 30, replace = TRUE)
predictions <- runif(n = 30, min = 0, max = 1)

brier_score(true_values, predictions)
#>  [1] 0.036222622 0.013692308 0.004388180 0.018116171 0.740647113 0.626537690
#>  [7] 0.486026352 0.372469506 0.023253393 0.520376993 0.664541522 0.691775222
#> [13] 0.511295623 0.558215487 0.028203400 0.009639752 0.019932221 0.676765192
#> [19] 0.019704717 0.653011634 0.172274474 0.608267123 0.081002024 0.514780931
#> [25] 0.014129890 0.009625272 0.249126660 0.166635860 0.108810974 0.230979711