R/RcppExports.R

# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

#' Computes the log loss score for a tournament prediction
#'
#' @description Compute the (weighted) rank probability score for a tournament.
#' @param 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. 
#' @param outcome A vector of length T containing the integers 1 to R giving the ranks that were obtained by each of the T teams
#' @param rankweights A vector of length R of rank weights or a single weight which will be reused for all ranks (defaults to 1)
#' @return The rank probability score. Zero means a perfect score.
#' @author Claus Ekstrom <ekstrom@@sund.ku.dk>
#' @examples
#'
#' 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)) 
#'
#' @export
logloss <- function(m, outcome, rankweights = 1L) {
    .Call('_socceR_logloss', PACKAGE = 'socceR', m, outcome, rankweights)
}

#' Computes the rank probability score for a tournament
#'
#' @description Compute the (weighted) rank probability score for a tournament.
#' @param 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. 
#' @param outcome A vector of length T containing the integers 1 to R giving the ranks that were obtained by each of the T teams
#' @param rankweights A vector of length R of rank weights or a single weight which will be reused for all ranks (defaults to 1)
#' @return The rank probability score. Zero means a perfect score.
#' @author Claus Ekstrom <ekstrom@@sund.ku.dk>
#' @examples
#'
#' 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)) 
#'
#' @export
trps <- function(m, outcome, rankweights = 1L) {
    .Call('_socceR_trps', PACKAGE = 'socceR', m, outcome, rankweights)
}

Try the socceR package in your browser

Any scripts or data that you put into this service are public.

socceR documentation built on July 3, 2019, 5:05 p.m.