Description Usage Arguments Details Value Examples

View source: R/deprecated.R View source: R/toptradingcycle.R

This package implements the top trading cycle algorithm.

1 | ```
toptrading(utils = NULL, pref = NULL)
``` |

`utils` |
is a matrix with cardinal utilities of all individuals in the
market. If there are |

`pref` |
is a matrix with the preference order of all individuals in the
market. This argument is only required when |

The top trading algorithm solves the following problem: A set of `n`

agents
each currently own their own home, and have preferences over the homes of other
agents. The agents may trade their homes in some way, the problem is to identify
a set of trades between agents so that no subset of agents can defect from the
rest of the group, and by trading within themselves improve their own payoffs.

Roughly speaking, the top trading cycle proceeds by identifying cycles of agents, then eliminating those cycles until no agents remain. A cycle is a sequence of agents such that each agent most prefers the next agent's home (out of the remaining unmatched agents), and the last agent in the sequence most prefers the first agent in the sequence's home.

The top trading cycle is guaranteed to produce a unique outcome, and that outcome is the unique outcome in the core, meaning there is no other outcome with the stability property described above.

A vector of length `n`

corresponding to the matchings being
made, so that e.g. if the `4`

th element is `6`

then agent
`4`

was matched to agent `6`

.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | ```
# example using cardinal utilities
utils <- matrix(c(
-1.4, -0.66, -0.45, 0.03,
0.72, 1.71, 0.59, 0.07,
0.44, 1.76, 1.71, -0.27,
0.26, 2.18, 1.4, 0.12
), byrow = TRUE, nrow = 4)
utils
results <- toptrading(utils = utils)
results
# example using ordinal preferences
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
``` |

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

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.