{'fraction_non_alphanumeric': 0.04527264642871579, 'fraction_numerical': 0.009883180403411617, 'mean_word_length': 4.159436913451512, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 21, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Peer Effects and Stability in Matching Markets

Many-to-one matching markets exist in numerous different forms, such as college admissions, matching medical interns to hospitals for residencies, assigning housing to college students, and the classic firms and workers market. In all these markets, externalities such as complementarities and peer effects severely complicate the preference ordering of each agent. Further, research has shown that externalities lead to serious problems for market stability and for developing efficient algorithms to find stable matchings. In this paper we make the observation that peer effects are often the result of underlying social connections, and we explore a formulation of the many-to-one matching market where peer effects are derived from an underlying social network. The key feature of our model is that it captures peer effects and complementarities using utility functions, rather than traditional preference ordering. With this model and considering a weaker notion of stability, namely two-sided exchange stability, we prove that stable matchings always exist and characterize the set of stable matchings in terms of social welfare. We also give distributed algorithms that are guaranteed to converge to a two-sided exchange stable matching. To assess the competitive ratio of these algorithms and to more generally characterize the efficiency of matching markets with externalities, we provide general bounds on how far the welfare of the worst-case stable matching can be from the welfare of the optimal matching, and find that the structure of the social network (e.g. how well clustered the network is) plays a large role.


Introduction
Many-to-one matching markets exist in numerous forms, such as college admissions, the national medical residency program, freshman housing assignment, as well as the classic firms-and-workers market. These markets are widely studied in academia and also widely deployed in practice, and have been applied to other areas, such as FCC spectrum allocation and supply chain networks [5,28] In the conventional formulation, matching markets consist of two sets of agents, such as medical interns and hospitals, each of which have preferences over the agents to which they are matched. In such settings it is important that matchings are 'stable' in the sense that agents do not have incentive to change assignments after being matched. The seminal paper on matching markets was by Gale and Shapley [18], and following this work an enormous literature has grown, e.g., [26,34,35,36] and the references therein. Further, variations on Gale and Shapley's original algorithm for finding a stable matching are in use by the National Resident Matching Program (NRMP), which matches medical school graduates to residency positions at hospitals [33].
However, there are problems with many of the applications of matching markets in practice. For example, couples participating in the NRMP often reject their matches and search outside the system. In housing assignment markets where college students are asked to list their preferences over housing options, there is often collusion among friends to list the same preference order for houses. These two examples highlight that 'peer effects', whether just couples or a more general set of friends, often play a significant role in many-to-one matchings. That is, agents care not only where they are matched, but also which other agents are matched to the same place. Similarly, 'complementarities' often play a role on the other side of the market. For example, hospitals and colleges care not only about which individual students are assigned to them, but also that the group has a certain diversity, e.g., of different specializations.
As a result of the issues highlighted above, there is a growing literature studying many-to-one matchings with externalities (i.e., peer effects and complementarities) [12,19,24,25,29,31,4,13,37] and the research has found that designing matching mechanisms is significantly more challenging when externalities are considered, e.g. incentive compatible mechanism design is no longer possible. In fact, even determining the existence of stable matchings in the presence of externalities has been difficult.
The reason for the difficulty is that there is no longer a guarantee that a stable many-to-one matching will exist when agents care about more than their own matching [33,35], and, if a stable matching does exist, it can be computationally difficult to find [32]. Consequently, most research has focused on identifying when stable matchings do and do not exist. Papers have proceeded by constraining the matching problem through restrictions of the possible preference orderings, [12,19,24,25,29,31], and by considered variations on the standard notion of stability [4,13,37]. Our paper also considers a restriction of the model, described in the following.
The key idea of this paper is that peer effects are often the result of an un-derlying social network. That is, when agents care about where other agents are matched, it is often because they are friends. With this in mind, we construct a model in Section 2 that includes a weighted, undirected social network graph and allows agents to have utilities (which implicitly defines their preference ordering) that depend on where neighbors in the graph are assigned. The model is motivated by [4], which also considers peer effects defined by a social network but focuses on one-sided matching markets rather than two-sided matching markets. We focus on two-sided exchange-stable matchings -see Section 2 for a detailed definition. We note that compared to the traditional notion of stability of [18], this is a distinct notion of stability, but one that is relevant to many situations where agents can compare notes with each other, such as the housing assignment or medical matching problem. For example, in [4,5,16], "pairwisestability" is considered since they consider models where agents exchange offices or licenses in FCC spectrum auctions. Further, consider a situation where two hospital interns prefer to exchange the hospitals allocated to them by the NRMP. If this is a traditional stable matching, the hospitals would not allow the swap, even though the interns are highly unsatisfied with the match. Such a situation has been documented in [21], and has led to a similar type of stability, exchange stability, as defined in [1,9,10,21].
Given our model of peer effects, the focus of the paper is then on characterizing the set of two-sided exchange-stable matchings. Our results concern (i) the existence of two-sided exchange-stable matchings, (ii) algorithms for finding two-sided exchange-stable matchings, and (iii) the efficiency of exchange-stable matchings (in terms of social welfare).
With respect to the existence of stable matchings (Section 3), it is not difficult to show that in our model two-sided exchange-stable matchings always exist. Further, if students value houses according to the same rules, the matching that maximizes social welfare is guaranteed to be two-sided exchange-stable. Given the contrast to the negative results that are common for many-to-one matchings, e.g., [13,32,33], these results are perhaps surprising. Further, the results on characterizing the existence of stable matchings naturally suggest two simple algorithms for finding stable matchings, which we discuss in Section 4.
With respect to the efficiency of exchange-stable matchings (Section 5), results are not as easy to obtain. In this context, we limit our focus to one-sided matching markets, but as a result we are able to attain bounds on the ratio of the welfare of the optimal matching to that of the worst stable matching, i.e., the 'price of anarchy'. We also demonstrate cases where our bounds are tight. When considering only one-sided markets, our model becomes similar to hedonic coalition formation, but with several key differences, as highlighted in Section 5. Our results (Theorems 5 and 6) show that the price of anarchy does not depend on the number of, say, interns, but does grow with the number of, say, hospitals -though the growth is typically sublinear. Further, we observe that the impact of the structure of the social network on the price of anarchy happens only through the clustering of the network, which is well understood in the context of social networks, e.g., [22,39]. Finally, it turns out that the price of anarchy has a dual interpretation in our context; in addition to providing a bound on the inefficiency caused by enforcing exchange-stability, it turns out to also provide a bound on the loss of efficiency due to peer effects.

Model and notation
To begin, we define the model we use to study many-to-one matchings with peer effects and complementarities. There are four components to the model, which we describe in turn: (i) basic notation for discussing matchings; (ii) the model for agent utilities, which captures both peer effects and complementarities; (iii) the notion of stability we consider; and (iv) the notion of social welfare we consider.
To provide a consistent language for discussing many-to-one matchings, throughout this paper we use the setting of matching incoming undergraduate students to residential houses. In this setting many students are matched to each house, and the students have preferences over the houses, but also have peer effects as a result of wanting to be matched to the same house as their friends. Similarly, the houses have preferences over the students, but there are additional complementarities due to goals such as maintaining diversity. It is clear that some form of stability is a key goal of this "housing assignment" problem.
Notation for many-to-one matchings Using the language of the housing assignment problem, we define two finite and disjoint sets, H = {h 1 , . . . , h m } and S = {s 1 , . . . , s n } denoting the houses and students, respectively. For each house, there exists a positive integer quota q h which indicates the number of positions a house has to offer. The quota for each house may be different.
A matching µ describes the assignment of students to houses such that students are matched to only one house, while houses are matched to multiple students. More formally: Definition 1. A matching is a subset µ ⊆ S × H such that |µ(s)| = 1 and |µ(h)| = q h , where µ(s) = {h ∈ H : (s, h) ∈ µ} and µ(h) = {s ∈ S : (s, h) ∈ µ}. 1 Note that we use µ 2 (s) to denote the set of student s's housemates (students also in house µ(s)).
Friendship network The friendship network among the students is modeled by a weighted graph, G = (V, E, w) where V = S and the relationships between students are represented by the weights of the edges connecting nodes. The strength of a relationship between two students s and t is represented by the weight of that edge, denoted by w(s, t) ∈ R + ∪ {0}. We require that the graph is undirected, i.e., the adjacency matrix is symmetric so that w(s, t) = w(t, s) for all s, t.
Additionally, we define a few metrics quantifying the graph structure and its role in the matching. Let the total weight of the graph be denoted by |E| := 1 2 s∈S t∈S w(s, t). Further, let the weight of edges connecting houses h and g under matching µ be denoted by E hg (µ) := s∈µ(h) t∈µ(g) w(s, t). Note that in the case of edges within the same house E hh (µ) := 1 2 s∈µ(h) t∈µ(h) w(s, t). Finally, let the weight of edges that are within the houses of a particular matching µ be denoted by E in (µ) := h∈H E hh (µ).
Agent utility functions In our model, each agent derives some utility from a particular matching and an agent (student or house) always strictly prefers matchings that give a strictly higher utility and is indifferent between matchings that give equal utility. This setup differs from the traditional notion of 'preference orderings' [18,35], but is not uncommon [2,4,5,7,16]. It is through the definitions of the utility functions that we model peer effects (for students) and complementarities (for houses).
Under our model, students derive benefit both from (i) the house they are assigned to and (ii) their peers that are assigned to the same house. We model each house h as having an desirability of D s h ∈ R + ∪ {0} for student s. A similar model was first used in [4] and is meant to capture the physical characteristics of the house (amenities, size, etc.) with D s h as well as peer effects. If D s h = D t h ∀s = t (objective desirability), this value can be seen as representing something like the U.S. News college rankings or hospital rankings -something that all students would agree on. This leads to a utility for student s under matching µ of where w(s, t) is the weight of the edge between s and t in the friendship graph and D s h is utility derived by student s for house h, so that the total utility that a student derives from a match is a combination of how "good" a house is as well as how many friends they will have in that house. 23 Similarly, the utility of a house h under matching µ is modeled by where D h σ denotes the desirability of a particular set of students σ for house h (the utility house h derives from being matched to the set of students σ). Note that this definition of utility allows general phenomena such as heterogeneous house preferences over groups of students.
Two-sided exchange stability Under the traditional definition of stability, if a student and a house were to prefer each other to their current match (forming a blocking pair), the student is free to move to the preferred house and the house is free to evict (if necessary) another student to make space for the preferred student. In our model, however, we assume that students and houses cannot "go outside the system" and leave the university (neither can students remain unmatched), like what medical students and hospitals do when they operate outside of the NRMP. As a result, we restrict ourselves to considering swaps of students between houses, similar to [4,5,16].
To define exchange stability, it is convenient to first define a swap matching µ t s in which students s and t switch places while keeping all other students' assignments the same.
Note that the agents directly involved in the swap are the two students switching places and their respective houses -all other matchings remain the same. Further, one of the students involved in the swap can be a "hole" representing an open spot, thus allowing for single students moving to available vacancies. When two actual students are involved, this type of swap is a twosided version of the "exchange" considered in [1,9,10,21] -two-sided exchange stability requires that houses approve the swap. As a result, while an exchangestable matching may not exist in either the marriage or roommate problem, we show in Section 3 that a two-sided exchange-stable matching will always exist for the housing assignment problem.

Definition 3.
A matching µ is two-sided exchange-stable (2ES) if and only if there does not exist a pair of students (s, t) such that: This definition implies that a swap matching in which all agents involved are indifferent is two-sided exchange-stable. This avoids looping between equivalent matchings. Note that the above definition implies that if two students want to switch between two houses (or a single student wants to "switch" with a hole), the houses involved must "approve" the swap or if two houses want to switch two students, the students involved must agree to the swap (a hole will always be indifferent). This is natural for the house assignment problem and many other many-to-one matching markets, but would be less appropriate for some other settings, such as the college-admissions model.

Social welfare
One key focus of this paper is to develop an understanding of the "efficiency loss" that results from enforcing stability of assignments in matching markets. We measure the efficiency loss in terms of the "social welfare", which we define as follows: Using this definition of social welfare, the efficiency loss can be quantified using the Price of Anarchy (PoA) and Price of Stability (PoS). Specifically, the PoA (PoS) is the ratio of the optimal social welfare over all matchings, not necessarily stable, to the minimum (maximum) social welfare over all stable matchings. Understanding the PoA and PoS is the focus of Section 5.

Existence of stable matchings
We begin by focusing on the existence of two-sided exchange stable matchings. In most prior work, matching markets with externalities do not have guaranteed existence of a stable matching. For example, in the presence of couples on the resident side of the hospital matching market, the NRMP algorithm may fail to have a stable outcome [33,35], and even if a stable matching does exist, it may be NP-hard to find [32].
In contrast to the prior literature discussed above, we prove that a two-sided exchange stable matching always exists in the model considered in this paper. We begin by proposing a potential function Φ(µ) for the matching game: Due to the symmetry of the social network, every approved swap will result in a strict increase of the potential function. Specifically, . Detailed proofs of this lemma and the following results are shown in Appendix A. Expanding on this idea, it is easy to prove the following theorem.
As there is a finite set of matches, this results in the existence of a two-sided exchange stable matching for every housing assignment market.
If we assume that there are no vacancies in any of the houses and students value houses according to the same rules (i.e., D s h = D t h ∀ s = t), then each each approved swap will result in a strict increase in the social welfare. Specifically, Lemma 3. If house quotas are exactly met and D s h = D t h ∀ s = t, then any swap matching µ t s for which As before, it is now easy to prove the following theorem.
Theorem 4. If house quotas are exactly met and D s h = D t h ∀ s = t, all local maxima of W (µ) are two-sided exchange stable.
Note that this implies that the maximally efficient matching will be two-sided exchange-stable. 4 Note, however, that not all two-sided exchange-stable matchings are local maxima of Φ(µ) or W (µ). Such a case arises when one student, for example, refuses a swap as her utility would decrease, but the other student involved stands to benefit a great deal from such a swap. If the swap were forced, the total potential function (or social welfare) could increase, but only at the expense of the first student.
The contrast between Theorem 2 and the results such as [33] and [35] can be explained by considering a few aspects of the model we study. In particular, we are using a distinct type of stability appropriate to our housing assignment market. Further, the assumption that the social network graph is symmetric are key to guaranteeing existence.

Finding stable matchings
In the previous section we have shown that a two-sided exchange-stable matching will always exist and, moreover, that under certain assumptions, socially optimal matchings are two-sided exchange-stable. In this section, we turn to the task of developing algorithms for finding two-sided exchange-stable matchings. In particular, two natural algorithms follow immediately from our analysis. For simplicity, in this section we will assume the conditions of Theorem 4; namely, that quotas are exactly met and students rate houses according to the same rules. 5 Algorithm 1 proceeds by greedily considering "approved" swaps among students/houses that improve the social welfare. Note that this algorithm can easily be implemented in a distributed manner, and loosely models the process by which individuals adjust a matching that is not stable.
Lemma 3 and Theorem 2 immediately give that this algorithm will converge to a two-sided exchange-stable matching, since the social welfare strictly improves with each iteration, and all local maxima of W are two-sided exchangestable matchings. Note that Algorithm 1 is not guaranteed to converge to the socially optimal stable matching; it will likely find just a local maxima of W . Also, note that each iteration of the algorithm above can involve searching many pairs of students (and houses) for an "approved" swap.
The second algorithm we consider again seeks to optimize W , this time using a MCMC heat bath. In this algorithm we start with a random initial matching and at each iteration swap a random pair of students with a probability that depends on the change in social welfare: a positive change yields a probability of swapping larger than 1/2 and vice-versa. Algorithm 2 therefore can emerge from a local maximum. The algorithm keeps track of the "best" matching found so far, even as it moves to worse matchings. If Algorithm 2 is run sufficiently long (perhaps exponential time) it can find the optimal two-sided exchangestable matching [20]. However, there is no guarantee that the best matching encountered in finite time is even two-sided exchange-stable, a situation that can be remedied by applying the greedy algorithm to this matching. Simulation results show the superiority of Algorithm 2 to Algorithm 1 in terms of welfare, at the expense of an increase in the number of computations.
Pick random pair of students {s, t} To illustrate the performance of these two natural algorithms, we use two social network data sets.
The first data set is from the Caltech Project [15]. This data set is an undirected graph representing the friendship links among the undergraduates at the California Institute of Technology in 2010. It includes approximately 900 nodes and 3500 edges. To illustrate the algorithms, we created 10 houses and assigned them desirability values uniformly distributed from 0 to 10. For the other side of the market, each student is assigned a score by each house, uniformly distributed from 0 to 10. Each algorithm is run using the same initial values, and the results are shown in Figure 1.
The second data set we use is from voting records for admin promotion at   Wikipedia. Edges in the dataset represent votes for or against a user by another user. For simplicity, we treated the directed graph as undirected, resulting in approximately 7000 nodes and 100000 edges. To illustrate the algorithms, we created 71 houses and assigned them uniform random values between 0 and 10 as before. For the other side of the market, each users is assigned a score by each house, uniformly distributed from 0 to 10, also as before. Each algorithm is run using the same initial values, and the results are shown in Figure 2. Figures 1 and 2 illustrate that with both networks, Algorithm 2 has longer running time than Algorithm 1, which converges quickly. 6 The y-axis in all figures shows the social welfare of the matching at each iteration. As expected, Algorithm 1 converges to a sub-optimal matching for both networks, but this value is of the same order of magnitude as that found by Algorithm 2.

Efficiency of stable matchings
To this point, we have focused on the existence of two-sided exchange-stable matchings and how to find them. In this section our focus is on the "efficiency loss" due to stability in a matching market and the role peer effects play in this efficiency loss.
We measure the efficiency loss in a matching market using the price of stability (PoS) and the price of anarchy (PoA) as defined in Section 2. Interestingly, the price of anarchy has multiple interpretations in the context of this paper. First, as is standard, it measures the worst-case loss of social welfare that results due to enforcing exchange-stability. For example, the authors in [2] bound the loss in social welfare caused by individual rationality (by enforcing stable matchings) for matching markets without externalities. Second, it provides a competitive ratio for Algorithm 1 for finding a stable matching, since Algorithm 1 provides no guarantee about which stable matching it will find. Third, we show later that the price of anarchy also has an interpretation as capturing the efficiency lost due to peer effects.
The results in this section all require one additional simplifying assumption to our model: complementarities are ignored and only peer effects are considered. Specifically, we assume, for all of our PoA results, U h (µ) = 0, and thus W (µ) = s∈S U s (µ). Under this assumption, the market is one-sided, with only students participating-as a result we are only considering exchange-stability. This assumption is limiting, but there are still many settings within which the model is appropriate. Two examples are the housing assignment problem in the case when students can swap positions without needing house approval, and the assignment of faculty to offices as discussed in [4], as clearly the offices have no preferences over which faculty occupy them. In order to simplify the analysis, we also make use of the assumptions in Theorem 4 : (i) D s h = D t h ∀ s = t and (ii) house quotas are exactly met.

Related models
When the housing assignment problem is restricted to a one-sided market involving only students, we note that it becomes very similar to both (i) a hedonic coalition formation game with symmetric additively separable preferences, as described in [6], and (ii) a coalitional affinity game, as described in [7].
In hedonic coalition formation games, agents' preferences for a given coalition are based on the other members of that coalition [11]. Note that coalition games are necessarily one-sided -agents care about the coalitions but the coalitions cannot care about the agents. The most related work to ours in this area is [6], where the authors show that when agents' preferences over coalition are symmetric and additively separable (as the student utility functions in the housing assignment problem are), a Nash (and individually) stable coalition structure will always exist. This mimics the existence result proved in Section 3, however our result applies for a two-sided market. Further work on hedonic games looks at the complexity of finding stable coalition structures; see [3,8,14,17,27] for (a) optimal matching (b) stable matching Coalitional affinity games consider the pairwise relationships between agents, as represented by a weighted graph [7], and are a special subclass of hedonic games. The most related result to the current work is [7], which proves a tight upper bound on the Price of Anarchy using the notion of core stability 7 when the weighted graph is symmetric.
While the one-sided housing assignment problem and hedonic coalition formation games appear to be very similar, there are a number of key differences. Most importantly, the housing assignment problem considers a fixed number of houses with a limited number of spots available; students cannot break away and form a new coalition/house, nor can a house have more students than its quota. In addition, our model considers exchange-stability, which is closest to the Nash stability of [6], but is still significantly different in that it involves a pair of students willing and able to swap. Finally, each student gains utility from the house they are matched with, in addition to the other members of that house, which is different from the original formulation of hedonic coalition games.

Discussion of results
To begin the discussion of our results, note that, as discussed in Section 3, the price of stability is 1 for our model because any social welfare optimizing matching is stable.
However, the price of anarchy can be much larger than 1. In fact, depending on the social network, the price of anarchy can be unboundedly large, as illustrated in the following example.
Example 1 (Unbounded price of anarchy). Consider a matching market with 4 students and 2 houses, each with a quota of 2, and two possible matchings illustrated by Figure 3. As shown in Figure 3 (a) and (b), respectively, in the optimal matching µ * , W (µ * ) = k; whereas there exists a exchange-stable matching with W (µ) = 2. Thus, as k increases, the price of anarchy grows linearly in k.
Despite the fact that, in general, there is a large efficiency loss that results from enforcing exchange-stability, in many realistic cases the efficiency loss is actually quite small. The following two theorems provide insight into such cases.
A key parameter in these theorems is γ * m which captures how well the social network can be "clustered" into a fixed number of m groups and is defined as follows.
Thus, γ * m represents the maximum edges that can be captured by a partition satisfying the house quotas. Note that γ * m is highly related to other clustering metrics, such as the conductance [23], [38] and expansion [30].
We begin by noting that due to the assumption that h∈H U h (µ) = 0, we can separate the social welfare function into two components: where Note that the parameter Q is independent of the particular matching µ. Our first theorem regarding efficiency is for the "simple" case of unweighted social networks with equal house quotas and/or equivalently valued houses.
Theorem 5. Let w(s, t) ∈ {0, 1} for all students s, t and let q h ≥ 2, D h ∈ Z + ∪ {0} for all houses h. If q h = q for all h and/or D h = D for all h, then The bound in Theorem 5 is tight, as illustrated by the example below.
Example 2 (Tightness of Theorem 5). Consider a setting with m houses and q h = mk for all h ∈ H. Students are grouped into clusters of size k > 2, as shown for m = 3 in Figure 4. The houses have D h = k + 1 and D g = D i = 0. Each student in the middle cluster in each row has k edges to the other students outside of their cluster (but none within), as shown.
The worst-case stable exchange-matching is represented by the vertical red lines. Note that since D h = k + 1, this matching is stable, even though all edges are cut. Thus min µ stable γ m (µ) = 0. The optimal matching is represented by k edges the horizontal blue lines in the figure; note that γ * m = 1. To calculate the price of anarchy, we start from equations (6) and (7) and calculate Notice that as k becomes large, this approaches the bound of 1 + 2(m − 1)γ * m .
We note that the requirement q h = q for all h and/or D h = D for all h is key to the proof of Theorem 5 and in obtaining such a simple bound; otherwise, Theorem 6 applies. We omit the proofs of these theorems here for brevity; see Appendix B for the details.
Our second theorem removes the restrictions in the theorem above, at the expense of a slightly weaker bound. Define q max = max h∈H q h , w max = max s,t∈S w(s, t) and D ∆ = min h,g∈H (D h − D g ), assuming that the houses are ordered in increasing values of D h . Theorem 6. Let w(s, t) ∈ R + ∪ {0} for all students s, t and D h ∈ R + ∪ {0}, q h ∈ Z + for all houses h, then Though Theorem 5 is tight, it is unclear at this point whether Theorem 6 is also tight. However, a slight modification of the above example does show that it has the correct asymptotics, i.e., there exists a family of examples that have price of anarchy Θ(mγ * m q max w max D −1 ∆ ).  A first observation one can make about these theorems is that the price of anarchy has no direct dependence on the number of students. This is an important practical observation since the number of houses is typically small, while the number of students can be quite large (similar phenomena hold in many other many-to-one matching markets). In contrast, the theorems highlight that the degree of heterogeneity in quotas, network edge weights, and house valuations all significantly impact inefficiency.
A second remark about the theorems is that the only dependence on the social network is through γ * m , which measures how well the graph can be "clustered" into m groups. An important note about γ * m is that it is highly dependent on m, and tends to shrink quickly as m grows. We give an illustration of this effect in Figures 5a and 5b using the two social network data sets described in Section 4. A consequence of this behavior is that the price of anarchy is not actually linear in m in Theorems 5 and 6, as it may first appear, it turns out to be sublinear. This is illustrated in the context of real social network data in Figures 5c and 5d. We note that as we are increasing m, what we are in fact doing is creating finer allowable partitions of the network.
Next, let us consider the impact of peer effects on the price of anarchy. Considering the simple setting of Theorem 5, we see that if there were no peer effects, this would be equivalent to setting w(s, t) = 0 for all s, t. This would imply that γ * m = 0, and so the price of anarchy is one. Thus, another interpretation of the price of anarchy in Theorem 5 is the efficiency lost as a result of peer effects.

Concluding remarks
In this paper we have focused on many-to-one matchings with peer effects and complementarities. Typically, results on this topic tend to be negative, either proving that stable matchings may not exist, e.g., [33,35], or that stable matchings are computationally difficult to find, e.g., [32].
In this paper, our goal has been to provide positive results. To this end, we focus on the case when peer effects are the result of an underlying social network, and this restriction on the form of the peer effects allows us to prove that a two-sided exchange-stable matching always exists and that socially optimal matchings are always stable. Further, we provide bounds on the maximal inefficiency (price of anarchy) of any exchange-stable matching and show how this inefficiency depends on the clustering properties of the social network graph. Interestingly, in our context the price of anarchy has a dual interpretation as characterizing the degree of inefficiency caused by peer effects.
There are numerous examples of many-to-one matchings where the results in this paper can provide insight; one of particular interest to us is the matching of incoming undergraduates to residential houses which happens yearly at Caltech and other universities. Currently incoming students only report a preference order for houses, and so are incentivized to collude with friends and not reveal their true preferences. For such settings, the results in this paper highlight the importance of having students report not only their preference order on houses, but also a list of friends with whom they would like to be matched. Using a combination of these factors the algorithms and efficiency bounds presented in this paper provide a promising approach, for this specific market as well as any general market where peer effects change the space of stable matchings.
The results in the current paper represent only a starting point for research into the interaction of social networks and many-to-one matchings. There are a number of simplifying assumptions in this work which would be interesting to relax. For example, the efficiency bounds we have proven consider only a one-sided market, where houses do not have preferences over students, students rate houses similarly, and quotas are exactly met. These assumptions are key to providing simpler bounds, and they certainly are valid in some matching markets; however relaxing these assumptions would broaden the applicability of the work greatly.

A Existence Proof
A.1 General case: Local maxima of Φ(µ) are two-sided exchange-stable To prove Theorem 2, we first prove a technical lemma (Lemma 1), from which the theorem follows immediately. The analysis is straightforward and draws its key ideas from the work of [4], which considers only a one-sided market rather than the two-sided market considered here.
Proof. (Lemma 1) We begin by calculating the difference in the potential function for a swap matching using (3): Expanding and canceling like terms, we have which becomes, due to the symmetry of the social network, Note that if t is a "hole", this becomes Now, consider a matching µ and a swap matching µ t s that satisfies (i) and (ii) from the lemma statement. Without loss of generality, assume that student s strictly improves. The other student could be either a "hole" or a real student that either improves or is indifferent to the swap. The other cases are symmetric. Define µ(s) = h, and µ(t) = g. The change in utility for student s is then Similarly, for student t, we have Adding the above inequalities, we obtain the following: On the house side of the market, we have := ∆ H as only houses h and g are affected by the swap and the change in their utilities is non-negative by assumption.
Thus, using (10) above, we have Φ(µ t s ) − Φ(µ) = ∆ H + δ s,t > 0. (12) Note that this holds even if t is a "hole." Proof. (Theorem 2) Let matching µ be a local maximum of Φ(µ). Assume, by way of contradiction, that µ is not two-sided exchange-stable. Lemma 1 shows that any swap matching that is acceptable to all parties (i.e. satisfies conditions (i) and (ii)) strictly increases Φ(µ). But this contradicts the assumption that µ is a local maximum. Thus, µ must be two-sided exchange-stable.
As the number of matches is finite, the global maximum of the potential function must be two-sided exchange-stable, and, therefore, a two-sided exchange stable matching will always exist.
A.2 Specific case: Local maxima of W (µ) are two-sided exchange-stable In this specific case, we assume that house quotas are exactly met (i.e., there are no vacancies or "holes") and that all students rate houses according to the same rules (i.e., D s h = D t h ∀ s = t).
Proof. (Lemma 3) Consider a matching µ and a swap matching µ t s that satisfies (i) and (ii) from the lemma statement. Note that due to the assumption that the house quotas are all met, the swap must be between two students, not a student and a "hole." Without loss of generality, assume that student s strictly improves. The other cases are symmetric. Define µ(s) = h, and µ(t) = g. The change in utility for student s is then Similarly, for student t, we have Adding the above inequalities, we obtain the following: Continuing, the total change in utility for all students is: w(x, t) > 0 where line (13) comes from the fact that we assume the social network graph is symmetric.
On the house side of the market, we have := ∆ H as only houses h and g are affected by the swap and the change in their utilities is non-negative by assumption. Thus, the total social welfare strictly increases: Using Lemma 3 it is now easy to complete the proof of Theorem 4.
Proof. (Theorem 4) Let matching µ be a local maximum of W (µ). Lemma 3 shows that any swap matching that is acceptable to all parties (i.e. satisfies conditions (i) and (ii)) strictly increases the total social welfare. But this contradicts the assumption that µ is a local maximum. Thus, µ must be stable.

B Proofs of PoA Theorems
We note that these proofs hold for the one-sided market; i.e., when U h (µ) = 0 ∀h ∈ H, where the quotas for the houses are exactly satisfied; i.e., there are no "holes," and students value houses according to the same rules; i.e., D s h = D t h ∀ s = t, h ∈ H. Also note that for ease of notation, we use E instead of |E| to represent the total edge weight of the graph in this appendix.

B.1 Proof of Theorem 5
Throughout the proof we assume that the houses are ordered: i.e., if g < h then D g < D h . An important tool that we use throughout the proof is a rephrasing of the definition of exchange stability in the one-sided market case in terms of a function α as follows.
Definition 4. Let α µ (s, g) be a function representing the benefit a student s gains by moving to house g under matching µ: Notice that using the definition above, given a specific swap matching µ t s where t ∈ µ(g), we can calculate the difference in utility for the involved student s as t). The definition of α also provides a useful new phrasing of the definition of exchange stability, which is equivalent to that of Definition 3 when the market is one-sided, i.e, when U h (µ) = 0 ∀h ∈ H. Note that we are only considering the Price of Anarchy for the one-sided market here -we plan to generalize these results for the two-sided case in future work.

Definition 5.
A matching µ is exchange stable (ES) in the one-sided (studentsonly) housing assignment market if and only if for all pairs of students s ∈ µ(h) and t ∈ µ(g), at least one of the following conditions holds: Condition 1: s doesn't want to swap, i.e., α µ (s, g) < w(s, t).
Using the above rephrasing of the definition of exchange stability, we now continue with the proof of Theorem 5. In order to prove an upper bound on the price of anarchy, we prove a lower bound on γ m (µ) when µ is stable. To prove this lower bound, we first prove an upper bound on the number of cross edges (E hg = E gh ) in the following lemma.
Lemma 7. Let w(s, t) ∈ {0, 1} for all students s, t and let q h ≥ 2, D h ∈ Z + ∪{0} for all h. Let q h = q for all h and/or D h = D for all h. If a matching µ is stable, then for all houses h and g, Proof. Using the conditions of stability from Definition 5 and Lemmas 11 and 12 as summarized below and proved in Appendix C, we have Case 1: If there exists s ∈ µ(h) such that α µ (s, g) > 1 then, by Lemma 11, if µ is stable it follows that Case 2: If there exists t ∈ µ(g) such that α µ (t, h) > 1 then, by Lemma 11, if µ is stable it follows that Case 3: If there does not exist s ∈ µ(h) such that α µ (s, g) > 1 and there does not exist t ∈ µ(g) such that α µ (t, h) > 1 then, by Lemma 12, if µ is stable it follows that Given any matching µ in the student-only market, it must fall into one of the three cases above. Thus, if µ is stable, it follows that one of the three bounds above holds. Because the edges are undirected, E hg = E gh , we can combine the three bounds to conclude that if µ is stable, Next, we use the above to prove a lower bound on γ m (µ). Proof.
where we have used the assumption that the houses are ordered in line (17).
Solving for E in (µ) gives Thus, Note that the above bound is only useful when the numerator is positive; otherwise, the bound becomes negative. However, it is immediate to see that γ m (µ) ≥ 0 always, as E in (µ) and E are non-negative, which completes the proof.
Finally, we can complete the proof of Theorem 5 using the above lemmas. There are two cases to consider, depending on the value of E : Plugging the bound from Lemma 8 into (6) gives Using Lemma 13 from the Appendix to substitute for h∈H q h D h is then enough to complete the proof in this case, after some algebra using the fact that γ * m ≤ 1.
In this case, Lemma 8 states that γ m (µ) ≥ 0. Using this bound and plugging into (6) gives Note that Q > 0 as long as E > 0 because we are given that E ≤ g<h q h (D h − D g ) in this case. Further, note that the case of E = 0 is trivial because all matchings have the same welfare and so the price of anarchy is 1. Using Combining (18) and (19) and again using Lemma 13 from the appendix is then enough to complete the proof in this case, after some algebra.
One final remark about this proof is that in the special case of D h = 0 a tighter bound holds. Specifically, the price of anarchy is bounded by (2m−1)γ * m in this case.

B.2 Proof of Theorem 6
The proof of Theorem 6 follows the same structure as the proof of Theorem 5, with a few added complexities that cause the bound to become weaker.
To begin, we again derive a bound on the cross-edges.
Because the edges are undirected, E hg = E gh , we can combine the three bounds to conclude that, if µ is stable, Next, we use the above to prove a lower bound on γ m (µ).
where line (20) follows from the assumption that the houses are ordered.
Solving for E in (µ) gives and thus This bound is only relevant when E > g>h q h (D h − D g ) + m 2 q max w max . Otherwise, the bound becomes negative, in which case we use the fact that γ m (µ) ≥ 0 always, as E in (µ) and E are non-negative.
Finally, we can complete the proof of Theorem 6 using the lemmas above. There are two cases to consider, depending on the value of E.
Case 1: E > g<h q h (D h − D g ) + m 2 q max w max Plugging the bound from Lemma 10 into (6) gives Using Lemma 13 to substitute for h∈H q h D h , the bound becomes, after some algebra, Using E ≥ g<h q h (D h − D g ) + m 2 q max w max , we have, after some algebra, 2 q max w max In this case, Lemma 10 states that γ m (µ) ≥ 0. Using this bound and plugging into (6), we have and so the price of anarchy becomes, again using Lemma 13, We can combine the two cases into one (looser) bound,

C Technical Lemmas
This appendix includes the lemmas used in the proofs of Theorems 5 and 6.
Lemma 11. Let w(s, t) ∈ {0, 1} for all students s, t and let D h ∈ Z + ∪ {0} for all h. Let µ be a stable matching. If there exists a student s ∈ µ(h) such that α µ (s, g) > 1 for some other house g, then E gh ≤ q g (D g − D h ) + 2E gg .
Proof. Since µ is stable, then for all t ∈ µ(g), (s, t) must satisfy at least one of the three conditions stated in the definition of exchange stability (Definition 5). However, for all t ∈ µ(g), α µ (s, g) > 1 ≥ w(s, t).
Since D h , w(s, t) ∈ Z + ∪ {0} we have that α µ (t, h) ∈ Z + ∪ {0}, and so Summing over all t ∈ µ(g) gives Using the definition of α, we have Simplifying the above yields from which the desired bound follows.
Lemma 12. Let w(s, t) ∈ {0, 1} for all students s, t, and let D h ∈ Z + ∪ {0} for all houses h. Let µ be a stable matching and let q h = q ≥ 2 and/or D h = D ∈ Z + ∪ {0} for all h. If (i) there does not exist an s ∈ µ(h) such that α µ (s, g) > 1 and (ii) there does not exists a ∈ µ(g) such that α µ (t, h) > 1, then Proof. It follows from the assumptions in the theorem statement that the students in houses h and g can be partitioned into 6 sets based on their house and α values (either 1, 0, or negative), as shown in Figure 6. Let S 0 , S 1 , and S −1 denote the set of students in house h such that α µ (s, g) = 0, α µ (s, g) = 1, and α µ (s, g) ≤ −1 respectively. For convenience, we use the same notation for the set and the number of students in the set, e.g., |S 1 | = S 1 The same conventions apply to the T variables and students in house g. Two sets are connected with a black line in Figure 6 if all students in one set must be connected to all students in the other set. These connections follow from the conditions of stability in Definition 5. This gives us 3 constraints: These constraints give us a lower bound on the edges between houses h and g.
To prove the theorem, we want to find an upper bound on the cross edges, E hg , so we relate the edges in the graph to the sum of the α values using the definition of the α function.
Since the students in each house are partitioned by their α values, we can bound this sum as: Combining (22) and (23) gives To continue, we need to find an upper bound on the quantity S 1 − S −1 . To do this, we start by lower bounding E gg . 2E gg = t∈µ(g) x∈µ(g)

w(t, x)
Recalling the definition of α in (14) gives Combining the previous two equations yields Using inequalities (21) and (23) gives We can now use the above to find an upper bound on S 1 − S −1 . To do this, we relate the left hand side of the above inequality to S 1 − S −1 .
Specifically, let f (S 1 , S 0 , S −1 , T 1 , T 0 , T −1 ) = S 1 T 1 + S 1 T 0 + S 0 T 1 − T 1 + T −1 − (S 1 − S −1 ). It is possible to show using elementary techniques that this function is non-negative, and thus that We omit the details for brevity. Note, however that the inequality in (26) holds only for the case where q h = q for all h ∈ H. In the case where the quotas are not equal but D h = D for all h ∈ H, the proof technique differs slightly, but still yields S 1 − S −1 ≤ 2E gg , from which the result follows. Finally, combining (25) and (26) gives To complete the proof we now plug the above into (24) to get E hg ≤q h (D h − D g ) + 2E hh + 2E gg + q g (D g − D h ) ≤ max(q h (D h − D g ), q g (D g − D h )) + 2(E hh + E gg ).
where the final step follows from noting that at most one of D h −D g and D g −D h is strictly positive.
Proof. Without loss of generality assume the houses are ordered so that if g < h, then D g < D h . The following inequalities hold simply because q h , q g , D h , D g are all non-negative values.
The remaining lemmas parallel the above lemmas, but are used for proving Theorem 6, and thus apply in more general settings.

Lemma 14.
Let w(s, t) ∈ R + ∪ {0} for all students s, t, and let D h ∈ R + ∪ {0} for all h ∈ H. Consider a stable matching µ. If there exists an s ∈ µ(h) such that α µ (s, g) > w(s, t) for all t ∈ µ(g), then E gh < q g (D g −D h )+2E gg +q g w max .
Proof. By assumption, there exists a student in h that strictly wants to swap with any student in house g. It then follows from the stability of µ that all students in g must strictly oppose the swap (i.e., α µ (t, h) < w(s, t)). This gives w(t, x) < w(s, t) < w max , for all t ∈ µ(g). Summing the above equation over t ∈ µ(g) then yields q g (D h − D g ) + E gh − 2E gg < q g w max Rearranging the previous equation completes the proof.
Lemma 15. Let w(s, t) ∈ R + ∪ {0} for all students s, t, and let D h ∈ R + ∪ {0} for all h ∈ H. Consider a stable matching µ. If (i) there does not exist an s ∈ µ(h) such that α µ (s, g) > w(s, t) for all t ∈ µ(g) and (ii) there does not exist t ∈ µ(g) such that α µ (t, h) > w(s, t) for all s ∈ µ(h), then w(t, x) ≤ w(s, t) ∀s ∈ µ(h) To complete the proof we simply sum these two bounds using w(s, t) ≤ w max and E gh = E hg .