comparisons_to_matrix: Construct Win Matrix from Comparisons

Description Usage Arguments Value Examples

View source: R/simulate_contests.R

Description

This function constructs a win matrix from a data frame of comparisons. It is needed for the mcmc function.

Usage

1
comparisons_to_matrix(n.areas, comparisons)

Arguments

n.areas

The number of areas in the study.

comparisons

An N x 2 data frame, where N is the number of comparisons. Each row should correspond to a judgement. The first column is the better area, the second column is the more deprived area. The areas should be labeled from 1 to n.areas.

Value

A matrix where the i, j^th element is the number of times area i beat area j.

Examples

1
2
3
4
5
#Generate some sample comparisons
comparisons <- data.frame("winner" = c(1, 3, 2, 2), "loser" = c(3, 1, 1, 3))

#Create matrix from comparisons
win.matrix <- comparisons_to_matrix(3, comparisons)

jasa-btun-anon/BTUN documentation built on Sept. 12, 2020, 12:54 a.m.