Skip to contents

Pivots a set of scores into a matrix with one row per forecast unit (excluding the compare column) and one column per comparator. Entries are the values of metric and are NA where a comparator did not provide a forecast for a given forecast unit.

The function is used by pairwise_comparison_one_group() to align the scores of all comparators once, rather than once per pair of comparators. Exact duplicate rows are dropped silently; rows that share a forecast unit and comparator but are not otherwise identical raise an error, as the scores could then not be pivoted unambiguously.

Usage

pivot_scores(scores, compare = "model", metric)

Arguments

scores

An object of class scores (a data.table with scores and an additional attribute metrics as produced by score()).

compare

Character vector with a single colum name that defines the elements for the pairwise comparison. For example, if this is set to "model" (the default), then elements of the "model" column will be compared.

metric

A string with the name of the metric to pivot. Unlike in get_pairwise_comparisons(), there is no default: the caller must supply a single metric present in scores.

Value

A numeric matrix with one row per forecast unit and one column per comparator. Column names are the comparators (as character).