Learn R Programming

Sabermetrics (version 2.0)

log5: Log5

Description

Log5 is a way to estimate the probability that Team A will win a game given the true winning probabilities of Team A and Team B

Usage

log5(pA, pB, order = 0)

Arguments

pA
Probability that A wins
pB
Probability that B wins
order
0 = A over B and 1 = B over A

Value

Returns a value equal to (pA-pA*pB)/(pA+pB-2*pA*pB)

References

https://en.wikipedia.org/wiki/Log5

See Also

pyth

Examples

Run this code
## Let's assume team A has a .60 true probability of winning
## Let's assume team B has a .40 true probability of winning
## We should get an output of 0.6923
log5(.60,.40)

## The function is currently defined as
function (pA, pB, order = 0) 
{
    if (order) {
        aux = pB
        pB = pA
        pA = aux
    }
    log5 <- (pA - pA * pB)/(pA + pB - 2 * pA * pB)
    return(log5)
  }

Run the code above in your browser using DataLab