Agency theory meets matching theory

The theory of incentives and matching theory can complement each other. In particular, matching theory can be a tool for analyzing optimal incentive contracts within a general equilibrium framework. We propose several models that study the endogenous payo¤s of principals and agents as a function of the characteristics of all the market participants, as well as the joint attributes of the principal-agent pairs that partner in equilibrium. Moreover, considering each principal-agent relationship as part of a market may strongly inuence our assessment of how the characteristics of the principal and the agent a¤ect the optimal incentive contract. Finally, we discuss the e¤ect of the existence of moral hazard on the nature of the matching between principals and agents that we may observe at equilibrium, compared to the matching that would happen if incentive concerns were absent. JEL Classication numbers: D86, D03, C78. Keywords: incentives, contracts, matching, moral hazard. This paper corresponds to the Presidential Address delivered by the second author at the 44th Simposio de la Asociación Española de Economía in Alicante. We gratefully acknowledge comments received from Kaniska Dam. We also acknowledge nancial support from the Ministerio de Ciencia y Tecnología and FEDER (PGC2018-094348-B-I00), Generalitat de Catalunya (2017 SGR 711 and ICREA Academia), and Severo Ochoa Programme (SEV-2015-0563). The authors are fellows of CESifo and MOVE. yUniversitat Autònoma de Barcelona and Barcelona GSE. Email: ines.macho@uab.cat zUniversitat Autònoma de Barcelona and Barcelona GSE. Email: david.perez@uab.cat


Introduction
The optimal design of incentives is a prevalent question in economic and social relationships. In labor contracts, a worker's decision about his e¤ort is often not contractible and his employer may need to provide him with incentives to work. A manager may have an inclination not to maximize the …rm's pro…ts but to use some of the company resources to obtain private bene…ts. An insurance company may fear that insured people are less cautious with the insured property than when they face the whole cost of the damage.
These incentive problems appear because one party in the relationship (the "agent") takes a decision that a¤ects another party (the "principal"), and they are usually referred to as "moral hazard"or "agency"problems.
The concept of moral hazard was introduced by Arrow (1963) in the economics literature to depict a market failure that insurance companies had identi…ed long before. Ten years later, Ross (1973) formalized the principal-agent relationship as a program where the principal maximizes her expected utility, taking into account not only that the agent has to accept the o¤er but also that he can choose the e¤ort or decision that is best for him, given the contract. Pioneer papers in this topic include Mirrless (1974Mirrless ( , 1975, Harris and Raviv (1979) and Holmström (1979). Since that time, the importance and applications of the theory of incentives, or the agency theory in general, has been tremendous in Economics, Management, and other social sciences. 1 The theory of incentives studies the best contract (for addressing moral hazard in the most e¢ cient way) for a given relationship, where this relationship is in general considered in isolation from any other. That is, it looks at a given principal and a given agent (or possibly several principals and/or agents) that intend to establish a relationship, and characterizes the optimal contract that the principal will propose, among the ones that the agent is ready to accept and considering that the agent will exert the e¤ort that is best for him given the contract.
Some principal-agent relationships are indeed isolated partnerships. This is the case, for example, for the regulatory relationship between a government and an established monopoly. Here we can see that the government cannot look for an alternative …rm to provide the service and the …rm cannot look for an alternative government. However, 1 Some textbooks on the theory of incentives include Macho-Stadler and Pérez-Castrillo (1997), Bolton and Dewatripont (2005), and La¤ont and Martimort (2002). most relationships take place in "markets": a principal is typically not forced to hire a particular agent but she can possibly partner with any agent present in the market, and similarly for the agents. For example, an investor is not compelled to invest in a certain start-up and a start-up is not forced to receive …nancing from a speci…c investor; any investor and any start-up will look for who to partner and sign a contract with. This means that not only is the contract in each relationship endogenous but so is the identity of the partners that establish relationships.
Simultaneously to the development of the theory of incentives, Gale and Shapley (1962) and Shapley and Shubik (1972) pioneered the development of the two-sided "matching theory,"which became (in the words of Robert Aumann, see Roth and Sotomayor 1990) "one of the outstanding success stories of the theory of games."Two-sided matching theory studies markets where players belong, from the outset, to one of two disjoint sets. The questions this theory addresses refer to the partnerships that are formed at the equilibrium and, in some models, the terms of the transfers between partners. One relevant advantage of matching theory is that it can successfully accommodate situations with heterogeneous players in either or both sides of the market.
Some recent papers 2 emphasize that the two theories, that is, the theory of incentives and matching theory, can complement each other. In particular, matching theory can be used as a tool to study incentive contracts in a general equilibrium scenario that allows the consideration of discrete as well as continuous sets of heterogeneous principals and heterogeneous agents.
The analysis of optimal incentive contracts within a general equilibrium framework allows new questions to be addressed such as the equilibrium payo¤s of principals and also the endogenous agents'utility as a function of the characteristics of all the market participants; and the joint characteristics of the principal-agent pairs that decide to partner. Moreover, considering each principal-agent relationship not in isolation but as part of a market may strongly in ‡uence, and even reverse, the results on the e¤ects of the characteristics of the principal and the agent on the optimal incentive contract. Indeed, the comparative static exercises performed in a principal-agent model to understand the e¤ect of, say, the improvement of an agent's characteristic on the terms of the contract do not take into account that such an improvement may lead the agent to be matched, at equilibrium, to a di¤erent principal. Hence, the optimal contract is not only a¤ected by the change in the agent's characteristic but also by the di¤erence between the characteristics of the new versus the old principal.
Moreover, from a matching point of view, the existence of moral hazard problems may have a signi…cant e¤ect on the type of matching between principals and agents that we may observe at equilibrium, compared to the matching that would happen if incentive problems were absent. Under moral hazard, the gains that the participants get when they match are di¤erent, and that a¤ects the equilibrium outcome.
In this paper, we propose several models that address incentive problems in general equilibrium environments. As will be clear during the discussion, some models are simple versions from previous papers by several authors. Other models are original. They provide meaningful economic intuitions in relevant economic situations. Moreover, they allow us to foresee how to use incentive and matching theory together to address other questions.
Section 2 introduces the assignment game, which studies one-to-one two-sided matching environments where utility among the two participants in any partnership can be fully transferred. Section 3 introduces a situation where participants'utility functions are such that utility is fully transferable and characterizes the Pareto-optimal contracts in a partnership when there is symmetric information among participants and when there is moral hazard. Section 4 presents a (static) market where there is a set of heterogeneous principals and a set of heterogeneous agents. Several subsections characterize the equilibrium matching and contracts under contractible and non-contractible e¤ort, for various types of heterogeneity among the population of principals and agents. Section 5 presents two models that illustrate how to extend the method to environments where the partnerships involve more than two participants. Section 6 introduces and analyzes a dynamic model where a set of principals and a set of agents meet every period. Finally, section 7 concludes with a discussion of the literature that studies models where the utility is not fully transferable plus of the literature that proposes methods to empirically analyze incentive contracts in market environments.

The assignment market
The assignment market (Shapley and Shubik 1972) is a representation of a two-sided market where each participant can participate at most in one transaction. There is a (…nite) set of n heterogeneous principals, P = f1; 2; ::::; ng and a (…nite) set of m heterogeneous agents, A = f1; 2; ::::; mg. A principal might be an employer, a lender, or a landowner.
An agent might a worker, a borrower, or a tenant. Principals are denoted by i, i 0 , etc.
whereas agents are denoted by j, j 0 , etc. In the assignment game, each principal can hire at most one agent, and each agent can work for at most one principal. 3 In addition, in the assignment game the attributes or characteristics of the participants of both sides are public information (there are no frictions).
If principal i does not hire any agent in A, she obtains pro…t o i , which we normalize to zero: o i = 0. If agent j does not work for any principal in P , then he obtains an outside utility of U o j = U o . Thus, o i and U o j represent the value for principal i and agent j of staying unmatched. On the other hand, if principal i and agent j match, then they produce a joint surplus of S ij . Given the heterogeneity of principals and agents, the surplus S ij typically depends on the identity and the attributes of both the principal and the agent. An important assumption is that principal i and agent j can share S ij in any way they wish, that is, utility among them is fully transferable. Thus, any pro…le of payo¤s ( i ; U j ) such that i + U j S ij is feasible for the pair fi; jg. 4 The formal de…nition of a matching in the market fP; A; S; U o g is: fjg for any j 2 A, and 3 Several papers in the matching literature propose extensions of the assignment game by assuming that the participants from one side or from both sides of the market can form several partnerships. For many-to-one and many-to-many matching models, see Sattinger (1975), Kelso and Crawford (1982), and Sotomayor (1992) and (2007). 4 There is a very important literature that considers two-sided matching models where utility is impossible to transfer, in the sense that each partner in a pair obtains a certain level of pro…t or utility that cannot be transfered to the other partner. This model was proposed in the seminal paper of Gale and Shapley (1962), who formulated the stable matching problem for the (one-to-one) marriage and the (many-to-one) college admission markets. See also Roth and Sotomayor (1990) for an excellent introduction to matching models (with and without transferable utility).
(c) for any (i; j) 2 P A, (i) = j if and only if (j) = i.
We say that principal i (resp. agent j) is matched if (i) 2 A (resp. (j) 2 P ). If (i) = i or (j) = j, then we say that principal i or agent j are unmatched.
A feasible matching is optimal if it maximizes the gain of the whole set of players.
If we denote S jj U o the utility obtained by an unmatched agent, we can then de…ne an optimal matching as follows: In this market, an outcome consists of a feasible matching and a vector of feasible payo¤s (that is, pro…ts and utilities) for principals and agents. This vector describes how the joint surplus of any matched pair is shared among the partners.
De…nition 3 A feasible outcome ( ; ; U ) consists of a feasible matching , a vector of pro…t levels = ( i ) i2P , and a vector of utilities U = (U j ) j2A such that: In the market fP; A; S; U o g, the matching between principals and agents as well as the sharing of the surplus of any partnership are endogenous. Any principal or any agent can look for an alternative partner and can sign a di¤erent contract. Therefore, we will focus on those outcomes that are stable. Moreover, in the assignment game, stability, pairwise stability, and competitive equilibrium are equivalent concepts. In particular, it is easy to de…ne competitive equilibria in this market and show that an outcome is stable (or pairwise stable) if and only if it is a competitive equilibrium (Shapley and Shubik 1972).
In this paper, we will refer to stable outcomes as competitive equilibrium outcomes, or simply as equilibrium outcomes.
An equilibrium outcome is individually rational. Moreover, if the outcome is a competitive equilibrium, it is not possible for a principal and an agent (who are possibly not matched under that outcome) to form a partnership and share the surplus in such a way that they are both better o¤ under the new partnership than under the previous outcome.
We could say that an equilibrium outcome is "divorce-proof." Competitive equilibrium (or stability) is our main solution concept in this paper. Shapley and Shubik (1972) prove that equilibrium outcomes always exist in the assignment game. They also show the following results on the set of equilibrium outcomes, which will be useful in the following sections.
First, any matching which is part of an equilibrium outcome is necessarily optimal.
Moreover, any optimal matching is compatible with any equilibrium payo¤ vector. Therefore, the set of equilibrium outcomes can be regarded as the Cartesian product of the set of optimal matchings and a set of equilibrium payo¤s.
Proposition 1 (a) If ( ; ; U ) is an equilibrium outcome then is an optimal matching.
(b) Let ( ; ; U ) be an equilibrium outcome and 0 an optimal matching. Then ( 0 ; ; U ) is also an equilibrium outcome.
Proposition 1 is a crucial property because it allows the study of the characteristics of the equilibrium matchings by just analyzing the properties that make a matching optimal.
Proposition 1 also states that principals or agents have the same set of equilibrium payo¤s independently of the equilibrium matching. Moreover, it can be shown that, in the set of equilibrium payo¤s, there is a polarization of interests between the two sides of the market, that is, 0 if and only if U 0 U , for all equilibrium payo¤s ( ; U ) and ( 0 ; U 0 ). Thus, if principals are better o¤ in some equilibrium outcome than in another equilibrium outcome, then agents are better o¤ in the second than in the …rst outcome.
In fact, the set of equilibrium payo¤s is endowed with a complete lattice structure under each partial order, where one is the dual of the other. In particular, there exists one and only one maximal element and one and only one minimal element in each lattice. Due to the polarization of interests between principals and agents, the best (the maximal) outcome for the principals is the worst (the minimal) outcome for the agents, and vice versa. Formally, Proposition 2 In the set of equilibrium outcomes, there exist a unique principal-optimal payo¤ ( + ; U ) and a unique agent-optimal payo¤ ( ; U + ). Then, for any equilibrium outcome ( ; ; U ), + i i i and U + j U j U j for any i 2 P and j 2 A: In sections 4 to 6, we study equilibrium outcomes in several principal-agent markets. In any such market, when principal i and agent j establish a partnership (i.e., when principal i hires agent j) the surplus of the relationship S ij will be the result of the contract signed by the partners. To better understand the analysis developed in the next sections, it is useful to make two remarks.
First, we are going to use the assignment game as a tool to analyze the principalagent markets. To be able to apply the results obtained for the assignment game, the surplus must be transferable inside a partnership. For this reason, we are going to assume particular functions for the preferences of principals and agents: the principals will be risk neutral and the agents will have constant absolute risk-averse (CARA) preferences. We will discuss principal-agent markets where the surplus is not fully transferable in Section 7.
Second, all the contracts in an equilibrium outcome are Pareto optimal. The optimality of a contract between a principal and an agent in any equilibrium outcome is due to the possibility that the same pair can block the initial outcome with a di¤erent contract.
Therefore, before we move to the analysis of principal-agent markets, we address the characteristics of the Pareto-optimal contracts in any principal-agent relationship in the next section. We will recall the results under symmetric information among the participants as well as the optimal contracts in situations with moral hazard for the classic agency model.
3 Pareto-optimal contracts in a principal-agent relationship In this section, we study the Pareto-optimal contracts in any principal-agent relationship that can possibly take place. Given that we consider an isolated partnership, in this section we drop the subscript i and j for principals and agents. We can think of any such relationship as a principal hiring an agent to perform a task, which we refer to as e¤ort, e 2 E; in exchange for a wage, w. The …nal output of the relationship, x; depends on the e¤ort e that the agent devotes to the task and a random variable for which both participants have the same prior distribution.
We assume that the principal is risk neutral whereas the agent has CARA preferences (an exponential utility). Formally, an agent that receives salary w and exerts e¤ort e obtains a utility of: where r 0 is the coe¢ cient of absolute risk aversion. 5 Additionally, we assume that the cost of e¤ort v(e) takes a quadratic form: v(e) = 1 2 ve 2 .
Concerning the output x, we assume that it is linear in the e¤ort e and a random variable ": where 0, > 0, and N (0; 1). Thus, the expected output of the production process is + e.
Finally, we assume that the contract is linear in the realized output. That is, we restrict attention to linear wage schemes of the form w = F + sx, where F is a …xed payment and s is the share of the output that goes to the agent. 6 Given the characteristics of the model, it is convenient to express the utility of the agent as a function of the contract (F; s) and the e¤ort e in terms of the agent's certain equivalent income: 7 U (F; s; e) = CE (F; s; e) = F + s ( + e) 1 2 The Pareto-optimal contracts are the result of the principal maximizing her pro…ts subject to the agent obtaining a certain utility level (equivalently, we can maximize the utility of the agent subject to the principal attaining a certain level of pro…t). The utility 5 See, e.g., Macho-Stadler and Pérez-Castrillo (2018) for more details and discussion on the use of this model. 6 Linear contracts are generally not optimal (see Mirrlees 1975). However, Holmström and Milgrom (1987) show that the optimal contract is linear in the outcome if the agent chooses e¤orts continuously to control the drift vector of a Brownian motion process and he observes his acummulated performance before acting. This set-up is simple and has been extensively used to study many interesting questions. 7 See, e.g., Bolton and Dewatripont (2005) for the details of the calculation.
obtained by the agent in the market will be endogenous, but in this section we are going to denote it by U . We note that in general U will be di¤erent from U o ; which corresponds to the utility that the agent obtains if he does not sign any agreement with any principal.

Pareto-optimal contracts under symmetric information
If e¤ort is contractible, that is, under symmetric information, the optimal contract (F; s; e) is the solution to M ax where we have taken into account that the principal maximizes expected pro…t. The constraint PC is the agent's participation constraint, which ensures that he obtains at least U . It is easy to see that PC is binding and the …xed part of the sharing rule F is: The variable part of the contract s is the solution to: The principal's pro…t is decreasing in s, which gives the optimal, …rst-best sharing rule under symmetric information s SI = 0. Moreover, the …rst-order condition (FOC) with respect to e gives e SI = 1 v . Therefore, the optimal contract under symmetric information is: For any such contract, the joint surplus is which does not depend on U . An increase in one unit in the level of utility of the agent U translates into a decrease of exactly one unit in the pro…t of the principal . Therefore, the utility is fully transferable.

Pareto-optimal contracts under moral hazard
If e¤ort is not contractible then the agent will choose the e¤ort that maximizes his utility i.e., the ICC gives e = s v : Then, the principal maximizes the same program as before, but taking into account the ICC. The binding PC determines the …xed fee: and the principal maximizes f(1 s) ( + e) F g, that is, The FOC of this program leads to s M H = 1 1+rv 2 2 (0; 1] : Notice that s M H summarizes the standard conclusions of moral hazard problems: the power of the incentives is decreasing in the cost of the e¤ort v and in the variance of the outcome 2 (as long as r > 0): In addition, it is decreasing in the agent's risk aversion (measured by r). Since a higher s M H translates into a higher expected output through the ICC, the previous expression re ‡ects the trade-o¤ between e¢ ciency (optimal risk-sharing would require s M H = s SI = 0) and incentives. Therefore, the optimal contract under moral hazard is and leads to the e¤ort The joint surplus under moral hazard is, after some easy calculations, Again, the surplus is independent of U . The CARA assumption implies that utility is transferable because the principal can give or take away utility directly through the …xed part of the contract F .

Contracts in a principal-agent market
We now go back to consider a principal-agent market. The set of heterogeneous, riskneutral principals is P = f1; 2; ::::; ng and the set of heterogeneous agents, with a CARA utility function, is A = f1; 2; ::::; mg. In this section, we consider principals that can be heterogeneous along several characteristics: in the value they provide to the project, the volatility of their project, etc. Similarly, agents can be di¤erent in the value they contribute, their risk aversion, etc. Each participant knows the characteristics of all the principals and agents. We address questions such us the nature of the endogenous matching between principals and agents (who is hired by whom), the e¤ect of the moral hazard on the nature of the matching, and the endogenous level of pro…t and utility that the participants obtain as a function of their characteristic. Also, we note that some of the conclusions obtained in comparative static exercises in a pre-determined principal-agent relationship may be modi…ed when we consider that the relationship is not isolated but is part of a principal-agent market.
In general, the participants can be heterogeneous in various characteristics. First, agents can di¤er in their degree of risk aversion and in their cost of exerting e¤ort, so agent j's utility function is Second, both principals and agents can have a heterogeneous in ‡uence on the output: depending on the identity of the agent and/or the principal, the average output (for a given e¤ort) can be higher or lower and the output can be more or less volatile. Thus, the output that is obtained in a partnership between principal i and agent j when the agent exerts e¤ort e is: where ij 0, ij > 0, and N (0; 1).
The total surplus obtained in a partnership depends on the principal's and the agent's characteristics. Suppose that we consider characteristics c i and c j , and let us denote the Then, the matching is PAM if "good" principals are matched with "good" agents and "bad" principals are matched with "bad" agents. On the other hand, if the matching is NAM, "good"principals are matched with "bad"agents and "bad"principals are matched with "good"agents. 8 From the analysis of Section 2 we know that the equilibrium matching is PAM if and only if PAM is an optimal matching. Moreover, since Becker (1973), we also know that in markets with a transferable utility and where agents of each side of the market di¤er in a one-dimensional characteristic, a su¢ cient condition for PAM to be an optimal matching is that there is type-type complementarity in the production of surplus. Similarly, a su¢ cient condition for NAM is type-type substitutability. If the surplus function is di¤erentiable (as is the case in our model) then a su¢ cient condition for PAM (NAM) is that the crosspartial derivative of the surplus function with respect to the characteristic of the principal and the characteristic of the agent is positive (negative).
The …rst subsection will discuss the characteristics of the equilibrium outcomes under symmetric information in several scenarios concerning the heterogeneity of principals and agents. The next subsection will analyze the same scenarios when moral hazard is present in each of the partnerships.

A principal-agent market under symmetric information
The …rst four examples that we propose correspond to scenarios where principals and agents are heterogeneous with respect to characteristics that we can consider "vertical characteristics,"in the sense that we can rank, say, the principals from best to worst. For instance, the variance of the project is a vertical characteristic: having a lower variance cannot be bad. In the last example, we introduce a "horizontal characteristic." Since the examples share some features, we will discuss the …rst ones more carefully. 8 Notice that if c i and c j are characteristics that are both detrimental for total surplus, then the same conclusion holds: in the case of PAM, "worst" principals are matched with "worst" agents (hence, the "best" principals are matched with the "best" agents). However, if one of the characteristics increases while the other decreases the total surplus then the reverse happens: if PAM, "good" principals are matched with "bad" agents and "bad" principals are matched with "good" agents; if NAM, the better the principal, the better the agent she is matched with.

Heterogeneous principals in the variance of their project and heterogeneous agents in their degree of risk aversion
Consider a situation where principals di¤er in the variance of their project whereas agents di¤er in their degree of risk aversion. Each side of the market is similar in any other respect. Formally, v j = v, 2 ij = 2 i , and ij = for all i 2 P and j 2 A. Then, and trivially: Given that the cross-partial derivative of the surplus function under symmetric information is zero, any matching is an equilibrium matching.
In this scenario, any principal fully ensures the agent she hires, so principals do not care about the risk aversion of the agent they are matched with; hence, also the agents do not care about the variance of the principals'project. 9 In particular, at equilibrium, all the matched principals obtain the same level of pro…ts and all the matched agents obtain the same utility level. Indeed, in an outcome where U j > U j 0 , the principal (j) and the agent j 0 could deviate because ; r j 0 , so (j) and j 0 together can produce more than the sum of the surplus they obtain at the outcome. And a similar reasoning holds if i > i 0 for some principals i and i 0 .

Heterogeneous principals in the variance of their project and heterogeneous agents in their ability
The implications of the analysis are similar if we consider a market where (principals di¤er in the variance of their project and) agents are not heterogenous in terms of risk aversion but they are in terms of their cost of e¤ort: r j = r for all j 2 A and v j can di¤er 9 In this paper, we keep a common framework where principals are risk-neutral. There is an extensive literature that examines the sorting patterns in a two-sided matching markets when principals are also risk-averse and the main objective of the partnership is to share risks. In these environments, NAM tend to arise: a highly risk-averse principal looks very much for insurance and a very risk-tolerant agent can provide it. For a general analysis of this question, see, for instance, Legros and Newman (2007) and Chiappori and Reny (2016). among agents. The parameter v j can be thought of as the inverse of the ability of the agent. Then, Also, in this case: and any matching is optimal.
As in subsection 4:1:1, the variance of the principal does not matter in the expression of Hence, all matched principals will obtain the same pro…t level at equilibrium. However, this is not true for the agents. As is intuitive, a matched agent with higher ability (that is, a lower v j ) enables obtainment of higher surplus, hence, at equilibrium he obtains a higher utility level than an agent with lower ability. To check this property, consider

Heterogeneity in the variance that principals and agents induce in the project
We now consider a situation where both the principal and the agent in ‡uence the volatility of the project. The in ‡uence is heterogenous among principals and among agents, although the participants of each side of the market are homogeneous in any other attribute. We can think of a market where principals may have more or less risky projects, and agents may be more or less precise in their job. Formally, r j = r, v j = v, and ij = for all i 2 P and j 2 A. Moreover, assume for simplicity 2 ij = 2 i + 2 j for all i 2 P and j 2 A. Then again, and any matching is e¢ cient (Li et al. 2013). 10 Therefore, also in this case, any matching can emerge in an equilibrium outcome under symmetric information. 10 Li et al. (2013) prove that this is also true if principals are risk-averse with the same degree of risk aversion.

Heterogeneity in the mean output that principals and agents induce in the project
Assume a scenario where the heterogeneity among principals and among agents is due to the di¤erent in ‡uences that they have in the mean of the output. That is, we assume r j = r, v j = v, and 2 ij = 2 for all i 2 P and j 2 A, and ij = f ( i ; j ), with @f @ i > 0 and @f @ j > 0. We can think of i (resp. j ) as some characteristic of the principal (resp. the agent) that has a positive in ‡uence on the output (productivity and ability, for example).
In this case, and As we know, the nature of the equilibrium matching depends on the supermodularity of the production function. Hence, if then any matching is an equilibrium matching. If e.g., for f ( i ; j ) = i j ; then the equilibrium matching is PAM. On the other hand, if @ j @ i < 0; e.g., for f ( i ; j ) = p i j ; then the equilibrium matching is NAM.

Heterogeneity in the "type" of principals and agents
Consider a situation where principals and agents have di¤erent "types" and that the e¢ ciency of the production depends on the di¤erence between these types. For example, in Banal-Estañol et al. (2018) we study a market between …rms and academics where the type is how applied their most preferred research is. We denote principal i's type by y i and agent j's type by y j and both populations are homogeneous in any other dimension.
Assume that the distance between the types of the two members of a match determines the mean of the result: ij = 0 + (y j y i ) 2 ; where can be positive (heterogeneity in types helps in the production process), or negative (production is larger if types are similar).
In this environment, the joint surplus of (i; j) is: Then, it is immediate that and the matching will be PAM (resp. NAM) if < 0 (resp. > 0).

A principal-agent market under moral hazard
In this subsection, we analyze the consequences of the moral hazard problem in several aspects of the relationships by studying the same markets as above but when the e¤ort is not veri…able.

Heterogeneous principals in the variance of their project and heterogeneous agents in their degree of risk aversion
When principals are heterogeneous in the risk of the project, 2 ij = 2 i ; and agents are heterogeneous in their degree of risk aversion, r j ; the joint surplus when the partnerships are subject to moral hazard is: Contrary to the result in the symmetric information environment both, the volatility of the project and the agent's degree of risk aversion have a negative impact on the joint surplus. A "good" principal is one with a low-volatility project and a "good" agent has a low degree of risk aversion. Moreover: We write the main implication in the following proposition (see  We now discuss how considering that principal-agent relationships are not necessarily isolated but part of a market may modify some of the implications of the comparative statics exercises that are often conducted in principal-agent models. 11 One robust implication from this model is that there exists a negative relation between risk and incentives: the more volatile the project, and the more risk-averse the agent, the lower the power of the incentives in a moral hazard situation. In particular, in the CARA model that we analyze, the share s M H = 1 1+rv 2 is decreasing in both 2 and r. Let us now take into account that there is an endogenous matching between principals and agents (see Serfes 2005 and 2008 for a more extensive discussion). Denote r j ( 2 i ) = r (i) the endogenous relationship in the matching between the volatility of the project and the agent's level of risk aversion. If PAM, then r 0 j ( 2 i ) > 0 and more volatile projects are carried out by more risk-averse agents. If NAM, then r 0 j ( 2 i ) < 0 and more volatile projects are carried out by less risk-averse agents.
The power of incentives as a function of the volatility of the project is: If the matching is PAM, then r j ( 2 i )v 2 i increases with 2 i , which implies that the incentives have less power as 2 i increases. This result is similar to the comparative statics result in a model where the principal-agent match is given. However, if the matching is NAM, then r j ( 2 i )v 2 i can be increasing, decreasing, or it may have any other shape, depending on the distribution of the attributes of the population of principals and agents.
Finally, it is also interesting to discuss the changes in the equilibrium pro…t and utility level as a function of the characteristics. Remember that under symmetric information (see subsection 4:1:1) all matched principals obtain the same pro…t and all the matched agents get the same utility level. However, this is no longer true under moral hazard. The higher the variance of her project, the lower the pro…t that a principal obtains. Similarly, the higher the agent's risk aversion, the lower his equilibrium utility level. 12 The fact that the "bargaining power" of principals and agents is endogenous in the market has important implications for the empirical analysis. For instance, we have seen that in a PAM, an agent's bonus is decreasing in his degree of risk aversion. Following the discussion in Serfes (2008), in an isolated principal-agent relationship where the principals have the bargaining power, bonuses and …xed salaries should be negatively correlated.
Hence, a lower bonus should imply a higher …xed salary. However, in the equilibrium in a market, higher risk aversion also implies a lower level of utility and the negative correlation between …xed and variable payment may no longer hold. As an example, Lafontaine (1992) …nds no systematic negative or positive correlation between royalties and franchise fees in franchise contracts.

Heterogeneous principals in the variance of their project and heterogeneous agents in their ability
The agents'cost parameter v plays a role similar to the agents'degree of risk aversion r in the optimal contract. However, the analysis when agents are heterogeneous in terms of 12 In an environment with a continuous of principals and agents, ability (in our model, in terms of their cost parameter) is simpler (see Li and Ueda 2009).
When r j = r, 2 ij = 2 i , and ij = for all i 2 P and j 2 A, then Therefore: Proposition 4 Under moral hazard, if principals are heterogeneous in the risk of the project, 2 i ; and agents are heterogeneous in their cost parameter, v j ; then the equilibrium matching is PAM.
Proposition 4 states that we should expect more able agents (those with lower costs) matched with …rms whose projects have lower variance. Li and Ueda (2009) use the proposition to provide an explanation for the fact that safer …rms receive funding from more reputable venture capitalists (see also Sørensen 2006), a conclusion that cannot be derived in a model where moral hazard is not present.
In this model, where principals are heterogeneous in the variance of their project and agents are heterogeneous in their ability, we illustrate now how to study the sensitivity of a principal's (resp. an agent's) payo¤ to her (resp. his) own characteristic. This exercise is easier in a model where the set of principals and the set of agents are continuous because, in contrast to the discrete assignment game, the scheme of equilibrium payo¤s is unique. 13 Moreover, to discuss the sensitivity in terms of a "positive"characteristic: denote c i and c j the characteristic of principal i and agent j ; respectively, and suppose that 2 i = 2 c i and v j = v c j . Thus, the higher the parameter c i or c j , the better the principal or the agent.
As we mentioned in subsection 4:1:2, a principal's pro…t is independent of her type under symmetric information, that is, 13 We could also use the discrete assignment game and focus in one of the two extremes of the complete lattice of the set of equilibrium payo¤s. Demange (1982), Leonard (1983), or Lemma 8.15 in Roth and Sotomayor (1990) show how to compute the precise levels of principals'pro…ts and agents'utilities in the principal-optimal payo¤ and in the agent-optimal payo¤.
However, an agent with higher ability obtains a higher level of utility: 14 Similarly, under moral hazard, we obtain: Therefore, and, in this model, while the principal's characteristic is irrelevant under symmetric information, it has a strong in ‡uence on the principal's pro…t under moral hazard. On the other hand, the (positive) e¤ect of the characteristic in agent's utility is stronger under symmetric than under moral hazard. This illustrates that the asymmetry of information is often detrimental not only to the principal's pro…t but also to the agent's equilibrium utility level. 14 We can compute the change in the utility level of the agent as a function of v as follows. Consider agent j and agent j 0 such that v j 0 = v j + . Denote i 0 = (j 0 ). In an equilibrium, principal i 0 and agent j do not have an incentive to deviate because S SI 2 Dividing both sides of the equation by and taking the limit when goes to zero, we obtain @ SI Uj @vj But we can take the other sense of the inequality as well, hence, We can use a similar procedure for the following expressions.

Heterogeneity in the variance that principals and agents induce in the project
When the heterogeneity among principals and among agents derive from the in ‡uence that both have on the volatility of the project (and assuming 2 ij = 2 i + 2 j ), then Therefore, and Proposition 5 follows. . A higher 2 i , that is, a riskier project, weakens the incentives that the agent receives: @s M H @ 2 i < 0. This happens because the cost of the bonus (versus paying a …xed fee) increases with the volatility of the output. More importantly for the nature of the matching, given that @ 2 s M H @ 2 i @ 2 j > 0, the e¤ect is less negative for agents with high j , that is, for less precise agents. Therefore, e¢ ciency (or optimality) requires that risky projects are carried out by less precise agents. 15 15 In quite a di¤erent model, Li et al. (2013) also …nd that moral hazard pushes toward PAM in terms of risk. They study the equilibrium matching between principals and agents who are all risk-averse and heterogeneous in their degree of risk aversion. Moreover, the agents exert unveri…able e¤orts to increase the mean of the output and to reduce its volatility. Compared to the environment without moral hazard, the agency problem in risk reduction induces more PAM.

Heterogeneity in the mean output that principals and agents induce in the project
We are now in a market where the characteristics of principal and agent in ‡uence the average outcome of the product: ij = f ( i ; j ). In this case, Therefore, in this environment (although the surplus is lower under moral hazard than under symmetric information) the nature of the equilibrium matching is not in ‡uenced by moral hazard: 16 there is PAM if 17 and there is NAM if 18 As a consequence of moral hazard, there is less surplus to share, but the incremental surplus due to a better principal (in terms of i ) or a better agent (in terms of j ) are the same in symmetric and asymmetric information. Hence, the di¤erence in the equilibrium payo¤ between two matched principals (resp. agents) of di¤erent characteristics is the same in both environments.

Heterogeneity in the "type" of principals and agents
When principals and agents are heterogeneous in their type, and the distance between types determines the mean so that ij = + (y j y i ) 2 , then the moral hazard problem is not related to the types and S M H (y i ; y j ) = + (y j y i ) 2 + 1 2v 1 1 + rv 2 : 16 The property that the nature of the matching is not in ‡uenced by moral hazard does not hold if not only the agent but also the principal is subject to moral hazard. As Ghatak and Karaivanov (2014) show, the double moral hazard induces a certain substitutability between the types that makes NAM more likely (see also Chakraborty Baranchuk et al. 2011). 18 In his analysis of the e¤ect of …rms'market power on managerial incentives, Dam (2015) …nds that both PAM and NAM are possible, depending on whether …rms with higher or lower market power bene…t more from managerial actions.
Then, it is immediate that and, as under symmetric information, the matching will be positive (resp. negative) assortative if < 0 (resp. > 0). Thus, also in this case, the nature of the matching is independent of the moral hazard problem. Similar types will form partnerships. 19 5 Beyond two-sided one-to-one partnerships The environments that we have discussed in the previous section involve two-party partnerships and use the two-sided one-to-one assignment game as a tool. The analysis of more general environments where more than two parties can form partnerships can be complex and the existence of equilibrium or stable outcomes may be problematic. 20 However, some of the tools that we have used, and other tools provided in the literature, can still be useful for particular environments. In this section, we present two examples.

A simple owner-principal-agent market
Suppose an environment where production requires the partnership between three parties: an owner (a landlord who owns the land, an owner of the permit to have a business, or a shareholder who provides the …nancial resources), a principal (who brings or run a project), and an agent (who works on the project). Thus, this market corresponds to a "three-sided"(instead of two-sided) one-to-one game.
To make the model very simple, assume all the owners are identical and risk neutral.
Finally, the number of owners is larger than the number of principals and than the number of agents. Moreover, the principals'pro…t, agents'utility, and production functions are as in Section 4. 19 See, Besley and Ghatak (2005) who study a market with two types of principals (mission-oriented and not mission-oriented), and two types of agent (motivated or not by the mission). 20 For example, Alkan (1988) shows that in the three-sided one-to-one matching market stable outcomes may not exist. Kelso and Crawford (1982) show that a su¢ cient condition for the existence of equilibrium in a two-sided many-to-one matching model is that agents are gross substitutes from each principal's standpoint. If agents are complementary, then equilibria may fail to exist.
An equilibrium is this simple three-sided market consists of a set of three-party (an owner, a principal, and an agent) partnerships and some isolated players, as well as an individually-rational sharing of the surplus in each partnership, such that it is not possible for an owner, a principal, and an agent to form a partnership and share the surplus in such a way that they are all better o¤ under the new partnership than under the previous outcome.
A model with these characteristics is easy to analyze because, at equilibrium, it is necessarily the case that the payo¤ of all the owners is zero. Indeed, consider an outcome where one owner obtains positive equilibrium pro…ts. This owner is necessarily matched with a principal and an agent. But then, this principal and this agent can form a new partnership with some unmatched owner, obtain the same total surplus as under the previous matching, and share it so that the three partners are better o¤ than before.
Given that the owners are identical and obtain zero pro…ts, they are like "dummies" in this model. In fact: (i) Take any equilibrium ( ; ; U ), with = ( i ) i2P and U = (U j ) j2A , in the two- where k is any owner; (b) if the partnership fk; i; jg is formed, then the owner obtains zero pro…ts, principal i gets i and agent j gets U j . This is an equilibrium outcome.
(ii) And similarly, given an equilibrium in the three-sided market (which involves zero payo¤ for the owners), the restriction of the partnership and the payo¤s to the sets of principals and agents constitutes an equilibrium in the two-sided market.
We note that the previous result holds because the market is particularly simple, not only due to the existence of many identical owners but also because only one of the two "important"partners (the agent) is subject to moral hazard. If both the principal and the agent are subject to moral hazard then the owners can play the role of "residual claimant" in the relationships because they can break the budget-balance constraint, even if there are still many identical owners and they obtain zero bene…ts at equilibrium. Thus, the existence of owners would improve the e¢ ciency of the production by the principal and the agent and the previous equivalence would no longer hold. 21 But the approach that we have proposed can still be useful for analyzing such markets.

A market where each principal hires two agents from a single pool
We consider again an environment where there are only two sets of participants: a set of identical risk-neutral principals P and a set of risk-averse agents A with CARA utility function. We now assume that the coe¢ cient of risk aversion r is the same for all the agents and that their disutility of e¤ort is 1 2 ve 2 . However, we study a production function that requires that each principal has to …ll up two positions, hence she needs to hire two agents. Thus, this is a two-sided many-to-one matching problem. 22 Each agent makes an e¤ort in the production and the identity of the two agents hired will determine the volatility of the project. That is, the variance is not a characteristic of the principal but of the team of agents. In particular, when a principal hires agents j and k, the output is where e j and e k are the e¤orts exerted, respectively, by agents j and k, 0, jk > 0, and N (0; 1).
Given that the principals are risk neutral and the agents have a CARA utility function, the utility is still transferable among the participants in any partnership. Therefore, the contracts between the principal and agents j and k maximize the total surplus.
Under symmetric information, and similarly to the case when the principal hires only one agent, the variable part of the optimal contract is zero, s SI = s SI k = 0 and the e¤ort requested is e SI j = e SI k = 1 v : Total surplus under symmetric information for a partnership fi; j; kg is 22 In our model, each principal hires several (two) agents who are subject to moral hazard. One can also analyze situations where it is the agent (subject to moral hazard) who contracts with several principals.
One example of such a situation is found in Lilienfeld-Toal and Mookherjee (2016), who analyze a credit market. This paper also illustrates that an exogenous shock may have a general equilibrium e¤ect in a market contracts which is absent in an isolated principal-agent relationship.
If the agents are subject to a (team) moral hazard problem, and they do not cooperate, then the optimal contracts solve (when agents'utility in the market is U j and U k ): M ax To discuss the characteristics of the equilibrium outcomes both under symmetric information and under moral hazard, …rst note that at equilibrium all principals necessarily obtain the same pro…ts eq because they are identical. For instance, if there are fewer agents than twice the number of principals, then some principal will certainly remain unmatched at equilibrium and all the principals (matched or unmatched) will obtain eq = 0.
In any case, at equilibrium, any surplus beyond eq generated in any partnership goes to the agents. Thus, even though it is the principals who are competing to create the partnerships, the equilibrium characteristics of the matching correspond to the characteristics of the equilibrium in the one-sided one-to-one matching problem among the agents.
In the one-sided one-to-one matching problem, there is a unique set of players (in our case, the set of agents A) and any two agents can form a partnership if they so decide.
An outcome corresponds to a matching between agents (which can also be identi…ed by a partition of the set of agents in either pairs of agents or singletons) and a sharing of the surplus obtained by any pair. In the one-sided one-to-one matching model with a …nite number of agents, equilibria may not exist. 24 But equilibria always exist if there is a continuum of agents. 25 Thus, for this model and for simplicity, we are going to assume 23 Note that the variable part of the contract s is the same for both partners, regardless of who contributes more (or less) to the variance of the project. 24 See, for instance, Talman and Yang (2011) for some su¢ cient conditions for the existence of equilibria. 25 See the results by Kaneko and Wooders (1986) and Gretsky et al. (1992).
that there is a continuum of agents A and a continuum of principals P .
If there is symmetric information in the market, even though the agents may be di¤erent in their e¤ect on the variance of the project, the variance is in fact irrelevant because S SI ijk does not depend on it. Therefore, in terms of the surplus, agents are identical. This implies that any matching (both in the one-sided and in the two-sided matching models) is optimal, hence, any matching is an equilibrium matching. Moreover, all the agents obtain the same level of utility. For instance, each agent obtains a utility of v if there are more principals than half the number of agents. 26 To study the market equilibrium when both agents are subject to moral hazard, let us assume that each j 2 A is characterized by a parameter 2 j > 0 so that the variance of a team formed by j and k is 2 jk = 2 j + 2 k + 2 j 2 k with 2 R and j j not too large. Then, the surplus S SI ijk depends on the types 2 j and 2 k working for the principal. As it happens in the two-sided models, in the one-sided models there is PAM when agents'characteristics are complementary: regardless of the distribution of types, "good" agents partner with "good"agents, and "bad"agents partner with "bad"agents. In fact, if the surplus function is strictly supermodular, then there is segregation among agents: every agent matches with someone identical to themselves. 27 On the other hand, if the surplus function is strictly submodular, then at equilibrium there is NAM among agents. 28 Therefore, taking into account the expression for S SI ijk , there is segregation if 2 ) for all j; k 2 A: In this case, each principal hires at equilibrium two identical agents. It is more e¢ cient that high-variance agents go together and low-variance agents go together, because this matching minimizes the distortion in incentives for the team. This happens when is negative, or it is positive but small enough.
Similarly, the surplus function is strictly submodular and there is NAM among agents at equilibrium if 2 ) for all j; k 2 A: 26 On the other hand, if the number of principals is lower than half the number of agents, the principals keep all the surplus and the agents obtain their outside utility at equilibrium. 27 See, for instance, Kremer (1993). 28 See Legros and Newman (2002) for a careful analysis of su¢ cient conditions for monotone matching.
Therefore, if > 0 and large, then we should see at equilibrium that a principal who hires an agent with very low variance also hires an agent with very high variance. In this case, hiring two high-variance agents is very costly, because providing incentives is very expensive. Thus, it is better to mix high-and low-variance agents. NAM is also more likely if v is small, because a lower v means a higher e¤orts in the optimal contracts, which makes dealing with very high variances more expensive and hence less e¢ cient.
Again, the moral hazard problem has important consequences for the type of matching that takes place in the market. And it also a¤ects in a new way the relationship between an agent's level of variance and the power of the incentives he receives in the market. We now discuss this fact in brief.
In an isolated multi-agent moral hazard situation, when the variance of one of the agents increases, the total variance of the team increases and the incentives for both partners decrease. That is, we should observe that the power of the incentives decreases with the variance. However, in the market, taking into account the assignment, one has to be more careful.
To see how incentives change with an agent's volatility, consider a market where (3) holds so that the matching is NAM. Moreover, 2 j is distributed according to a uniform distribution in [ 2 ; 2 ]. This means that the equilibrium partner (j) of j has an associated variance of 2 (j) = 2 + 2 2 j . The power of incentives given to agent j are : Therefore, which, given that > 0 if NAM, is negative if and only if 2 j < 2 (j) . Figure 1 shows the power of the incentives as a function of 2 j , when [ 2 ; 2 ] = [1; 3]. The teams formed by agents with variance more to the center of the interval of individual variance (the team (k; (k)) as compared to the team (j; (j))) are those teams with higher total variance, hence they receive fewer incentives. Below the mean, when the variance of an agent increases, each individual of the team will receive lower incentives. This is the same comparative static as in a single principal-agent model. But above the mean, an increase in the variance of the agent will lead to an increase in his incentives (because his partner in the team will have lower individual variance and the team total variance will decrease).

A market with repeated moral hazard
In the previous sections, we have studied several markets where principals and agents interact. One important feature of those markets is that they are static. Interactions between principals and agents only happen once. This is a natural hypothesis given that the assignment game, which constitutes our tool to model markets, is also a static model.
However, we can also use the ideas and methodology derived from the assignment game to model some dynamic markets.
In this section, we propose a dynamic model where a set of principals and a set of agents meet every period. The model is in the same spirit as Macho-Stadler et al. (2014), but the particulars of the model and the objective are di¤erent. In that paper, the main objective is to show that the existence of a market strongly in ‡uences the principals' choice of short-term (ST) or long-term (LT) contracts when agents have industry-speci…c abilities and are subject to moral hazard. In an isolated principal-agent relationship in their framework, if both participants are able to commit to the duration of the contract, an LT contract is always optimal (see, e.g., Lambert 1983, Rogerson 1985, and Chiappori et al. 1994). However, when there is a market, the sorting of workers with heterogeneous ability to …rms which are heterogeneous in their pro…tability is also important and this can only be achieved with ST contracts. The paper shows that ST contracts are often o¤ered at equilibrium, and they sometimes coexist with LT contracts.
The main objective of the model developed in this section is complementary. We con-sider that agents have industry-and principal-speci…c characteristics and we analyze the in ‡uence of these characteristics on the equilibrium con…guration of LT and ST contracts in the industry. Moreover, contrary to Macho-Stadler et al. (2014), we assume (as in the previous sections in this paper) that agents are risk-averse with a CARA utility function, which implies that LT and ST contracts are equally optimal in an isolated principal-agent relationship. 29 For simplicity, we model the sets of principals and agents as continuous, instead of discrete, sets but the de…nitions and properties of the assignment game are easily extended to the continuous framework.
We model the economy as an overlapping generation model where at each period t, with t = 1; 2; :::, principals (…rms) contract with agents (workers) to develop projects.
Principals are in…nitely-lived, risk-neutral, players, and the set of principals is constant for all periods. They are heterogeneous in the potential return R of the technology they own.
For a given principal i, the attribute R i is the same across periods and it is distributed in the interval R; R , with R > 0, according to the distribution function G(R). We can identify the set of principals with the interval R; R of their characteristic. On the other hand, agents live for two periods, and their preferences are represented through a CARA utility function with the same coe¢ cient of risk aversion r. Both principals and agents discount the future according to the discount factor 2 (0; 1).
At any period t, a generation of agents is born. Thus, in period t the market is composed of the set of principals, the set of agents that enter the market during this period and the set of older agents that entered the market in period t 1. In period 1; there is a set of agents who are already old.
To run its project, a principal must hire a non-trained (junior) agent and a trained (senior) agent. To become trained, that is, senior, an agent must have worked in this market in the …rst period of his life. That is, working for a principal gives the agent the necessary skills to take charge of a project. We assume that the measure of the set of agents born in any period is larger than the measure of the set of principals, so there are more junior agents than non-trained positions to …ll in the market. 29 See Chiappori et al. (1994). The intuition behind this result is that when the agent has a CARA utility function, the incentives for the second period do not depend on the savings of the agent from the previous period. In other words, LT contracts are subgame perfect and as a consequence equivalent to the sequence of ST contracts. Therefore, in an isolated principal-agent relationship, or even in a market where all principals are identical, there is no advantage in signing LT contracts.
The output x for principal i from the project follows the production function: where > 0 and N (0; 1). Parameter p refers to the characteristic of the senior agent, and e to his e¤ort. The senior's cost of e¤ort is v(e) = 1 2 ve 2 . We assume that the non-contractible e¤ort of the senior agent is crucial for determining the output whereas the junior agent performs a routine job whose cost is normalized to zero.
The senior agent's productivity, p, summarizes his ability/productivity. We assume that this productivity takes the form p = p I + , where p I is the senior industry-speci…c ability (the same for all principals) and is the senior principal-speci…c ability. 30 Concerning the principal-speci…c ability, we assume that = 0 when the senior agent works for a principal di¤erent than when junior, and = > 0 when he works for the same principal than when junior. As for the industry-speci…c ability, all juniors are identical ex-ante but during their work as juniors, they reveal their industry-speci…c talent; that is, this ability is unknown to everyone when the agent is born and becomes public after he has worked as a junior. We assume that there is a proportion q of high-ability agents that have p I = p H and a proportion (1 q) of low-productivity agents with p I = p L . We assume that industry-speci…c ability is important, so that p H p L > : Then, they are two types of agents but four possible levels of productivity: p 2 fp H ; p H + ; p L ; p L + g.
A senior agent enters a relationship only if his expected utility is at least equal to U o , which is the level of utility that he can secure outside this labor market. Similarly, a junior agent accepts a contract only if his expected intertemporal utility is at least For simplicity, we assume that R is high enough and all principals in R; R are active in the market; hence, we disregard the principals'participation constraint.
Concerning the salaries, a junior agent working for a principal receives a …xed wage B. As above, the principal o¤ers a linear contract to the senior agent, with s 2 [0; 1] : Thus, if he is hired by principal i, a senior agent with 30 Some authors refer to industry-speci…c as portable skills (Grosyberg et al. 2008). In addition to the agent's ability, one can also think of portable resources such as carrying contacts, clients, or providers when moving to a new …rm.
ability p selects the e¤ort In any period t, the expected pro…t of a principal i that runs its project with a junior agent, to whom it pays the salary B, and a senior agent of ability p, who is paid according to the payment scheme (F; s), is Principals and agents can sign either ST or LT contracts. An ST contract between a principal and a junior agent consists of a salary B. An ST contract between a principal and a senior agent is an incentive scheme (F; s) that may depend on the potential of the principal's project R and the agent's productivity p. An LT contract between a principal and a junior agent in period t speci…es the salary that the agent will receive during this period and the incentive scheme that will govern the relationship in period t + 1, which will be a function of the revealed ability of the agent. That is, an LT contract is a vector (B; F H ; s H ; F L ; s L ) that implies a commitment by the principal to retain the agent as a senior and a commitment by the agent to work for the same principal in period t + 1.
We focus on stationary equilibria, that is, on equilibria where …rms o¤er the same contracts every period. This allows us to do the analysis, taking into account the expected pro…ts that principals make in one (in any) period. The only small arrangement we have to make is that we need to associate to the junior agent a cost of 1 B rather than B, because any possible deviation of the type of contract by a principal will have consequences in the next period. 31 We denote the one-period pro…t Ee . A principal has an incentive to switch from contract C to contract C 0 if and only if Ee (C) < Ee (C 0 ). As was the case in the static models that we presented in the previous sections, all the equilibrium contracts must be Pareto optimal. Thus, before describing more characteristics of the equilibrium, we state the Pareto-optimal LT and ST contracts.

Pareto-optimal long-term contracts
Given that there are more junior agents than principals, and junior agents are ex-ante identical, any principal can secure the services of a junior agent if he receives a total (twoperiod) discounted payment of (1 + ) U o . Therefore, principal i looks for the contract 31 and she solves the following problem: The previous program takes into account that an agent hired under an LT contract always acquires the principal-speci…c ability, hence his productivity is either p H + or p L + , but not p H or p L .
We state the characteristics of the candidate LT contract for principal i in Proposition

32
Proposition 6 If in equilibrium principal i o¤ers an LT contract, then: i (p L + ) 2 +rv 2 , and the vector of …xed payments (B; F H ; F L ) satis…es (P CT L).

b) E¤orts are
c) The principal's one-period pro…t under the optimal LT contract is: It is worth noticing that the pro…t function Ee LT (R i ) is continuously di¤erentiable and increasing in R i . 32 The proofs of the results in this section are in the Appendix.

Pareto-optimal short-term contracts
All principals signing ST contracts hire similar junior agents, as they are indistinguishable ex-ante. With respect to senior agents, principals can decide to hire high-ability or lowability agents (and a senior with principal-speci…c skills or not). If a senior agent is hired by the principal for whom he worked last period, he has a higher productivity than if hired by another principal. However, all seniors have the same value for the other principals in the market. As a consequence, all high-ability seniors have the same "equilibrium value" U H in the market and all low-ability seniors can obtain the same U L . Both U H and U L exceed or are equal to U o . 33 The equilibrium salary B that the junior agent will receive satis…es: where the equality is due to the abundance of junior agents.
We now compute the Pareto-optimal contract o¤ered by principal R i to a senior agent with industry-speci…c ability I, for I = H; L; who must receive U I . Denote p ] I the agent's productivity: p ] I = p I + if the agent worked last period as a junior for the same principal and p ] I = p I otherwise. Then, the principal solves the following program: The market for seniors is an assignment game with a continuum of equilibria in terms of payo¤s. If, for instance, we denote U H the utility that a high-ability senior obtains in equilibrium when he works for a principal for whom he has no principal-speci…c ability, then he could obtain any U 2 [U H ; U H + ] in equilibrium if he works as a senior for the same principal as a junior. Thus, we focus at the equilibrium that gives the principal-optimal payo¤ (see Proposition 2). If we would consider equilibria where the highability seniors obtain more that U H , then this increase in utility when senior would lead to a decrease in the …xed payment to all junior agents and, in expectation, a junior agent would obtain the same utility in both equilibria. The same comments hold for equilibria where the low-ability agents would obtain more than at the principal-optimal payo¤. 1 2v b) If the productivity of the agent is p ] I , the e¤ort is e ] I +rv 2 . c)The expected principal's one-period pro…t when she hires a high-ability senior agent, also taking into account the cost of the junior agent, is and when she hires low-ability senior agent is As it happens for the optimal LT contracts, the pro…t functions Ee ST H (R i ; B; U H ) and Ee ST L (R i ; B; U L ) are continuously di¤erentiable and increasing in R i .

Equilibria
We now look for the equilibrium outcomes. We focus on equilibria where the low-ability senior agents obtain U o , that is, U L = U o . For the same reasons discussed in the previous subsection, this simpli…cation does not have consequences for the total agents'expected utility and for the form of the equilibrium contract.
In equilibrium, the set of principals is partitioned into a maximum of three subsets: the set of principals that o¤er LT contracts, the set of principals that o¤er ST contracts to juniors and to high-ability seniors, and the set of principals that o¤er ST contracts to juniors and to low-ability seniors. We explore equilibria where ST contracts may appear. 34 In equilibrium, high-ability agents should be more expensive than low-ability agents, that is, U H > U L = U o because every principal makes a higher pro…t with a high-than with a low-ability senior agent, and the number of high-ability senior agents is lower than the number of principals. Also, the willingness to pay for a high-instead of a lowability senior increases with the attribute R of the principal. 35 Therefore, if there are 34 There is a trivial equilibrium where all principals sign LT contracts with their agents: if all the principals in the economy sign LT contracts then no single principal has an incentive to deviate and o¤er a sequence of ST contracts because she can only hire the same agent that worked for her as a junior. 35 The principal's one-period pro…t in ST contracts depends on expressions like It is easy to check that @ 2 @R@p R 4 p 4 R 2 p 2 +rv 2 > 0, that is, R and p are complements.
ST contracts, principals with a high R will hire high-ability seniors whereas principals with a low R will hire low-ability senior agents. Finally, it is intuitive that if there is an equilibrium where LT and ST contracts coexist, the principals using LT contracts should have an attribute R that is not too high (so that it is not worthwhile for them to pay as much as U H every period) and not too low (so that they do not hire low-ability agents every period). 36 Thus, we study the existence of equilibria where there are two thresholds R L and R H with R < R L < R H < R; such that principal i signs ST contracts with low-ability seniors if R i 2 R; R L ; LT contracts if R i 2 R L ; R H , and ST contracts with high-ability seniors if R i 2 R H ; R . At equilibrium, low-skilled agents obtain U L = U o and junior agents in ST contracts get (1 + ) U o in total, that is, equation (4) holds, which implies . Moreover, the equilibria (that is, the parameters U H , R H , and R L ) must satisfy the following three properties: 1) There are as many principals with R i in R; R L as in R H ; R , that is, 2) If R i = R L , then principal i is indi¤erent between using ST contracts hiring lowability seniors and using LT contracts, that is, 3) If R i = R H , then principal i is indi¤erent between using LT contracts and using ST contracts hiring high-ability seniors: Proposition 8 shows that an equilibrium with the previous characteristics exists if and only if is low enough. In particular, needs to be lower than the unique threshold o 2 (0; p H p L ) implicitly de…ned by equation (8): 36 Indeed, we prove in Claim 1 in the Appendix that the di¤erence between an LT pro…t and ST pro…t hiring low-skilled agents is increasing in R i . Similarly, the di¤erence between an ST pro…t hiring high-skilled agents and LT pro…t is increasing in R i . As stated in Proposition 8, only LT contracts are signed at equilibrium if the principal-speci…c ability that a junior agent learns when working for a principal is very large, o = 0:282: In this case, even for the principal with the most pro…table project R = 6 it is not worthwhile using ST contracts to always catch a high-productivity (in terms of industry-speci…c ability) agent. She would prefer to sign an LT contract with junior agents and bene…t from their acquired principal-speci…c ability.
On the other hand, if < o , then there are three groups of principals. Principals with a high R choose ST contracts to make sure that they always hire high-productivity agents.
Some of these high-productivity agents also have a principal-speci…c ability because they were hired by the same principal when junior, whereas others were working for other principals. They all receive a high salary at equilibrium. At the other extreme, principals with a low R choose ST contracts because junior agents are ready to accept low salaries if hired under these types of contracts. They hope to have high productivity and access a high salary when senior. For the principals with intermediate values of R, the principal-speci…c ability is important enough so that they prefer to always keep the same agents for both periods. For these principals, the advantages of ST contracts discussed above do not compensate for the eventual loss of the principal-speci…c ability. The set of principals that prefer LT contracts at equilibrium increases with the importance of the principal-speci…c ability, so it is larger as increases.
In our model, the junior's ability is unknown to everyone. Hermalin (2002) studies a competitive labor market where workers initially have private information about their ability while this ability becomes public when they become seniors. High-ability …rms want to retain high-ability workers, and high-ability workers value the option to entertain outside wage o¤ers once their ability becomes known to the market. Then, o¤ering ST contracts allows the screening of high-ability types from low-ability ones (who prefer LT contracts). As a consequence, …rms have few incentives to train workers under ST contracts, and training may be under-provided in equilibrium.
That the ability of a senior agent is public information is another important hypothesis in the model. If the current principal has an informational advantage over the senior's ability then the other principals will attempt to infer the worker's quality by observing the principal's job assignment or promotion decisions (see, e.g., Waldman 1984).
Finally, we assume that the agent can commit to not leaving the …rm. If the contract cannot include buyout clauses (to be paid by the principal who wishes to hire the senior worker), penalties in the case of breaking the contract (that the worker would have to pay), or non-compete clauses (forbidding working for another …rm in the market) then an agent may not be able to commit to staying in the …rm that trained him as a junior.
The advantages and disadvantages of using non-compete agreements and other retention clauses has been studied, also taking into account how those clauses protect the …rms' internal knowledge when this knowledge creates a competitive advantage and may be absorbed by rivals or entrants when hiring the worker (see, e.g., Mukherjee and Vasconcelos 2018).

Conclusion and extensions
In this paper, we analyze the optimal incentive scheme in principal-agent relationships in several market situations. We use the assignment game as a tool to embed the relationships in a general equilibrium framework. We …rst highlighted the importance of considering principal-agent relationships not as isolated partnerships but as part of a market. When not only the contract but also the identity of the partners are endogenous, some of the conclusions that one obtains in classic principal-agent theory may be reversed. This is particularly relevant in empirical work, where data often comes from the markets.
Second, we have shown that the existence of moral hazard may alter the characteristics of the equilibrium matching in markets, compared to the situation where information about the e¤ort of the agents is veri…able.
In all the models that we have seen in this paper, the surplus obtained in any partnership can be fully distributed among principals and agents. For instance, the cost for a principal of increasing by one unit the level of utility of an agent is also one. This is an important characteristic that makes the models share the main properties of the assignment game (with a discrete or a continuous number of agents). In particular, a matching is an equilibrium matching if and only if it is optimal. However, there are many relevant environments where this characteristic does not hold, especially when moral hazard problems are present. For example, if the agents are subject to moral hazard and they are risk-averse with a utility function that is di¤erent from the CARA utility function, or they are subject to limited liability constraints, then the surplus is not (at least, not fully) transferable.
Several papers study environments with a non-transferable utility to analyze partnerships and contracts in markets. Legros and Newman (2007) provide necessary and su¢ cient conditions for PAM and NAM in these markets. The monotonicity of the equilibrium matching requires not only the complementarity/substitutability of the surplus in types but also the complementarity/substitutability between an agent's type and his partner's payo¤. Besley and Ghatak (2005) consider a market with two types of principals (pro…t-oriented and mission-oriented) and two types of agents (those who only care about the monetary reward and those that receive an intrinsic motivation if they work for a mission-oriented …rm) and study the market assignment and contracts. Dam and Pérez-Castrillo (2006) model the interaction between landowners and heterogeneous (poor) tenants who are subject to limited liability constraints and study the consequences of competition on the power of incentives, the e¢ ciency of the relationships, and the e¤ect of redistributive policies. 37 Legros and Newman (2007) also propose two applications: they study the market between a set of principals endowed with projects with heterogeneous risk characteristics and a set of agents who di¤er in initial wealth and have a declining absolute risk aversion, as well as a "marriage market"where agents are heterogeneous in their absolute risk tolerance (see also Chiappori  Finally, we discuss some of the empirical literature related to these models. Empirical research on situations with incentives and moral hazard often use data from markets where the match principal-agent is not exogenous. Unlike single-agent choices, matching outcomes depend on the preferences of other agents in the market. 38 Recently, several papers have proposed estimation strategies adapted for matching situations, and some empirical papers estimate two-sided matching situations with (and without) transfers. 39 Some papers use reduced-form models, as the "probit-counterfactual" approach (see, Gompers et al. 2016). This approach uses data on the actual pairs to construct a plausible set of counterfactual pairs (control group) of available alternatives to the actual partner.
Then, it estimates the likelihood of an agent being matched with an actual rather than an alternative partner. 40 Following this approach, Agrawal et al. (2008) use the spatial and 37 Barros and Macho-Stadler (1988) also analyze the e¤ect of the principals' competition for a good agent on the power of incentives and the e¢ ciency of the relationship. 38 This is the case in other interesting economic situations such as in Nash equilibrium outcomes, or any other cooperative or non-cooperative outcome that depends on the preferences of all the agents. 39 For more details see Graham  Given its interest both from the theoretical and the empirical perspective, we expect that considering moral hazard problems in markets will allow researchers to increase the understanding of important economic questions.

Appendix
Proof of Proposition 6. a) Substituting the e¤orts in the program that maximizes the principal, and rewriting (P CT L), we obtain We rewrite the principal's program as Moreover, any vector of …xed-payments (B; F H ; F L ) that satisfy (P CT L) (and which ensures that the senior agent obtains at least U o in both states of the world, which is always possible) is equivalent for both the principal and the agent.
b) The expressions for e H and e L follow easily.
(1 q) Given that the probability that p ] H = p H + is q, and also taking into account the (discounted) cost of the junior agent, her one-period pro…t is: Similar calculations lead to an expression of the expected one-period pro…t for a principal that hires agents with a low industry-speci…c ability, taking into account that the probability that the senior agent has a principal-speci…c ability is now (1 q).
Proof of Proposition 8. Before we prove the proposition, we prove in Claim 1 the properties on the derivatives of the di¤erences between LT and ST pro…ts.
Proof of Claim 1. i) Denoting k rv 2 and x R 2 i , we can write the di¤erence in pro…ts as: 1 2v The derivative of the function depicted in (9) with respect to x is positive if: x 2 (p H + ) 6 + 2x (p H + ) 4 k x (p H + ) 2 + k 2 x 2 p 6 L + 2xp 4 L k xp 2 L + k > 0: Equation (10) is satis…ed given that p H + > p L and @ @d x 2 d 6 + 2xd 4 k (xd 2 + k) 2 = 2x 3 d 7 + 6x 2 d 5 k + 8xd 3 k 2 (xd 2 + k) 3 > 0: ii) Proceeding as in the proof of i), the di¤erence in pro…ts is: The function in (12) is increasing in x because p H > p L + and then the derivative of (12) with respect to x is the similar to the derivative of (9) with respect to x.
We now prove Proposition 8.
a) If there is an equilibrium with only ST contracts then there is a principal i such that principals with R < R i hire low-ability seniors and principals with R > R i hire high-ability seniors. The principal with the threshold level R i should be indi¤erent between the two types of contract, that is, which holds for any > 0.
b) We rewrite equation (6) as that is, Similarly, equation (7)  (p L + ) 4 R H2 (p L + ) 2 + rv 2 ! : (14) Therefore, an equilibrium with the coexistence of ST and LT contracts exists if we can …nd R L and R H with R < R L < R H < R, and U H that satisfy (5), (13), and (14).
Equations (13) and (14) imply Equation (15) implicitly de…nes a function R H (R L ). We prove several properties of this function through the following claims: Claim 2 R H (R L ) > R L for any R L and any > 0.

Claim 3
The function R H (R L ) is increasing.

Proof of Claim 3.
Given that R H (R L ) = p y (R L2 ), R H0 R L = 1 2 2R L y 0 (R L2 ) p y(R L2 ) . Therefore, R H (R L ) is increasing if y(x) is increasing. To prove that y(x) is increasing, note that as stated above, we can implicitly de…ne the function y(x) as h(y; 0) h(x; ) = 0.
Claim 4 i) If = 0, then R H (R L ) = R L for any R L . In particular, R H (R) = R.
ii) R H (R) increases with .
For part ii), and following (15) Note that we can write equation (8)