Title: | Evaluating Sport Tournament Predictions |
---|---|
Description: | Functions for evaluating tournament predictions, simulating results from individual soccer matches and tournaments. See <http://sandsynligvis.dk/2018/08/03/world-cup-prediction-winners/> for more information. |
Authors: | Claus Thorn Ekstrøm [aut, cre] |
Maintainer: | Claus Thorn Ekstrøm <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.1.1 |
Built: | 2025-03-07 03:03:05 UTC |
Source: | https://github.com/ekstroem/soccer |
Creates a matrix to collapse the rows of a tournamewnt prediction matrix
collapse_prediction(ranks = c(1, 2, 3, 4, 8, 16, 32))
collapse_prediction(ranks = c(1, 2, 3, 4, 8, 16, 32))
ranks |
An integer vector of R ordered elements giving the cut offs of the ranks to create |
Returns a vector of numeric values. Elements in the input factor that cannot be converted to numeric will produce NA.
Returns a numeric matrix with R rows and T columns that can be multiplied on a square prediction matrix to obtain the collapsed predictions
Claus Ekstrom [email protected]
m2 <- matrix(c(.5, .5, 0, 0, .5, .5, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1), 4) # Collapse into ranks 1, 2, and 3+4 collapse <- collapse_prediction(c(1, 2, 4)) collapsed_prediction <- collapse %*% m2 collapsed_prediction
m2 <- matrix(c(.5, .5, 0, 0, .5, .5, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1), 4) # Collapse into ranks 1, 2, and 3+4 collapse <- collapse_prediction(c(1, 2, 4)) collapsed_prediction <- collapse %*% m2 collapsed_prediction
A list containing five predictions for the FIFA 2018 World Cup.
fifa2018
fifa2018
A list with 5 predictions (each a 7 by 32 matrix) containing the predictions probabilities of 1st, 2nd, 3rd, 4th, 5th-8th, 9th-12th, and 17th-32nd place.
A prediction with equal probability of winning for all teams
Ekstrom's prediction (based on the Skellam distribution)
Ekstrom's prediction (based on the ELO rankings)
Prediction of Groll et all
Updated prediction of Groll et all
http://sandsynligvis.dk/2018/08/03/world-cup-prediction-winners/
A named vector sorted in the ranking of the teams in the FIFA 2018 World Cup. The value correspond to the corresponding columns in the prediction matrices of fifa2018
fifa2018result
fifa2018result
A vector of the final rankings
http://sandsynligvis.dk/2018/08/03/world-cup-prediction-winners/
Compute the (weighted) rank probability score for a tournament.
logloss(m, outcome, rankweights = 1L)
logloss(m, outcome, rankweights = 1L)
m |
An R*T prediction matrix where the R rows represent the ordered ranks and each column is a team. Each column should sum to 1, and each row should sum to the number of teams that can attain a given rank. |
outcome |
A vector of length T containing the integers 1 to R giving the ranks that were obtained by each of the T teams |
rankweights |
A vector of length R of rank weights or a single weight which will be reused for all ranks (defaults to 1) |
The rank probability score. Zero means a perfect score.
Claus Ekstrom <[email protected]>
m1 <- matrix(c(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, .5, .5, 0, 0, .5, .5), 4) m1 # Prediction where certain on the top ranks logloss(m1, c(1, 2, 3, 4))
m1 <- matrix(c(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, .5, .5, 0, 0, .5, .5), 4) m1 # Prediction where certain on the top ranks logloss(m1, c(1, 2, 3, 4))
Computes the optimal weights to obtain the minimal loss function from a list of prediction matrices.
optimize_weights(predictionlist, outcome, FUN = trps)
optimize_weights(predictionlist, outcome, FUN = trps)
predictionlist |
A list of R x T prediction matrices where each column sum to 1 and each row sums to |
outcome |
An integer vector listing the |
FUN |
The function used for optimizing the predictions. The default is top use rps for the rank probability score. Another option is logloss for log loss. |
Returns a numeric vector containing an optimal vector of weights that sum to 1 and that minimizes the loss function.
Claus Ekstrom [email protected]
m1 <- matrix(c(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, .5, .5, 0, 0, .5, .5), 4) m1 # Prediction where certain on the top ranks m2 <- matrix(c(.5, .5, 0, 0, .5, .5, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1), 4) m2 # Prediction where the groups are okay m3 <- matrix(c(.5, .5, 0, 0, .5, .5, 0, 0, 0, 0, .5, .5, 0, 0, .5, .5), 4) m3 # Prediction where no clue about anything m4 <- matrix(rep(1/4, 16), 4) optimize_weights(list(m1, m2, m3, m4), 1:4)
m1 <- matrix(c(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, .5, .5, 0, 0, .5, .5), 4) m1 # Prediction where certain on the top ranks m2 <- matrix(c(.5, .5, 0, 0, .5, .5, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1), 4) m2 # Prediction where the groups are okay m3 <- matrix(c(.5, .5, 0, 0, .5, .5, 0, 0, 0, 0, .5, .5, 0, 0, .5, .5), 4) m3 # Prediction where no clue about anything m4 <- matrix(rep(1/4, 16), 4) optimize_weights(list(m1, m2, m3, m4), 1:4)
Functions for evaluating sport tournament predictions, the tournament rank probability score, and working with models for prediction sport matches.
Claus Ekstrom <[email protected]>
Compute the (weighted) rank probability score for a tournament.
trps(m, outcome, rankweights = 1L)
trps(m, outcome, rankweights = 1L)
m |
An R*T prediction matrix where the R rows represent the ordered ranks and each column is a team. Each column should sum to 1, and each row should sum to the number of teams that can attain a given rank. |
outcome |
A vector of length T containing the integers 1 to R giving the ranks that were obtained by each of the T teams |
rankweights |
A vector of length R of rank weights or a single weight which will be reused for all ranks (defaults to 1) |
The rank probability score. Zero means a perfect score.
Claus Ekstrom <[email protected]>
m1 <- matrix(c(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, .5, .5, 0, 0, .5, .5), 4) m1 # Prediction where certain on the top ranks trps(m1, c(1, 2, 3, 4))
m1 <- matrix(c(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, .5, .5, 0, 0, .5, .5), 4) m1 # Prediction where certain on the top ranks trps(m1, c(1, 2, 3, 4))