galeShapley.checkPreferences: Check if preference order is complete

Description Usage Arguments Value Examples

View source: R/galeshapley.R

Description

This function checks if a given preference ordering is complete. If needed, it transforms the indices from R indices (starting at 1) to C++ indices (starting at zero).

Usage

1

Arguments

pref

is a matrix with ordinal preference orderings for one side of the market. Suppose that pref refers to the preferences of n women over m men. In that case, pref will be of dimension m by n. The i,jth element refers to woman j's ith most favorite man. Preference orders can either be specified using R-indexing (starting at 1) or C++ indexing (starting at 0).

Value

a matrix with ordinal preference orderings with proper C++ indices or NULL if the preference order is not complete.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# preferences in proper C++ indexing: galeShapley.checkPreferences(pref)
# will return pref
pref <- matrix(c(
  0, 1, 0,
  1, 0, 1
), nrow = 2, ncol = 3, byrow = TRUE)
pref
galeShapley.checkPreferences(pref)

# preferences in R indexing: galeShapley.checkPreferences(pref)
# will return pref-1
pref <- matrix(c(
  1, 2, 1,
  2, 1, 2
), nrow = 2, ncol = 3, byrow = TRUE)
pref
galeShapley.checkPreferences(pref)

# incomplete preferences: galeShapley.checkPreferences(pref)
# will return NULL
pref <- matrix(c(
  3, 2, 1,
  2, 1, 2
), nrow = 2, ncol = 3, byrow = TRUE)
pref
galeShapley.checkPreferences(pref)

matchingR documentation built on May 25, 2021, 9:07 a.m.