Skip to content
master
Switch branches/tags
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
R
 
 
 
 
man
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

TraME-Rcpp   Build Status Build status

Transportation Methods for Econometrics via Rcpp modules

Overview

TraME (Transportation Methods for Econometrics) is a C++ library for solving problems of equilibrium computation and estimation in consumer demand and matching frameworks via the Mass Transportation Approach.

TraME-Rcpp is a package of Rcpp modules that allows seamless integration of the TraME C++ library with R.

Installation and Testing

The quickest way to install TraME-Rcpp is via the devtools package.

install.packages("devtools")
library(devtools)
install_github("TraME-Project/TraME-Rcpp")

The TraME test routines are invoked as follows:

library(TraME.Rcpp)
tests_TraME()

Note that TraME requires compilation, and so an appropriate development environment is necessary to install the package.

  • Windows users should get Rtools.
  • Mac uses should check here.

Example

The following code replicates the example from here.

rm(list=ls())
library(TraME.Rcpp)

#

nbX = 18   # number of x types
nbY = 5    # number of y types
sigma = 1  # scaling value

n = rep(1,nbX)  # number of agents of each type
m = rep(1,nbY)

# systematic utilities

alpha = matrix(runif(nbX*nbY),nbX,nbY)
gamma = matrix(runif(nbX*nbY),nbX,nbY)

lambda = 1 + matrix(runif(nbX*nbY),nbX,nbY)
zeta = 1 + matrix(runif(nbX*nbY),nbX,nbY)

phi = alpha + gamma

lambda_LTU = lambda/(lambda + zeta)
phi_LTU = (lambda*alpha + zeta*gamma) / (lambda + zeta)

# build markets

mfe_geo_obj <- new(mfe_geo) # geometric matching function <=> perfectly transferable utility
mfe_geo_obj$build(n,m,phi,sigma,FALSE)

mfe_cd_obj <- new(mfe_cd)   # CD matching function <=> linearly transferable utility
mfe_cd_obj$build(n,m,lambda_LTU,phi_LTU,sigma,FALSE)

mfe_min_obj <- new(mfe_min) # min matching function <=> non-transferable utility
mfe_min_obj$build(n,m,alpha,gamma,sigma,FALSE)

# run IPFP

ptm = proc.time()

sol_geo <- mfe_geo_obj$solve("ipfp")
sol_cd <- mfe_cd_obj$solve("ipfp")
sol_min <- mfe_min_obj$solve("ipfp")

time =  proc.time()  - ptm

message(paste0('\nTime taken = ', time["elapsed"], 's.\n'))

sol_cd <- mfe_cd_obj$solve("ipfp",1E-04,1000) # direct control over tolerance values

Authors

Alfred Galichon and Keith O'Hara

License

GPL (>= 2)

Acknowledgements

Work on TraME is supported by NSF Grant DMS-1716489

About

TraME Library using Rcpp modules

Resources

License

Releases

No releases published

Packages

No packages published