{
"cells": [
{
"cell_type": "markdown",
"id": "78340de6",
"metadata": {},
"source": [
"\n",
""
]
},
{
"cell_type": "markdown",
"id": "e4f57fdb",
"metadata": {},
"source": [
"# Coase’s Theory of the Firm"
]
},
{
"cell_type": "markdown",
"id": "38de378c",
"metadata": {},
"source": [
"## Contents\n",
"\n",
"- [Coase’s Theory of the Firm](#Coase’s-Theory-of-the-Firm) \n",
" - [Overview](#Overview) \n",
" - [The Model](#The-Model) \n",
" - [Equilibrium](#Equilibrium) \n",
" - [Existence, Uniqueness and Computation of Equilibria](#Existence,-Uniqueness-and-Computation-of-Equilibria) \n",
" - [Implementation](#Implementation) \n",
" - [Exercises](#Exercises) "
]
},
{
"cell_type": "markdown",
"id": "81125376",
"metadata": {},
"source": [
"## Overview\n",
"\n",
"In 1937, Ronald Coase wrote a brilliant essay on the nature of the firm [[Coase, 1937](https://python-advanced.quantecon.org/zreferences.html#id232)].\n",
"\n",
"Coase was writing at a time when the Soviet Union was rising to become a significant industrial power.\n",
"\n",
"At the same time, many free-market economies were afflicted by a severe and painful depression.\n",
"\n",
"This contrast led to an intensive debate on the relative\n",
"merits of decentralized, price-based allocation versus top-down planning.\n",
"\n",
"In the midst of this debate, Coase made an important observation:\n",
"even in free-market economies, a great deal of top-down planning does in fact take place.\n",
"\n",
"This is because *firms* form an integral part of free-market economies and, within firms, allocation is by planning.\n",
"\n",
"In other words, free-market economies blend both planning (within firms) and decentralized production coordinated by prices.\n",
"\n",
"The question Coase asked is this: if prices and free markets are so efficient, then why do firms even exist?\n",
"\n",
"Couldn’t the associated within-firm planning be done more efficiently by the market?\n",
"\n",
"We’ll use the following imports:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "93bd9cbf",
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"from scipy.optimize import fminbound"
]
},
{
"cell_type": "markdown",
"id": "bea69927",
"metadata": {},
"source": [
"### Why Firms Exist\n",
"\n",
"On top of asking a deep and fascinating question, Coase also supplied an illuminating answer: firms exist because of transaction costs.\n",
"\n",
"Here’s one example of a transaction cost:\n",
"\n",
"Suppose agent A is considering setting up a small business and needs a web developer to construct and help run an online store.\n",
"\n",
"She can use the labor of agent B, a web developer, by writing up a freelance contract for these tasks and agreeing on a suitable price.\n",
"\n",
"But contracts like this can be time-consuming and difficult to verify\n",
"\n",
"- How will agent A be able to specify exactly what she wants, to the finest detail, when she herself isn’t sure how the business will evolve? \n",
"- And what if she isn’t familiar with web technology? How can she specify all the relevant details? \n",
"- And, if things go badly, will failure to comply with the contract be verifiable in court? \n",
"\n",
"\n",
"In this situation, perhaps it will be easier to *employ* agent B under a simple labor contract.\n",
"\n",
"The cost of this contract is far smaller because such contracts are simpler and more standard.\n",
"\n",
"The basic agreement in a labor contract is: B will do what A asks him to do for the term of the contract, in return for a given salary.\n",
"\n",
"Making this agreement is much easier than trying to map every task out in advance in a contract that will hold up in a court of law.\n",
"\n",
"So agent A decides to hire agent B and a firm of nontrivial size appears, due to transaction costs."
]
},
{
"cell_type": "markdown",
"id": "ac648b38",
"metadata": {},
"source": [
"### A Trade-Off\n",
"\n",
"Actually, we haven’t yet come to the heart of Coase’s investigation.\n",
"\n",
"The issue of why firms exist is a binary question: should firms have positive size or zero size?\n",
"\n",
"A better and more general question is: **what determines the size of firms**?\n",
"\n",
"The answer Coase came up with was that “a firm will tend to expand until the costs of organizing an extra\n",
"transaction within the firm become equal to the costs of carrying out the same\n",
"transaction by means of an exchange on the open market…” ([[Coase, 1937](https://python-advanced.quantecon.org/zreferences.html#id232)], p. 395).\n",
"\n",
"But what are these internal and external costs?\n",
"\n",
"In short, Coase envisaged a trade-off between\n",
"\n",
"- transaction costs, which add to the expense of operating *between* firms, and \n",
"- diminishing returns to management, which adds to the expense of operating *within* firms \n",
"\n",
"\n",
"We discussed an example of transaction costs above (contracts).\n",
"\n",
"The other cost, diminishing returns to management, is a catch-all for the idea\n",
"that big operations are increasingly costly to manage.\n",
"\n",
"For example, you could think of management as a pyramid, so hiring more workers to implement more tasks\n",
"requires expansion of the pyramid, and hence labor costs grow at a rate more than\n",
"proportional to the range of tasks.\n",
"\n",
"Diminishing returns to management makes in-house production expensive, favoring small firms."
]
},
{
"cell_type": "markdown",
"id": "e4fe3dee",
"metadata": {},
"source": [
"### Summary\n",
"\n",
"Here’s a summary of our discussion:\n",
"\n",
"- Firms grow because transaction costs encourage them to take some operations in house. \n",
"- But as they get large, in-house operations become costly due to diminishing returns to management. \n",
"- The size of firms is determined by balancing these effects, thereby equalizing the marginal costs of each form of operation. "
]
},
{
"cell_type": "markdown",
"id": "c367996d",
"metadata": {},
"source": [
"### A Quantitative Interpretation\n",
"\n",
"Coases ideas were expressed verbally, without any mathematics.\n",
"\n",
"In fact, his essay is a wonderful example of how far you can get with clear thinking and plain English.\n",
"\n",
"However, plain English is not good for quantitative analysis, so let’s bring some mathematical and computation tools to bear.\n",
"\n",
"In doing so we’ll add a bit more structure than Coase did, but this price will be worth paying.\n",
"\n",
"Our exposition is based on [[Kikuchi *et al.*, 2018](https://python-advanced.quantecon.org/zreferences.html#id231)]."
]
},
{
"cell_type": "markdown",
"id": "0ac2df49",
"metadata": {},
"source": [
"## The Model\n",
"\n",
"The model we study involves production of a single unit of a final good.\n",
"\n",
"Production requires a linearly ordered chain, requiring sequential completion\n",
"of a large number of processing stages.\n",
"\n",
"The stages are indexed by $ t \\in [0,1] $, with $ t=0 $ indicating that no tasks\n",
"have been undertaken and $ t=1 $ indicating that the good is complete."
]
},
{
"cell_type": "markdown",
"id": "2aa4c882",
"metadata": {},
"source": [
"### Subcontracting\n",
"\n",
"The subcontracting scheme by which tasks are allocated across firms is illustrated in the figure below\n",
"\n",
"![https://python-advanced.quantecon.org/_static/lecture_specific/coase/subcontracting.png](https://python-advanced.quantecon.org/_static/lecture_specific/coase/subcontracting.png)\n",
"\n",
" \n",
"In this example,\n",
"\n",
"- Firm 1 receives a contract to sell one unit of the completed good to a final buyer. \n",
"- Firm 1 then forms a contract with firm 2 to purchase the partially completed good at stage $ t_1 $, with\n",
" the intention of implementing the remaining $ 1 - t_1 $ tasks in-house (i.e., processing from stage $ t_1 $ to stage $ 1 $). \n",
"- Firm 2 repeats this procedure, forming a contract with firm 3 to purchase the good at stage $ t_2 $. \n",
"- Firm 3 decides to complete the chain, selecting $ t_3 = 0 $. \n",
"\n",
"\n",
"At this point, production unfolds in the opposite direction (i.e., from upstream to downstream).\n",
"\n",
"- Firm 3 completes processing stages from $ t_3 = 0 $ up to $ t_2 $ and transfers the good to firm 2. \n",
"- Firm 2 then processes from $ t_2 $ up to $ t_1 $ and transfers the good to firm 1, \n",
"- Firm 1 processes from $ t_1 $ to $ 1 $ and delivers the completed good to the final buyer. \n",
"\n",
"\n",
"The length of the interval of stages (range of tasks) carried out by firm $ i $ is denoted by $ \\ell_i $.\n",
"\n",
"![https://python-advanced.quantecon.org/_static/lecture_specific/coase/allocation.png](https://python-advanced.quantecon.org/_static/lecture_specific/coase/allocation.png)\n",
"\n",
" \n",
"Each firm chooses only its *upstream* boundary, treating its downstream boundary as given.\n",
"\n",
"The benefit of this formulation is that it implies a recursive structure for the decision problem for each firm.\n",
"\n",
"In choosing how many processing stages to subcontract, each successive firm faces essentially the same\n",
"decision problem as the firm above it in the chain, with the only difference being that the decision space is a subinterval of the decision space for the firm above.\n",
"\n",
"We will exploit this recursive structure in our study of equilibrium."
]
},
{
"cell_type": "markdown",
"id": "cdc80d51",
"metadata": {},
"source": [
"### Costs\n",
"\n",
"Recall that we are considering a trade-off between two types of costs.\n",
"\n",
"Let’s discuss these costs and how we represent them mathematically.\n",
"\n",
"**Diminishing returns to management** means rising costs per task when a firm expands the range of productive activities coordinated by its managers.\n",
"\n",
"We represent these ideas by taking the cost of carrying out $ \\ell $ tasks in-house to be $ c(\\ell) $, where $ c $ is increasing and strictly convex.\n",
"\n",
"Thus, the average cost per task rises with the range of tasks performed in-house.\n",
"\n",
"We also assume that $ c $ is continuously differentiable, with $ c(0)=0 $ and $ c'(0) > 0 $.\n",
"\n",
"**Transaction costs** are represented as a wedge between the buyer’s and seller’s prices.\n",
"\n",
"It matters little for us whether the transaction cost is borne by the buyer or the seller.\n",
"\n",
"Here we assume that the cost is borne only by the buyer.\n",
"\n",
"In particular, when two firms agree to a trade at face value $ v $, the buyer’s total outlay is $ \\delta v $, where $ \\delta > 1 $.\n",
"\n",
"The seller receives only $ v $, and the difference is paid to agents outside the model."
]
},
{
"cell_type": "markdown",
"id": "aec6d388",
"metadata": {},
"source": [
"## Equilibrium\n",
"\n",
"We assume that all firms are *ex-ante* identical and act as price takers.\n",
"\n",
"As price takers, they face a price function $ p $, which is a map from $ [0, 1] $ to $ \\mathbb R_+ $, with $ p(t) $ interpreted\n",
"as the price of the good at processing stage $ t $.\n",
"\n",
"There is a countable infinity of firms indexed by $ i $ and no barriers to entry.\n",
"\n",
"The cost of supplying the initial input (the good processed up to stage zero) is set to zero for simplicity.\n",
"\n",
"Free entry and the infinite fringe of competitors rule out positive profits for incumbents,\n",
"since any incumbent could be replaced by a member of the competitive fringe\n",
"filling the same role in the production chain.\n",
"\n",
"Profits are never negative in equilibrium because firms can freely exit."
]
},
{
"cell_type": "markdown",
"id": "a49bacf0",
"metadata": {},
"source": [
"### Informal Definition of Equilibrium\n",
"\n",
"An equilibrium in this setting is an allocation of firms and a price function such that\n",
"\n",
"1. all active firms in the chain make zero profits, including suppliers of raw materials \n",
"1. no firm in the production chain has an incentive to deviate, and \n",
"1. no inactive firms can enter and extract positive profits "
]
},
{
"cell_type": "markdown",
"id": "3d9d0219",
"metadata": {},
"source": [
"### Formal Definition of Equilibrium\n",
"\n",
"Let’s make this definition more formal.\n",
"\n",
"(You might like to skip this section on first reading)\n",
"\n",
"An **allocation** of firms is a nonnegative sequence $ \\{\\ell_i\\}_{i \\in \\mathbb N} $ such that $ \\ell_i=0 $ for all sufficiently large $ i $.\n",
"\n",
"Recalling the figures above,\n",
"\n",
"- $ \\ell_i $ represents the range of tasks implemented by the $ i $-th firm \n",
"\n",
"\n",
"As a labeling convention, we assume that firms enter in order, with firm 1 being the furthest downstream.\n",
"\n",
"An allocation $ \\{\\ell_i\\} $ is called **feasible** if $ \\sum_{\\, i \\geq 1} \\ell_i = 1 $.\n",
"\n",
"In a feasible allocation, the entire production process is completed by finitely many firms.\n",
"\n",
"Given a feasible allocation, $ \\{\\ell_i\\} $, let $ \\{t_i\\} $ represent the corresponding transaction stages, defined by\n",
"\n",
"\n",
"\n",
"$$\n",
"t_0 = s \\quad \\text{and} \\quad t_i = t_{i-1} - \\ell_i \\tag{15.1}\n",
"$$\n",
"\n",
"In particular, $ t_{i-1} $ is the downstream boundary of firm $ i $ and $ t_i $ is its upstream boundary.\n",
"\n",
"As transaction costs are incurred only by the buyer, its profits are\n",
"\n",
"\n",
"\n",
"$$\n",
"\\pi_i = p(t_{i-1}) - c(\\ell_i) - \\delta p(t_i) \\tag{15.2}\n",
"$$\n",
"\n",
"Given a price function $ p $ and a feasible allocation $ \\{\\ell_i\\} $, let\n",
"\n",
"- $ \\{t_i\\} $ be the corresponding firm boundaries. \n",
"- $ \\{\\pi_i\\} $ be corresponding profits, as defined in [(15.2)](#equation-prof). \n",
"\n",
"\n",
"This price-allocation pair is called an **equilibrium** for the production chain if\n",
"\n",
"1. $ \\; p(0) = 0 $, \n",
"1. $ \\; \\pi_i = 0 $ for all $ i $, and \n",
"1. $ p(s) - c(s - t) - \\delta p(t) \\leq 0 $ for any pair $ s, t $ with $ 0 \\leq s \\leq t \\leq 1 $. \n",
"\n",
"\n",
"The rationale behind these conditions was given in our informal definition of equilibrium above."
]
},
{
"cell_type": "markdown",
"id": "325bc813",
"metadata": {},
"source": [
"## Existence, Uniqueness and Computation of Equilibria\n",
"\n",
"We have defined an equilibrium but does one exist? Is it unique? And, if so, how can we compute it?"
]
},
{
"cell_type": "markdown",
"id": "cbbcad08",
"metadata": {},
"source": [
"### A Fixed Point Method\n",
"\n",
"To address these questions, we introduce the operator $ T $ mapping a nonnegative function $ p $ on $ [0, 1] $ to $ Tp $ via\n",
"\n",
"\n",
"\n",
"$$\n",
"Tp(s) = \\min_{t \\leq s} \\,\n",
" \\{ c(s-t) + \\delta p(t) \\}\n",
" \\quad \\text{for all} \\quad\n",
" s \\in [0,1]. \\tag{15.3}\n",
"$$\n",
"\n",
"Here and below, the restriction $ 0 \\leq t $ in the minimum is understood.\n",
"\n",
"The operator $ T $ is similar to a Bellman operator.\n",
"\n",
"Under this analogy, $ p $ corresponds to a value function and $ \\delta $ to a discount factor.\n",
"\n",
"But $ \\delta > 1 $, so $ T $ is not a contraction in any obvious metric, and in fact, $ T^n p $ diverges for many choices of $ p $.\n",
"\n",
"Nevertheless, there exists a domain on which $ T $ is well-behaved: the set\n",
"of convex increasing continuous functions $ p \\colon [0,1] \\to \\mathbb R $ such that $ c'(0) s \\leq p(s) \\leq c(s) $ for all $ 0 \\leq s \\leq 1 $.\n",
"\n",
"We denote this set of functions by $ \\mathcal P $.\n",
"\n",
"In [[Kikuchi *et al.*, 2018](https://python-advanced.quantecon.org/zreferences.html#id231)] it is shown that the following statements are true:\n",
"\n",
"1. $ T $ maps $ \\mathcal P $ into itself. \n",
"1. $ T $ has a unique fixed point in $ \\mathcal P $, denoted below by $ p^* $. \n",
"1. For all $ p \\in \\mathcal P $ we have $ T^k p \\to p^* $ uniformly as $ k \\to \\infty $. \n",
"\n",
"\n",
"Now consider the choice function\n",
"\n",
"\n",
"\n",
"$$\n",
"t^*(s) := \\text{ the solution to } \\min_{ t \\leq s} \\{c(s - t) + \\delta p^*(t) \\} \\tag{15.4}\n",
"$$\n",
"\n",
"By definition, $ t^*(s) $ is the cost-minimizing upstream boundary for a firm that\n",
"is contracted to deliver the good at stage $ s $ and faces the price\n",
"function $ p^* $.\n",
"\n",
"Since $ p^* $ lies in $ \\mathcal P $ and since $ c $ is strictly convex, it follows that the right-hand side of [(15.4)](#equation-coase-argmins) is continuous and strictly convex in $ t $.\n",
"\n",
"Hence the minimizer $ t^*(s) $ exists and is uniquely defined.\n",
"\n",
"We can use $ t^* $ to construct an equilibrium allocation as follows:\n",
"\n",
"Recall that firm 1 sells the completed good at stage $ s=1 $, its optimal upstream boundary is $ t^*(1) $.\n",
"\n",
"Hence firm 2’s optimal upstream boundary is $ t^*(t^*(1)) $.\n",
"\n",
"Continuing in this way produces the sequence $ \\{t^*_i\\} $ defined by\n",
"\n",
"\n",
"\n",
"$$\n",
"t_0^* = 1 \\quad \\text{and} \\quad t_i^* = t^*(t_{i-1}) \\tag{15.5}\n",
"$$\n",
"\n",
"The sequence ends when a firm chooses to complete all remaining tasks.\n",
"\n",
"We label this firm (and hence the number of firms in the chain) as\n",
"\n",
"\n",
"\n",
"$$\n",
"n^* := \\inf \\{i \\in \\mathbb N \\,:\\, t^*_i = 0\\} \\tag{15.6}\n",
"$$\n",
"\n",
"The task allocation corresponding to [(15.5)](#equation-coase-ralloc) is given by $ \\ell_i^* := t_{i-1}^* - t_i^* $ for all $ i $.\n",
"\n",
"In [[Kikuchi *et al.*, 2018](https://python-advanced.quantecon.org/zreferences.html#id231)] it is shown that\n",
"\n",
"1. The value $ n^* $ in [(15.6)](#equation-coase-eqfn) is well-defined and finite, \n",
"1. the allocation $ \\{\\ell^*_i\\} $ is feasible, and \n",
"1. the price function $ p^* $ and this allocation together forms an equilibrium for the production chain. \n",
"\n",
"\n",
"While the proofs are too long to repeat here,\n",
"much of the insight can be obtained by observing that, as a fixed point of $ T $, the equilibrium price function must satisfy\n",
"\n",
"\n",
"\n",
"$$\n",
"p^*(s) =\n",
"\\min_{t \\leq s} \\, \\{ c(s - t) + \\delta p^*(t) \\}\n",
"\\quad \\text{for all} \\quad s \\in [0, 1] \\tag{15.7}\n",
"$$\n",
"\n",
"From this equation, it is clear that so profits are zero for all incumbent firms."
]
},
{
"cell_type": "markdown",
"id": "223a1a71",
"metadata": {},
"source": [
"### Marginal Conditions\n",
"\n",
"We can develop some additional insights on the behavior of firms by examining marginal conditions associated with the equilibrium.\n",
"\n",
"As a first step, let $ \\ell^*(s) := s - t^*(s) $.\n",
"\n",
"This is the cost-minimizing range of in-house tasks for a firm with downstream boundary $ s $.\n",
"\n",
"In [[Kikuchi *et al.*, 2018](https://python-advanced.quantecon.org/zreferences.html#id231)] it is shown that $ t^* $ and $ \\ell^* $ are increasing and continuous, while $ p^* $ is continuously differentiable at all $ s \\in (0, 1) $ with\n",
"\n",
"\n",
"\n",
"$$\n",
"(p^*)'(s) = c'(\\ell^*(s)) \\tag{15.8}\n",
"$$\n",
"\n",
"Equation [(15.8)](#equation-coase-env) follows from $ p^*(s) = \\min_{t \\leq s} \\, \\{ c(s-t) + \\delta p^*(t) \\} $ and the envelope theorem for derivatives.\n",
"\n",
"A related equation is the first order condition for $ p^*(s) = \\min_{t \\leq s} \\, \\{ c(s-t) + \\delta p^*(t) \\} $, the minimization problem for a firm with upstream boundary $ s $, which is\n",
"\n",
"\n",
"\n",
"$$\n",
"\\delta (p^*)'(t^*(s)) = c'(s - t^*(s)) \\tag{15.9}\n",
"$$\n",
"\n",
"This condition matches the marginal condition expressed verbally by\n",
"Coase that we stated above:\n",
"\n",
"> “A firm will tend to expand until the costs of organizing an extra\n",
"transaction within the firm become equal to the costs of carrying\n",
"out the same transaction by means of an exchange on the\n",
"open market…”\n",
"\n",
"\n",
"Combining [(15.8)](#equation-coase-env) and [(15.9)](#equation-coase-foc) and evaluating at $ s=t_i $, we see that active firms that are adjacent satisfy\n",
"\n",
"\n",
"\n",
"$$\n",
"\\delta \\, c'(\\ell^*_{i+1}) = c'(\\ell^*_i) \\tag{15.10}\n",
"$$\n",
"\n",
"In other words, the marginal in-house cost per task at a given firm is equal to that of its upstream partner multiplied by gross transaction cost.\n",
"\n",
"This expression can be thought of as a **Coase–Euler equation,** which determines\n",
"inter-firm efficiency by indicating how two costly forms of coordination (markets and management) are jointly minimized in equilibrium."
]
},
{
"cell_type": "markdown",
"id": "9d206e4c",
"metadata": {},
"source": [
"## Implementation\n",
"\n",
"For most specifications of primitives, there is no closed-form solution for the equilibrium as far as we are aware.\n",
"\n",
"However, we know that we can compute the equilibrium corresponding to a given transaction cost parameter $ \\delta $ and a cost function $ c $\n",
"by applying the results stated above.\n",
"\n",
"In particular, we can\n",
"\n",
"1. fix initial condition $ p \\in \\mathcal P $, \n",
"1. iterate with $ T $ until $ T^n p $ has converged to $ p^* $, and \n",
"1. recover firm choices via the choice function [(15.3)](#equation-coase-deft) \n",
"\n",
"\n",
"At each iterate, we will use continuous piecewise linear interpolation of functions.\n",
"\n",
"To begin, here’s a class to store primitives and a grid:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "bc9f04a5",
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"class ProductionChain:\n",
"\n",
" def __init__(self,\n",
" n=1000,\n",
" delta=1.05,\n",
" c=lambda t: np.exp(10 * t) - 1):\n",
"\n",
" self.n, self.delta, self.c = n, delta, c\n",
" self.grid = np.linspace(1e-04, 1, n)"
]
},
{
"cell_type": "markdown",
"id": "2980347e",
"metadata": {},
"source": [
"Now let’s implement and iterate with $ T $ until convergence.\n",
"\n",
"Recalling that our initial condition must lie in $ \\mathcal P $, we set\n",
"$ p_0 = c $"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5c4c443b",
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"def compute_prices(pc, tol=1e-5, max_iter=5000):\n",
" \"\"\"\n",
" Compute prices by iterating with T\n",
"\n",
" * pc is an instance of ProductionChain\n",
" * The initial condition is p = c\n",
"\n",
" \"\"\"\n",
" delta, c, n, grid = pc.delta, pc.c, pc.n, pc.grid\n",
" p = c(grid) # Initial condition is c(s), as an array\n",
" new_p = np.empty_like(p)\n",
" error = tol + 1\n",
" i = 0\n",
"\n",
" while error > tol and i < max_iter:\n",
" for j, s in enumerate(grid):\n",
" Tp = lambda t: delta * np.interp(t, grid, p) + c(s - t)\n",
" new_p[j] = Tp(fminbound(Tp, 0, s))\n",
" error = np.max(np.abs(p - new_p))\n",
" p = new_p\n",
" i = i + 1\n",
"\n",
" if i < max_iter:\n",
" print(f\"Iteration converged in {i} steps\")\n",
" else:\n",
" print(f\"Warning: iteration hit upper bound {max_iter}\")\n",
"\n",
" p_func = lambda x: np.interp(x, grid, p)\n",
" return p_func"
]
},
{
"cell_type": "markdown",
"id": "d4164a63",
"metadata": {},
"source": [
"The next function computes optimal choice of upstream boundary and range of\n",
"task implemented for a firm face price function p_function and with downstream boundary $ s $."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3e906901",
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"def optimal_choices(pc, p_function, s):\n",
" \"\"\"\n",
" Takes p_func as the true function, minimizes on [0,s]\n",
"\n",
" Returns optimal upstream boundary t_star and optimal size of\n",
" firm ell_star\n",
"\n",
" In fact, the algorithm minimizes on [-1,s] and then takes the\n",
" max of the minimizer and zero. This results in better results\n",
" close to zero\n",
"\n",
" \"\"\"\n",
" delta, c = pc.delta, pc.c\n",
" f = lambda t: delta * p_function(t) + c(s - t)\n",
" t_star = max(fminbound(f, -1, s), 0)\n",
" ell_star = s - t_star\n",
" return t_star, ell_star"
]
},
{
"cell_type": "markdown",
"id": "3f463f22",
"metadata": {},
"source": [
"The allocation of firms can be computed by recursively stepping through firms’ choices of\n",
"their respective upstream boundary, treating the previous firm’s upstream boundary as their own downstream boundary.\n",
"\n",
"In doing so, we start with firm 1, who has downstream boundary $ s=1 $."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "00ac014b",
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"def compute_stages(pc, p_function):\n",
" s = 1.0\n",
" transaction_stages = [s]\n",
" while s > 0:\n",
" s, ell = optimal_choices(pc, p_function, s)\n",
" transaction_stages.append(s)\n",
" return np.array(transaction_stages)"
]
},
{
"cell_type": "markdown",
"id": "16bd62bd",
"metadata": {},
"source": [
"Let’s try this at the default parameters.\n",
"\n",
"The next figure shows the equilibrium price function, as well as the\n",
"boundaries of firms as vertical lines"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a96b30f7",
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"pc = ProductionChain()\n",
"p_star = compute_prices(pc)\n",
"\n",
"transaction_stages = compute_stages(pc, p_star)\n",
"\n",
"fig, ax = plt.subplots()\n",
"\n",
"ax.plot(pc.grid, p_star(pc.grid))\n",
"ax.set_xlim(0.0, 1.0)\n",
"ax.set_ylim(0.0)\n",
"for s in transaction_stages:\n",
" ax.axvline(x=s, c=\"0.5\")\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "a94db42a",
"metadata": {},
"source": [
"Here’s the function $ \\ell^* $, which shows how large a firm with\n",
"downstream boundary $ s $ chooses to be"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "5f0ca3ae",
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"ell_star = np.empty(pc.n)\n",
"for i, s in enumerate(pc.grid):\n",
" t, e = optimal_choices(pc, p_star, s)\n",
" ell_star[i] = e\n",
"\n",
"fig, ax = plt.subplots()\n",
"ax.plot(pc.grid, ell_star, label=\"$\\ell^*$\")\n",
"ax.legend(fontsize=14)\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "4aa0a813",
"metadata": {},
"source": [
"Note that downstream firms choose to be larger, a point we return to below."
]
},
{
"cell_type": "markdown",
"id": "117d081a",
"metadata": {},
"source": [
"## Exercises\n",
"\n",
"\n",
""
]
},
{
"cell_type": "markdown",
"id": "ec89ea03",
"metadata": {},
"source": [
"## Exercise 15.1\n",
"\n",
"The number of firms is endogenously determined by the primitives.\n",
"\n",
"What do you think will happen in terms of the number of firms as $ \\delta $ increases? Why?\n",
"\n",
"Check your intuition by computing the number of firms at delta in (1.01, 1.05, 1.1)."
]
},
{
"cell_type": "markdown",
"id": "e7d585f0",
"metadata": {},
"source": [
"## Solution to[ Exercise 15.1](https://python-advanced.quantecon.org/#coa_ex1)\n",
"\n",
"Here is one solution"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "51507883",
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"for delta in (1.01, 1.05, 1.1):\n",
"\n",
" pc = ProductionChain(delta=delta)\n",
" p_star = compute_prices(pc)\n",
" transaction_stages = compute_stages(pc, p_star)\n",
" num_firms = len(transaction_stages)\n",
" print(f\"When delta={delta} there are {num_firms} firms\")"
]
},
{
"cell_type": "markdown",
"id": "27124c4a",
"metadata": {},
"source": [
"## Exercise 15.2\n",
"\n",
"The **value added** of firm $ i $ is $ v_i := p^*(t_{i-1}) - p^*(t_i) $.\n",
"\n",
"One of the interesting predictions of the model is that value added is increasing with downstreamness, as are several other measures of firm size.\n",
"\n",
"Can you give any intution?\n",
"\n",
"Try to verify this phenomenon (value added increasing with downstreamness) using the code above."
]
},
{
"cell_type": "markdown",
"id": "e7a1fce2",
"metadata": {},
"source": [
"## Solution to[ Exercise 15.2](https://python-advanced.quantecon.org/#coa_ex2)\n",
"\n",
"Firm size increases with downstreamness because $ p^* $, the equilibrium price function, is increasing and strictly convex.\n",
"\n",
"This means that, for a given producer, the marginal cost of the input purchased from the producer just upstream from itself in the chain increases as we go further downstream.\n",
"\n",
"Hence downstream firms choose to do more in house than upstream firms — and are therefore larger.\n",
"\n",
"The equilibrium price function is strictly convex due to both transaction\n",
"costs and diminishing returns to management.\n",
"\n",
"One way to put this is that firms are prevented from completely mitigating the costs\n",
"associated with diminishing returns to management — which induce convexity — by transaction costs. This is because transaction costs force firms to have nontrivial size.\n",
"\n",
"Here’s one way to compute and graph value added across firms"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "88b497ee",
"metadata": {
"hide-output": false
},
"outputs": [],
"source": [
"pc = ProductionChain()\n",
"p_star = compute_prices(pc)\n",
"stages = compute_stages(pc, p_star)\n",
"\n",
"va = []\n",
"\n",
"for i in range(len(stages) - 1):\n",
" va.append(p_star(stages[i]) - p_star(stages[i+1]))\n",
"\n",
"fig, ax = plt.subplots()\n",
"ax.plot(va, label=\"value added by firm\")\n",
"ax.set_xticks((5, 25))\n",
"ax.set_xticklabels((\"downstream firms\", \"upstream firms\"))\n",
"plt.show()"
]
}
],
"metadata": {
"date": 1714698770.3032134,
"filename": "coase.md",
"kernelspec": {
"display_name": "Python",
"language": "python3",
"name": "python3"
},
"title": "Coase’s Theory of the Firm"
},
"nbformat": 4,
"nbformat_minor": 5
}