Learn R Programming

socceR (version 0.1.1)

optimize_weights: Optimize weights from list of prediction matrices

Description

Computes the optimal weights to obtain the minimal loss function from a list of prediction matrices.

Usage

optimize_weights(predictionlist, outcome, FUN = trps)

Arguments

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.

Value

Returns a numeric vector containing an optimal vector of weights that sum to 1 and that minimizes the loss function.

Examples

Run this code
# NOT RUN {
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)

# }

Run the code above in your browser using DataLab