ttc2.Rd
Implements the school matching algorithm proposed in Abdulkadiroglu and Sonmez (2003) for a matching problem
in which both sides have preferences. Missing preferences are handled in the following ways: Suppose that a student only ranked colleges that are already matched
to other students. This student is removed from the matching process and a list with all unmatchable students is printed.
If full_return
is set to TRUE
, a vector with this students is returned as well.
Now suppose during the matching process a student points to a college that still has capacities but does not rank any more students.
We assume now that the college is indifferent over all other students (so we do not allow for free capacieties) and we match the student who wants to go there to the college.
ttc2(nStudents = ncol(s.prefs), nColleges = ncol(c.prefs), s.prefs = NULL, c.prefs = NULL, nSlots = NULL, priority = NULL, seed = NULL, full_return = FALSE)
nStudents | integer indicating the number of students in the matching problem. Defaults to |
---|---|
nColleges | integer indicating the number of colleges in the matching problem. Defaults to |
s.prefs | matrix of dimension |
c.prefs | matrix of dimension |
nSlots | vector of length |
priority | (Optional) vector of length |
seed | (Optional) integer setting the state for random number generation. Defaults to seed = NULL |
full_return | (Optinal) If |
ttc2
returns a data frame of the matching of students (ind) to colleges (obj) for the school market problem based on the Top-Trading-Cycles algorithm.
Abdulkadiroglu, A. and T. Sonmez (2003). School Choice: A Mechanism Design Approach. American Economic Review, 93 (3): 729-747.
##\dontrun{ ## 1-a. Compare example from the Abdulkadiroglu et al. (2003) (in the Appendix, page 742-744) ## 1-b. Generate matrix of students' preference rankings over schools, a.k.a. Rank Order Lists (ROL) s.prefs <- matrix(c( 2,1,3,4, 1,2,3,4, 3,2,1,4, 3,4,1,2, 1,3,4,2, 4,1,2,3, 1,2,3,4, 1,2,4,3), byrow = FALSE, ncol = 8); s.prefs#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] #> [1,] 2 1 3 3 1 4 1 1 #> [2,] 1 2 2 4 3 1 2 2 #> [3,] 3 3 1 1 4 2 3 4 #> [4,] 4 4 4 2 2 3 4 3## 1-c. Generate matrix of schools' preference rankings over students, a.k.a. Rank Order Lists (ROL) c.prefs <- matrix(c( 1,2,3,4,5,6,7,8, 3,5,4,8,7,2,1,6, 5,3,1,7,2,8,6,4, 6,8,7,4,2,3,5,1), byrow = FALSE, ncol = 4); c.prefs#> [,1] [,2] [,3] [,4] #> [1,] 1 3 5 6 #> [2,] 2 5 3 8 #> [3,] 3 4 1 7 #> [4,] 4 8 7 4 #> [5,] 5 7 2 2 #> [6,] 6 2 8 3 #> [7,] 7 1 6 5 #> [8,] 8 6 4 1## 1-d. Generate capacities nSlots <- c(2,2,3,3) ## 1-e. Find assignment based on TTC algorithm ttc2(s.prefs = s.prefs, c.prefs = c.prefs, nSlots = nSlots)#> ind obj #> 1 1 2 #> 2 2 1 #> 3 3 3 #> 4 4 3 #> 5 5 1 #> 6 6 4 #> 7 7 2 #> 8 8 4## 2-a. Generate college preferences with college 1 only ranking student 1 c.prefs <- matrix(c( 1,rep(NA,7), 3,5,4,8,7,2,1,6, 5,3,1,7,2,8,6,4, 6,8,7,4,2,3,5,1), byrow = FALSE, ncol = 4); c.prefs#> [,1] [,2] [,3] [,4] #> [1,] 1 3 5 6 #> [2,] NA 5 3 8 #> [3,] NA 4 1 7 #> [4,] NA 8 7 4 #> [5,] NA 7 2 2 #> [6,] NA 2 8 3 #> [7,] NA 1 6 5 #> [8,] NA 6 4 1## 2-b. Find assignment based on TTC algorithm ttc2(s.prefs = s.prefs, c.prefs = c.prefs, nSlots = nSlots, priority = 1:8)#> ind obj #> 1 1 2 #> 2 2 1 #> 3 3 3 #> 4 4 3 #> 5 5 1 #> 6 6 4 #> 7 7 2 #> 8 8 4## If all schools have the same preferences the two sided ttc and the serial dictator yield ## the same outcome if the preferences are taken to be the prioirty order for the serial dictator # Preferences are the same for all schools: c.prefs <- matrix(c( 5,3,1,7,2,8,6,4, 5,3,1,7,2,8,6,4, 5,3,1,7,2,8,6,4, 5,3,1,7,2,8,6,4), byrow = FALSE, ncol = 4) priority <- c.prefs[,1] match_ttc <- ttc2(s.prefs = s.prefs, c.prefs = c.prefs, nSlots = nSlots); match_ttc#> ind obj #> 1 1 2 #> 2 2 2 #> 3 3 3 #> 4 4 3 #> 5 5 1 #> 6 6 4 #> 7 7 1 #> 8 8 4#> ind obj #> 1 1 2 #> 2 2 2 #> 3 3 3 #> 4 4 3 #> 5 5 1 #> 6 6 4 #> 7 7 1 #> 8 8 4#> [1] TRUE##}