Skip to main content

Solves, simulates, and estimates separable matching TU models

# cupid_matching

A Python package to solve, simulate and estimate separable matching models

## Installation

pip install [-U] cupid_matching


## Importing functions from the package

For instance:

from cupid_matching.min_distance import estimate_semilinear_mde


## How it works

The following only describes the general ideas. The full documentation is here.

The cupid_matching package has code - to solve for the stable matching using our Iterative Projection Fitting Procedure (IPFP) in variants of the model of bipartite, one-to-one matching with perfectly transferable utility. It has IPFP solvers for variants of the Choo and Siow 2006 model with or without singles, homoskedastic and heteroskedastic; and also for a class of nested logit models. - to estimate the parameters of separable models with semilinear surplus and entropy using a minimum distance estimator. - to estimate the parameters of semilinear Choo and Siow models using a Poisson GLM estimator. - for a Streamlit interactive app that demonstrates solving and estimating the Choo and Siow model using the cupid_matching package. You can try it here.

Incidentally, myy ipfp_R Github repository contains R code to solve for equilibrium in (only) the basic version of the Choo and Siow model.

The package builds on the pioneering work of Choo and Siow JPE 2006 and on my work with Alfred Galichon, especially our REStud 2022 paper and this working paper.

## Examples

• example_choosiow.py shows how to run minimum distance and Poisson estimators on a Choo and Siow homoskedastic model.
• example_nestedlogit.py shows how to run minimum distance estimators on a two-layer nested logit model.

## Warnings

• many of these models (including all variants of Choo and Siow) rely heavily on logarithms and exponentials. It is easy to generate examples where numeric instability sets in.
• as a consequence, the numeric versions of the minimum distance estimator (which use numerical derivatives) are not recommended.
• the bias-corrected minimum distance estimator (corrected) may have a larger mean-squared error and/or introduce numerical instabilities.
• the estimated variance of the estimators assumes that the observed matching was sampled at the household level, and that sampling weights are all equal.

## Release notes

### version 1.1.0

• the package now relies on my utilities package bs_python_utils. The VarianceMatching class in matching_utils,py is new; this should be transparent for the user.

### version 1.0.8

• deleted spurious print statement.

### version 1.0.7

• fixed error in bias-correction term.

### version 1.0.6

• corrected typo.

### version 1.0.5

• simplified the bias-correction for the minimum distance estimator in the Choo and Siow homoskedastic model.

### version 1.0.4

• added an optional bias-correction for the minimum distance estimator in the Choo and Siow homoskedastic model, to help with cases when the matching patterns vary a lot across cells.
• added two complete examples: example_choosiow.py and example_nestedlogit.py.

## Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

### Source Distribution

cupid_matching-1.1.0.tar.gz (39.2 kB view hashes)

Uploaded Source

### Built Distribution

cupid_matching-1.1.0-py3-none-any.whl (43.7 kB view hashes)

Uploaded Python 3