toptrading.checkStability function

Check if there are any pairs of agents who would rather swap houses with each other rather than be with their own two current respective partners.

Check if there are any pairs of agents who would rather swap houses with each other rather than be with their own two current respective partners.

toptrading.checkStability(utils = NULL, pref = NULL, matchings)

Arguments

  • utils: is a matrix with cardinal utilities of all individuals in the market. If there are n individuals, then this matrix will be of dimension n by n. The i,jth element refers to the payoff that individual j receives from being matched to individual i.

  • pref: is a matrix with the preference order of all individuals in the market. This argument is only required when utils is not provided. If there are n individuals, then this matrix will be of dimension n by n. The i,jth element refers to j's ith most favorite partner. Preference orders can either be specified using R-indexing (starting at 1) or C++ indexing (starting at 0).

  • matchings: is a vector of length n corresponding to the matchings being made, so that e.g. if the 4th element is 6

    then agent 4 was matched to agent 6.

Returns

true if the matching is stable, false otherwise

Examples

pref <- matrix(c( 2, 4, 3, 4, 3, 3, 4, 2, 4, 2, 2, 1, 1, 1, 1, 3 ), byrow = TRUE, nrow = 4) pref results <- toptrading(pref = pref) results toptrading.checkStability(pref = pref, matchings = results)
  • Maintainer: Jan Tilly
  • License: GPL (>= 2)
  • Last published: 2021-05-25