# matchingMarkets

Analysis of Stable Matchings in R

## Functions

matchingMarkets comes with two estimators:

• stabit: Implements a Bayes estimator that corrects for sample selection in matching markets when the selection process is a one-sided matching game (i.e. group formation).

• stabit2: Implements the Bayes estimator for a two-sided matching game (i.e. the college admissions and stable marriage problems).

and five algorithms that can be used to simulate matching data:

• hri: Constraint model for the hospital/residents problem. Finds all stable matchings in two-sided matching markets. Implemented for both the stable marriage problem (one-to-one matching) and the hospital/residents problem, also known as college admissions problem (many-to-one matching).

• iaa: Immediate Acceptance Algorithm (a.k.a. Boston mechanism): First-preference-first algorithm used for school choice in many countries. And Gale-Shapley Deferred Acceptance Algorithm.

• sri: Constraint model for the stable roommates problem. Finds all stable matchings in the roommates problem (one-sided matching market).

• plp: Partitioning Linear Programme. Finds stable matchings in the roommates problem (one-sided matching market) with transferable utility.

• ttc: Top-Trading-Cycles Algorithm. Finds stable matchings in the housing market problem.

Functions hri and sri are based on Patrick Prosser's n-ary constraint encoding model. They allow for incomplete preference lists (some agents find certain agents unacceptable) and unbalanced instances (unequal number of agents on both sides).

## Installation

Get started by installing the R software for statistical computing.

To get the latest stable version of the package from CRAN:

install.packages("matchingMarkets")
library(matchingMarkets)


Under Linux, the dependency package gmp requires that you have GNU MP (> 4.1.4) installed, see http://gmplib.org.

To get the most recent development version from GitHub:

install.packages("devtools")
devtools::install_github("thiloklein/matchingMarkets")
library(matchingMarkets)


or from R-Forge:

install.packages("matchingMarkets", repos="http://R-Forge.R-project.org")
library(matchingMarkets)


Note: If you get a Java error such as JAVA_HOME cannot be determined from the Registry, this can be resolved by installing a Java version (i.e. 64-bit Java or 32-bit Java) that fits to the type of R version that you are using (i.e. 64-bit R or 32-bit R). This problem can easily effect Windows 7 users, since they might have installed a version of Java that is different than the version of R they are using. See this post and download the Java version from the Oracle website.

## Documentation

Package documentation is available at matchingMarkets.org and the vignette is available from the CRAN page. An application of the estimator in function stabit is in Klein (2015).

## Function reference

### Package

Gives an overview of the various functions used in the matchingMarkets package.

• matchingMarkets-package(matchingMarkets)
An R package for the analysis of stable matchings.

### Algorithms

Documentation for the most common matching algorithms.

• hri
All stable matchings in the hospital/residents problem with incomplete lists
• iaa
Immediate Acceptance Algorithm (a.k.a. Boston mechanism) for two-sided matching markets
• sri
All stable matchings in the stable roommates problem with incomplete lists
• plp
Partitioning Linear Programme for the stable roommates problem
• ttc
Top-Trading-Cycles Algorithm for the house allocation problem

### Estimators

Two structural estimators for one-sided and two-sided matching markets.

• stabit(stabitSel2)
Matching model and selection correction for group formation
• stabit2(stabit2Mat1, stabit2Sel1, stabit2Sel2)
Matching model and selection correction for college admissions

### Data generation

Two functions to produce simulated data for one-sided and two-sided matching markets.

• stabsim
Simulated data for group formation problem
• stabsim2
Simulated data for college admissions problem

### Datasets

Description of three datasets for matching markets contained in the package.

• baac00
Townsend Thai Project BAAC Annual Resurvey, 2000
• klein15a
MCMC results in Klein (2015a)
• klein15b
Results of Monte Carlo Simulations in Klein (2015b)

### Other

• khb
Karlson-Holm-Breen method for comparing probit coefficients
• mce
MC Experiments