*! version 1.0.0 20jan2025

Title

logloss -- Compute the log loss for binary outcome models

Syntax

logloss outcomevar forecastvar [if] [in]

outcomevar is a binary variable indicating the outcome of the experiment.

forecastvar is the corresponding probability of a positive outcome and
must be between 0 and 1.

by is allowed; see prefix.

Description

logloss computes the log loss metric to assess the accuracy of a binary prediction model. The log loss metric
is considered to be more sensitive than brier in distinguishing between good and poor predictive models. The
log loss ranges from 0 to infinity, where a lower score indicates better performance. A perfect model would have a
log loss of 0, while a random model would have a log loss of around 0.693.
(see: https://www.dratings.com/log-loss-vs-brier-score/).

Example

. sysuse auto

. logit foreign price mpg weight length

. predict predict, pr

. logloss foreign predict

. bys rep78: logloss foreign predict

Stored results

logloss stores the following in r():

Scalars

r(logloss) computed log loss value

Citation of logloss

logloss is not an official Stata command. It is a free contribution
to the research community, like a paper. Please cite it as such:

Linden A. (2025). LOGLOSS: Stata module for computing the log loss metric for binary outcome models.

Author

Ariel Linden

President, Linden Consulting Group, LLC

alinden@lindenconsulting.org

Also see

Online: brier